Hi I had a question to setup the MCP2515 driver in the zephyr project.
We have a custom board for the decawave DWM1001 module, which uses a nRF52832 chip. They have a device tree file in the zephyr project for this module, so I started with that device tree and configured it for our setup, which is
| NRF52832 | MCP25625 |
| P0.14 | SPI_CS |
| P0.22 | SPI_MISO |
| P0.31 | SPI_MOSI |
| P0.30 | SPI_SCK |
| P0.27 | CAN_RESET |
| P0.03 | CAN_INT |
. The devicetree file looks as follows
/dts-v1/;
#include <nordic/nrf52832_qfaa.dtsi>
/ {
model = "nRF52832 Sevendof";
compatible = "decawave,dwm1001", "nordic,nrf52832-qfaa",
"nordic,nrf52832";
chosen {
zephyr,console = &uart0;
zephyr,shell-uart = &uart0;
zephyr,uart-mcumgr = &uart0;
zephyr,bt-mon-uart = &uart0;
zephyr,bt-c2h-uart = &uart0;
zephyr,sram = &sram0;
zephyr,flash = &flash0;
zephyr,code-partition = &slot0_partition;
};
leds {
compatible = "gpio-leds";
led0_red: led_0 {
gpios = <&gpio0 2 GPIO_INT_ACTIVE_LOW>;
label = "Red LED 0";
};
can_reset_pin: can_reset {
gpios = <&gpio0 27 GPIO_INT_ACTIVE_LOW>;
label = "CAN Reset Pin";
};
};
/* These aliases are provided for compatibility with samples */
aliases {
led0 = &led0_red;
led0-red = &led0_red;
canreset = &can_reset_pin;
};
};
&adc {
status = "okay";
};
&gpiote {
status = "okay";
};
&gpio0 {
status = "okay";
};
&uart0 {
status = "okay";
compatible = "nordic,nrf-uart";
current-speed = <115200>;
tx-pin = <5>;
rx-pin = <11>;
};
&i2c0 {
compatible = "nordic,nrf-twi";
status = "okay";
sda-pin = <29>;
scl-pin = <28>;
};
&spi1 {
compatible = "nordic,nrf-spi";
status = "okay";
sck-pin = <30>;
mosi-pin = <31>;
miso-pin = <22>;
cs-gpios = <&gpio0 14 0>;
mcp2515@0 {
compatible = "microchip,mcp2515";
spi-max-frequency = <1000000>;
int-gpios = <&gpio0 3 0>; /* D2 */
status = "okay";
label = "CAN_1";
reg = <0x0>;
osc-freq = <16000000>;
bus-speed = <125000>;
sjw = <1>;
prop-seg = <2>;
phase-seg1 = <7>;
phase-seg2 = <6>;
#address-cells = <1>;
#size-cells = <0>;
};
};
&spi2 {
compatible = "nordic,nrf-spi";
status = "okay";
sck-pin = <16>;
mosi-pin = <20>;
miso-pin = <18>;
cs-gpios = <&gpio0 17 0>;
};
&flash0 {
/*
* For more information, see:
* http://docs.zephyrproject.org/latest/guides/dts/index.html#flash-partitions
*/
partitions {
compatible = "fixed-partitions";
#address-cells = <1>;
#size-cells = <1>;
boot_partition: partition@0 {
label = "mcuboot";
reg = <0x00000000 0xc000>;
};
slot0_partition: partition@c000 {
label = "image-0";
reg = <0x0000C000 0x32000>;
};
slot1_partition: partition@3e000 {
label = "image-1";
reg = <0x0003E000 0x32000>;
};
scratch_partition: partition@70000 {
label = "image-scratch";
reg = <0x00070000 0xa000>;
};
storage_partition: partition@7a000 {
label = "storage";
reg = <0x0007a000 0x00006000>;
};
};
};
. The project file looks as follows CONFIG_GPIO=y CONFIG_SERIAL=n CONFIG_PRINTK=y CONFIG_RTT_CONSOLE=y # Alternate conf file required for building the CAN sample for the # MCP2515 stand alone CAN controller CONFIG_CAN=y CONFIG_CAN_INIT_PRIORITY=80 CONFIG_CAN_MCP2515_MAX_FILTER=5. The main project file I am using is the can example from zephyr. I only added the pull up for the CAN_RESET GPIO, which I can confirm works. I am not seeing any messages on the SPI pins, which make me suspect that the overlay is incorrect. I just added the mcp into the spi setup in the overlay, from a shield example, I am not to sure if it is correct and what sjw, prop-seg, phase-seg1 and phase-seg2 mean. Any help or pointers are appreciated. The program stops with debug messages "CAN: Device driver not found.".