[color=rgb(51, 51, 51) !important] 全志A40i或者T3的CPU中無CAN控制器,而在實(shí)際使用過程中,會用到CAN,通常會采用SPI轉(zhuǎn)CAN的方式。
在OKA40i-C底板上,有一路SPI,但由于電壓與mcp2515的電壓不匹配,所以會采用串口2的這組復(fù)用為SPI外接mcp2515模塊。
[color=rgb(51, 51, 51) !important]根據(jù)CPU手冊第三章描述,可以將PI17-19復(fù)用為SPI1,采用PH08作為中斷。 ![]() [color=rgb(51, 51, 51) !important]A40i/T3采用sys_config.fex或者dts 配置引腳復(fù)用功能,下面我們采用dts 進(jìn)行配置。
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]同時修改設(shè)備樹: ![]() ![]()
02-修改defconfig[color=rgb(51, 51, 51) !important]采用通過其他平臺驗(yàn)證,且適配設(shè)備樹的驅(qū)動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配置,默認(rèn)已支持,此處不再說明。
03-配置iproute[color=rgb(51, 51, 51) !important]文件系統(tǒng): [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節(jié)點(diǎn)[color=rgb(51, 51, 51) !important]啟動之后,ifconfig 查看出現(xiàn)can0節(jié)點(diǎn)。使用以下命令進(jìn)行測試: [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]如果有必要請聯(lián)系飛凌技術(shù)服務(wù)人員,提供patch文件。
注意事項(xiàng)[color=rgb(51, 51, 51) !important]在設(shè)備樹中,用作中斷時,因A40i/T3只能使用PH組的引腳復(fù)用為中斷,在設(shè)備樹中設(shè)置中斷時的如下: [color=rgb(51, 51, 51) !important]interrupt-parent = <&pio>; [color=rgb(51, 51, 51) !important]interrupts = <8 0>; [color=rgb(51, 51, 51) !important]另外,需要注意驅(qū)動中的中斷觸發(fā)方式。 [color=rgb(51, 51, 51) !important]原文鏈接:https://www.forlinx.com/article_view_794.html
|