请问下各位大神,匠芯创的CAN rx过滤器,如何配置啊?
官方例程看不明白,谁帮解释下?谢谢。
如下:
#if CAN_RX_FILTER_ENABLE
/* config can rx filter */
struct rt_can_filter_item items[2] =
{
//Only receive standard data frame with ID 0x100~0x1FF
RT_CAN_FILTER_ITEM_INIT(0x100, 0, 0, 0, 0x700, RT_NULL, RT_NULL),
//Only receive standard data frame with ID 0x345
RT_CAN_FILTER_ITEM_INIT(0x345, 0, 0, 0, 0x7FF, RT_NULL, RT_NULL),
};
struct rt_can_filter_config cfg = {2, 1, items};
ret = rt_device_control(can_rx_dev, RT_CAN_CMD_SET_FILTER, &cfg);
if (ret)
{
rt_kprintf("Setting can filter failed!\n");
return ret;
}
#endif离线