
#ifndef _USART1_H
#define _USART1_H

#include "stm32f0xx.h"
#include "stm32f0xx_dma.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

unsigned short GetCRC16(unsigned char *pbuf,  unsigned short len);
#define  u8  unsigned char
#define  u16  unsigned int
#define  u32  unsigned long	

//#define F030_RX_BUFSIZE	512
//#define F030_TX_BUFSIZE	256


#define USART1_RX_BUFSIZE	512
#define USART1_TX_BUFSIZE	256
//typedef struct{
//	uint8_t RxBuf[F030_RX_BUFSIZE];
//	uint16_t RxCount;
//	uint8_t RxNewFlag;
//	
//}F030RxBUFF_T;

void USART1_Init(void);
void requestData(void);
void USART1SendData(void);
void USART1TxData(void *data,int len);
void DMA_Config(void);
typedef struct
{
	u32 slaveID;
	u32 Bound;
	u32 CTscale;
	u32 PTscale;
	
}SettingParams;


typedef struct {
	float ua;
	float	ub;
	float	uc;
	float	ia;
	float	ib;
	float	ic;
	float pa;
	float pb;
	float pc;
	float	pttl;
	float qa;
	float qb;
	float qc;
	float qttl;
	float sa;
	float sb;
	float sc;
	float sttl;
	float freq;
	float cosa;
	float cosb;
	float cosc;
	float costtl;
	float	kwhttli;
	float	kvarhttli;
	float kwhttle;
	float kvarhttle;
	float	thdUa;
	float	thdUb;
	float	thdUc;
	float thdUttl;
	float	thdlRmsa;
	float	thdlRmsb;
	float	thdlRmsc;
	float	thdlRmsttl;
	float	unblU;
	float unblI;
	float leakCurrent;
	float md;//ÐèÁ¿
	float loadRatio;
	float di1State;
	float di2State;
	float temp1;
	float temp2;
	float temp3;
	float temp4;
	float ctnum;
	//
	float NetState;
	float SIMState;
	float SIDState;
}DataStructure;
#endif
