EDA365欢迎您登录!
您需要 登录 才可以下载或查看,没有帐号?注册
x
[color=rgb(51, 51, 51) !important] 全志A40i或者T3的CPU中无CAN控制器,而在实际使用过程中,会用到CAN,通常会采用SPI转CAN的方式。 1 d& X2 _8 B, x# ]0 }. v
在OKA40i-C底板上,有一路SPI,但由于电压与mcp2515的电压不匹配,所以会采用串口2的这组复用为SPI外接mcp2515模块。
! E; o3 w- C( B% ?[color=rgb(51, 51, 51) !important]根据CPU手册第三章描述,可以将PI17-19复用为SPI1,采用PH08作为中断。 ![]() [color=rgb(51, 51, 51) !important]A40i/T3采用sys_config.fex或者dts 配置引脚复用功能,下面我们采用dts 进行配置。 ( n- h- {( Y! u! W
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]同时修改设备树: ![]() - M4 ?4 g w* i& v6 o
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配置,默认已支持,此处不再说明。
/ K# H5 z* s; \1 W8 z03-配置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]重新编译,并打包镜像,烧录。
# ^' N* V8 n! s; y2 t( N! l04-测试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文件。
0 c# u& g* f: L& e' V注意事项[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]另外,需要注意驱动中的中断触发方式。
9 t2 m Y, w1 Y( X0 E6 m( Y, A |