

#ifndef __ecan_H
#define __ecan_H



typedef struct 
{
	unsigned SID:11;
	unsigned FILHIT:5;
	unsigned CMSGTS:16;
}cmsgsid;

typedef struct 
{
	unsigned DLC:4;
	unsigned RB0:1;
	unsigned :3;
	unsigned RB1:1;
	unsigned RTR:1;
	unsigned EID:18;
	unsigned IDE:1;
	unsigned SRR:1;
	unsigned :2;
}cmsgeid;

typedef struct
{
	unsigned Byte0:8;
	unsigned Byte1:8;
	unsigned Byte2:8;
	unsigned Byte3:8;
}cmsgdata0;

typedef struct
{
	unsigned Byte4:8;
	unsigned Byte5:8;
	unsigned Byte6:8;
	unsigned Byte7:8;
}cmsgdata1;

typedef union uCanMsgBuffer 
{
	struct
	{
		cmsgsid CMSGSID;
		cmsgeid CMSGEID;
		cmsgdata0 CMSGDATA0;
		cmsgdata1 CMSGDATA1;
	};
	int messageWord[4];
	
}CanMsgBuffer;




extern unsigned char RX_SID_Msg_Flag;         //接收标志位
extern unsigned char RX_EID_Msg_Flag;

extern unsigned char TXbuffer[8];             //发送数据缓冲区
extern unsigned char RXbuffer[8];             //接收数据缓冲区


extern void CAN_Init(void);

extern void Write_CAN_Baud(void);
extern void CAN1RxMsgProcess(void);

extern void Write_SID_Filter(unsigned short SendSID);
extern void Write_EID_Filter(unsigned int SendEID);

extern void CAN_TX_EID_Message(unsigned int SendEID);
extern void CAN_TX_SID_Message(unsigned short MsgSID);
	
	
	
	
#endif


