然后是设置速率和过滤器
/**
* @brief Configures the CAN, transmit and receive by polling
* @param None
* @retval : PASSED if the reception is well done, FAILED in other case
*/
void CAN_Polling_init(void)
{
CAN_InitTypeDef CAN_InitStructure;
CAN_FilterInitTypeDef CAN_FilterInitStructure;
/* CAN register init */
CAN_DeInit(CAN1);
// CAN_StructInit(&CAN_InitStructure);
// printf("RxMessage.StdId is 0x%x,RxMessage.DLC is 0x%x,RxMessage.Data[0] is 0x%x,RxMessage.Data[1] is 0x%x\r\n",
// RxMessage.StdId,RxMessage.DLC,RxMessage.Data[0],RxMessage.Data[1]);
if (RxMessage.StdId!=0x6f1)
{
return FAILED;
}
if (RxMessage.IDE!=CAN_ID_STD)
{
return FAILED;
}
if (RxMessage.DLC!=4)
{
return FAILED;
}
if ((RxMessage.Data[0]<<8|RxMessage.Data[1])!=0x4002)
{
return FAILED;
}