查看: 1840|回复: 0

飞凌嵌入式分享丨全志 A40i / T3对CAN的支持

[复制链接]
发表于 2021-12-8 09:12:00 | 显示全部楼层 |阅读模式
关键词: 飞凌嵌入式
[color=rgb(51, 51, 51) !important]全志A40i或者T3的CPU中无CAN控制器,而在实际使用过程中,会用到CAN,通常会采用SPI转CAN的方式。

在OKA40i-C底板上,有一路SPI,但由于电压与mcp2515的电压不匹配,所以会采用串口2的这组复用为SPI外接mcp2515模块。
[color=rgb(51, 51, 51) !important]根据CPU手册第三章描述,可以将PI17-19复用为SPI1,采用PH08作为中断。
[color=rgb(51, 51, 51) !important]A40i/T3采用sys_config.fex或者dts 配置引脚复用功能,下面我们采用dts 进行配置。

01-打开SPI1
[color=rgb(51, 51, 51) !important]修改sys_config.fex,将uart2的配置去掉,打开SPI1的配置。
[color=rgb(51, 51, 51) !important]同时将PH08注释掉:
[color=rgb(51, 51, 51) !important]同时修改设备树:

02-修改defconfig
[color=rgb(51, 51, 51) !important]采用通过其他平台验证,且适配设备树的驱动mcp251x.c,
[color=rgb(51, 51, 51) !important]修改defconfig 配置文件:
[color=rgb(51, 51, 51) !important]Networking support ---> CAN bussubsystem support--->CAN Device Drivers --->Microchip MCP251x SPI CAN controllers选中。
[color=rgb(51, 51, 51) !important]同时选中SPI配置,默认已支持,此处不再说明。

03-配置iproute
[color=rgb(51, 51, 51) !important]文件系统:
[color=rgb(51, 51, 51) !important]buildroot-201611/configs/sun8iw11p1_hf_defconfig
[color=rgb(51, 51, 51) !important]需要配置上BR2_PACKAGE_IPROUTE2=y.
[color=rgb(51, 51, 51) !important]重新编译,并打包镜像,烧录。

04-测试can0节点
[color=rgb(51, 51, 51) !important]启动之后,ifconfig 查看出现can0节点。使用以下命令进行测试:
[color=rgb(51, 51, 51) !important]ifconfig can0 down
[color=rgb(51, 51, 51) !important]ip link set can0 up type can bitrate 125000 triple-sampling on
[color=rgb(51, 51, 51) !important]ifconfig can0 up
[color=rgb(51, 51, 51) !important]cansend can0 123#12345678
[color=rgb(51, 51, 51) !important]candump can0
[color=rgb(51, 51, 51) !important]如果有必要请联系飞凌技术服务人员,提供patch文件。

注意事项
[color=rgb(51, 51, 51) !important]在设备树中,用作中断时,因A40i/T3只能使用PH组的引脚复用为中断,在设备树中设置中断时的如下:
[color=rgb(51, 51, 51) !important]interrupt-parent = <&pio>;
[color=rgb(51, 51, 51) !important]interrupts = <8 0>;
[color=rgb(51, 51, 51) !important]另外,需要注意驱动中的中断触发方式。
[color=rgb(51, 51, 51) !important]原文链接:https://www.forlinx.com/article_view_794.html

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关于我们  -  服务条款  -  使用指南  -  站点地图  -  友情链接  -  联系我们
电子工程网 © 版权所有   京ICP备16069177号 | 京公网安备11010502021702
快速回复 返回顶部 返回列表