電子工程網(wǎng)

標題: 飛凌嵌入式分享丨全志 A40i / T3對CAN的支持 [打印本頁(yè)]

作者: 哦哈喲    時(shí)間: 2021-12-8 09:12
標題: 飛凌嵌入式分享丨全志 A40i / T3對CAN的支持
[color=rgb(51, 51, 51) !important]全志A40i或者T3的CPU中無(wú)CAN控制器,而在實(shí)際使用過(guò)程中,會(huì )用到CAN,通常會(huì )采用SPI轉CAN的方式。

在OKA40i-C底板上,有一路SPI,但由于電壓與mcp2515的電壓不匹配,所以會(huì )采用串口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 進(jìn)行配置。

01-打開(kāi)SPI1
[color=rgb(51, 51, 51) !important]修改sys_config.fex,將uart2的配置去掉,打開(kāi)SPI1的配置。
[color=rgb(51, 51, 51) !important]同時(shí)將PH08注釋掉:
[color=rgb(51, 51, 51) !important]同時(shí)修改設備樹(shù):

02-修改defconfig
[color=rgb(51, 51, 51) !important]采用通過(guò)其他平臺驗證,且適配設備樹(shù)的驅動(dòng)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]同時(shí)選中SPI配置,默認已支持,此處不再說(shuō)明。

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節點(diǎn)
[color=rgb(51, 51, 51) !important]啟動(dòng)之后,ifconfig 查看出現can0節點(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文件。

注意事項
[color=rgb(51, 51, 51) !important]在設備樹(shù)中,用作中斷時(shí),因A40i/T3只能使用PH組的引腳復用為中斷,在設備樹(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]另外,需要注意驅動(dòng)中的中斷觸發(fā)方式。
[color=rgb(51, 51, 51) !important]原文鏈接:https://www.forlinx.com/article_view_794.html






歡迎光臨 電子工程網(wǎng) (http://selenalain.com/) Powered by Discuz! X3.4
午夜高清国产拍精品福利|亚洲色精品88色婷婷七月丁香|91久久精品无码一区|99久久国语露脸精品|动漫卡通亚洲综合专区48页