Hello,
I need an example for using the spi in zephyr and how to change the pins if necessary.
Where can I find it?
Thank you
Hello,
I need an example for using the spi in zephyr and how to change the pins if necessary.
Where can I find it?
Thank you
Hello,
DEVICE_DT_GET_ANY has the devicetree compatible as input arugment. You are using a subnode label.
So in case of nrf52dk_nrf52832 this would be:
compatible = "nordic,nrf-spi";
But using this function is probably not a good idea since you have several SPI peripherals with the same compatibale avialable.
spi0: spi@40003000 {
#address-cells = < 0x1 >;
#size-cells = < 0x0 >;
reg = < 0x40003000 0x1000 >;
interrupts = < 0x3 0x1 >;
status = "disabled";
label = "SPI_0";
compatible = "nordic,nrf-spi";
sck-pin = < 0x1b >;
mosi-pin = < 0x1a >;
miso-pin = < 0x1c >;
};
spi1: spi@40004000 {
#address-cells = < 0x1 >;
#size-cells = < 0x0 >;
reg = < 0x40004000 0x1000 >;
interrupts = < 0x4 0x1 >;
status = "okay";
label = "SPI_1";
compatible = "nordic,nrf-spi";
sck-pin = < 0x1f >;
mosi-pin = < 0x1e >;
miso-pin = < 0x1d >;
};
spi2: arduino_spi: spi@40023000 {
#address-cells = < 0x1 >;
#size-cells = < 0x0 >;
reg = < 0x40023000 0x1000 >;
interrupts = < 0x23 0x1 >;
status = "okay";
label = "SPI_2";
compatible = "nordic,nrf-spi";
sck-pin = < 0x19 >;
mosi-pin = < 0x17 >;
miso-pin = < 0x18 >;
cs-gpios = < &arduino_header 0x10 0x1 >;
};
And as the API description states: "If there are multiple, this returns an arbitrary one." I recommend you using this function instead.
Regards,
Markus
Hello,
DEVICE_DT_GET_ANY has the devicetree compatible as input arugment. You are using a subnode label.
So in case of nrf52dk_nrf52832 this would be:
compatible = "nordic,nrf-spi";
But using this function is probably not a good idea since you have several SPI peripherals with the same compatibale avialable.
spi0: spi@40003000 {
#address-cells = < 0x1 >;
#size-cells = < 0x0 >;
reg = < 0x40003000 0x1000 >;
interrupts = < 0x3 0x1 >;
status = "disabled";
label = "SPI_0";
compatible = "nordic,nrf-spi";
sck-pin = < 0x1b >;
mosi-pin = < 0x1a >;
miso-pin = < 0x1c >;
};
spi1: spi@40004000 {
#address-cells = < 0x1 >;
#size-cells = < 0x0 >;
reg = < 0x40004000 0x1000 >;
interrupts = < 0x4 0x1 >;
status = "okay";
label = "SPI_1";
compatible = "nordic,nrf-spi";
sck-pin = < 0x1f >;
mosi-pin = < 0x1e >;
miso-pin = < 0x1d >;
};
spi2: arduino_spi: spi@40023000 {
#address-cells = < 0x1 >;
#size-cells = < 0x0 >;
reg = < 0x40023000 0x1000 >;
interrupts = < 0x23 0x1 >;
status = "okay";
label = "SPI_2";
compatible = "nordic,nrf-spi";
sck-pin = < 0x19 >;
mosi-pin = < 0x17 >;
miso-pin = < 0x18 >;
cs-gpios = < &arduino_header 0x10 0x1 >;
};
And as the API description states: "If there are multiple, this returns an arbitrary one." I recommend you using this function instead.
Regards,
Markus
Hi Markus,
Hi Markus,
thanks for your help, but still i can't understand how to open the SPI2, using the functions you suggest. An example is available that uses these functions.
Thanks in advance.
Fausto