#ifndef if_can_h__
#define if_can_h__

//#include "define.h"
#include "stm32f10x_can.h"

typedef struct{	
	uint32_t Reserve1		:3;
	uint32_t srcMACID		:5;
	uint32_t Reserve0		:2;
	uint32_t destMACID	:5;
	uint32_t ACK				:1;
	uint32_t FunClass		:6;
	uint32_t SegFlag		:2;
	uint32_t SegNum			:8;
		
}YeCanID_st;

typedef union{
	uint32_t Exide;
	YeCanID_st yecanid;
}YeCanID_un;



typedef struct{

	uint8_t *rx_databuf; //接收数据缓存
	uint8_t seg_num;  //分段号
	uint8_t seg_flag;//分段标志
	uint16_t rx_index;//接收缓存下标
}YeCanRxFrame_st;

extern volatile uint8_t CAN0_TX_BUSY_Flag;

/*
@brief CAN通讯初始化， 包括CANgpio 过滤器
*/
void YeCanInit(void);
/*
@brief CAN发送通讯帧
@param 源地址
@param 主机地址
@param 发送数据缓存
@param 发送数据长度
@rtv    0 成功 1 失败
*/
uint8_t YeCan_SendFrame(uint8_t srcaddr,uint8_t dstaddr,const uint8_t* txdata, uint16_t len);

#endif
