/* CAN filter init */
CAN_FilterInitStructure.CAN_FilterNumber=1; // 选择过滤器编号
CAN_FilterInitStructure.CAN_FilterMode=CAN_FilterMode_IdMask; //指定了过滤器将被初始化到的模式标识符屏蔽位模式
CAN_FilterInitStructure.CAN_FilterScale=CAN_FilterScale_32bit; //给出了过滤器位宽1个32位过滤器
<SPAN style="COLOR: #ff0000"> CAN_FilterInitStructure.CAN_FilterIdHigh=0x0000; // 标识符匹配
CAN_FilterInitStructure.CAN_FilterIdLow=0x0001; //用来设定过滤器标识符(32位位宽时为其低段位,16位位宽时为第二个
CAN_FilterInitStructure.CAN_FilterMaskIdHigh=0xFFFF; // // 标识符屏蔽位,1:必须匹配,0:不用关心
CAN_FilterInitStructure.CAN_FilterMaskIdLow=0x000f; /</SPAN>/用来设定过滤器屏蔽标识符或者过滤器标识符(32位位宽时为其低段位,16位位宽时为第二个
CAN_FilterInitStructure.CAN_FilterFIFOAssignment=CAN_FIFO1;//设定了指向过滤器的FIFO0
CAN_FilterInitStructure.CAN_FilterActivation=ENABLE; //使能过滤器
CAN_FilterInit(&CAN_FilterInitStructure);
/*数据接收*/
/*i = 0;
while((CAN_MessagePending(CAN_FIFO0) < 1) && (i != 0xFF))//有报文到达FIFO0
{
i++;
} */
while(CAN_MessagePending(CAN1,CAN_FIFO1) < 1);//一直等到有数据收到为止
/* receive */
<SPAN style="COLOR: #ff0000"> RxMessage.StdId=0x00000002;
RxMessage.IDE=CAN_ID_STD;
RxMessage.DLC=4;
RxMessage.Data[0]=0x00;
RxMessage.Data[1]=0x00;
看不懂上面这此如何对应的啊,求帮助。 |