Commit 53336ec9 authored by 郑萍's avatar 郑萍

feat:CAN接收调通

parent 549c3fbc
......@@ -15,8 +15,8 @@ void Can_Init(void)
can_config_st_t Can_Config;
Can_Config.ch = CAN_CH_0;
Can_Config.freq = CAN_500Kbps;
Can_Config.MASK[0] = 0x001fffffU;
Can_Config.MASK[1] = 0x000fffffU;
Can_Config.MASK[0] = 0x1fffffffU;
Can_Config.MASK[1] = 0x1fffffffU;
Can_Config.MASK[2] = 0x1fffffffU;
Can_Config.MASK[3] = 0x1fffffffU;
Can_Config.rx_callback = Can_Rx_Cak;
......
......@@ -6,8 +6,21 @@
CANMSG_Type* CANMSG;
CanTxRxMsg CAN_RecvMsg;
CANBuffList_t CanBufList = {0};
can_rx_callback can_rx_handler = NULL;
uint8_t Read_RingBuff(CanTxRxMsg *data)
{
if (CanBufList.length == 0)
{
return 0;
}
*data = CanBufList.data[CanBufList.Head];
CanBufList.Head = (CanBufList.Head + 1) % LIST_BUF_MAX_NUM;
CanBufList.length--;
return 1;
}
/**
* @brief CAN就收完成回调
*
......@@ -20,8 +33,8 @@ static void can_recv_handler(void *msg)
if (CAN_GetFlagStatus(CAN0, CAN_FLAG_REC) != RESET)
{
CAN_ClearFlag(CAN0, CAN_FLAG_REC);
// CANMSG = CAN_Get_CANxMSGy(CAN0);
// CAN_Receive_IT(CAN0, &CAN_RecvMsg);
CAN_Receive_IT(CAN0, &CanBufList);
Read_RingBuff(&CAN_RecvMsg);
if (can_rx_handler != NULL)
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment