赞
踩
未完待续。。。。
市面上(x宝上)便宜的CAN模块实在是太少了,好在有Seeed和Waveshare两家在做,控制芯片和收发芯片貌似都一样,开源的魅力。
最近Seeed把MCP2517升级到了MCP2518,而Waveshare则下架了,难道MCP2517有什么问题么。。。
将CAN FD module的pwr/spi/int的pin连接到Nano,由于Nano的40pin和Raspberry Pi的不是一一对应的,没法直接把module叠加上去了。但是杜邦线可以带我们飞(飞线)啊。
Seeed CANFD module 与Jetson Nano的连接
可以参考Seeed的Wiki(https://wiki.seeedstudio.com/2-Channel-CAN-BUS-FD-Shield-for-Raspberry-Pi/)
驱动可以从GitHub中下载(https://github.com/seeed-Studio/pi-hats)。
make all
2xMCP2518FD-overlay.dts 是针对raspberry pi的,没有办法直接在Nano中使用,需要针对Nano的DTS做一些修改。
可以在板子上通过dtc将Nano的dtb转换成dts,加入CANFD的修改,再编译成dtb。
DTB --> DTS
//TODO: 忘记了,回头再补上
修改DTS
- clock {
- /* ... */
-
- mcp2517fd_osc: mcp2517fd_osc {
- compatible = "fixed-clock";
- #clock-cells = <0>;
- clock-frequency = <40000000>;
- clock-accuracy = <100>;
- };
- };
-
- /* ... */
-
- spi@7000d400 {
- /* ... */
-
- can0:can@0 {
- compatible = "microchip,mcp2517fd";
- reg = <0x0>;
- spi-max-frequency = <125000000>;
- interrupt-parent = <0x56>;
- interrupts = <0xC8 8>; /* IRQ_TYPE_LEVEL_LOW */
- clocks = <&mcp2517fd_osc>;
- controller-data {
- nvidia,cs-setup-clk-count = <0x1e>;
- nvidia,cs-hold-clk-count = <0x1e>;
- nvidia,rx-clk-tap-delay = <0x1f>;
- nvidia,tx-clk-tap-delay = <0x0>;
- };
-
- };
-
- /*
- spi@0 {
- compatible = "spidev";
- reg = <0x0>;
- spi-max-frequency = <0x1f78a40>;
- nvidia,enable-hw-based-cs;
- nvidia,rx-clk-tap-delay = <0x7>;
- };
- */
- };
-
- spi@7000d600 {
- /* ... */
-
- /*
- spi@0 {
- compatible = "spidev";
- reg = <0x0>;
- spi-max-frequency = <0x1f78a40>;
- nvidia,enable-hw-based-cs;
- nvidia,rx-clk-tap-delay = <0x6>;
- };
- */
-
- can1:can@0 {
- compatible = "microchip,mcp2517fd";
- reg = <0x0>;
- spi-max-frequency = <125000000>;
- interrupt-parent = <0x56>;
- interrupts = <0x26 8>; /* IRQ_TYPE_LEVEL_LOW */
- clocks = <&mcp2517fd_osc>;
- controller-data {
- nvidia,cs-setup-clk-count = <0x1e>;
- nvidia,cs-hold-clk-count = <0x1e>;
- nvidia,rx-clk-tap-delay = <0x1f>;
- nvidia,tx-clk-tap-delay = <0x0>;
- };
- };
- };
因为CANFD连接了Nano的SPI0和SPI1,所以将DTS中原来的SPI0/1的配置去掉了,分别配置can0和can1,另外,在clock中加入了MCP25xx的clock配置。
DTS --> DTB
dtc -I dts -O dtb -o tegra210-p3448-0000-p3449-0000-b00-mcp25xxfd.dtb tegra210-p3448-0000-p3449-0000-b00-mcp25xxfd.dts
配置启动项,使用新的DTB
//TODO: 忘记了,回头再补上
以上在板子上的修改主要是为了调试,最后还需要将修改集成到BSP中。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。