您尚未登录。

楼主 # 今天 10:11:41

dgtg
会员
注册时间: 2017-11-08
已发帖子: 270
积分: 224.5

CAN如何配置过滤器?

请问下各位大神,匠芯创的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

离线

页脚

工信部备案:粤ICP备20025096号 Powered by FluxBB

感谢为中文互联网持续输出优质内容的各位老铁们。 QQ: 516333132, 微信(wechat): whycan_cn (哇酷网/挖坑网/填坑网) service@whycan.cn