#ifndef _rs485_H
#define _rs485_H	

#include "stm32f10x.h"                  // Device header
 								  


extern u8 RS485_RX_BUF[128]; 		//receive buffer, max 128
extern u8 RS485_RX_CNT;   			// received data length
extern u8 RS485_RX_Flag_Num;
extern u8 RS485_RX_Flag;

#define RS485_1_TX_EN		PBout(11)	// 485 mode control. 0:receiving; 1:Send
#define RS485_2_TX_EN		PBout(10)	// 485 mode control. 0:receiving; 1:Send
#define RS485_3_TX_EN		PBout(4)	// 485 mode control. 0:receiving; 1:Send


void RS485_1_Init(u32 bound);
void RS485_2_Init(u32 bound);
void RS485_3_Init(u32 bound);
void RS485_1_Send_Data(u8 *buf,u8 len);
void RS485_1_Send_Data_1(u8 *buf,u8 len);
//void RS485_3_Send_Data_1(void);
void RS485_1_Send_Data_2(void);
void RS485_1_Send_Data_3(void);
void RS485_3_Send_Data(u8 *buf,u8 len);
void RS485_Receive_Data(u8 *buf,u8 *len);
void SN74CB3Q3253_Init(void);
u8 CRC16_check(u8 *puchMsg, u16 usDataLen); 
void GetCRC16(u8 *puchMsg, u16 usDataLen,u8 *uchCRCHi,u8 *uchCRCLo) ;


#endif	   
