UPDATE: if at one point you need to use GPIO18 for something other then RF24L01 then you have to delete the spi-cs-extend.dtbo file from the /boot/overlays/ and then reboot.
puskyer
@puskyer
Best posts made by puskyer
Latest posts made by puskyer
-
RE: I got a plug-and-play NRF24 shield for the Pi on Aliexpress
-
RE: I got a plug-and-play NRF24 shield for the Pi on Aliexpress
Hello
Not sure if this will be helpfull, I have a module/breakout board that looks exactly the one above, but both the CE and CSN pins are different.
CE (3) my board = gpio21 = pin 13
should be = gpio17 = pin 11
CSN(4) my board = gpio18 = pin 12
should be = gpio8 = pin 24So I found info from the following link: link text
So it seem the raspberry pi SPIDEV0 by default has 2 CSN pins configured ( 7 and 8 ) and the SPI driver in the kernel uses GPIOS toggled by software, rather than hardware. So, this means that any GPIO can be used for CSN, and it can support more then two.
Also based on the link all of the setup for the SPI driver is defined in the device tree, and we can use device tree overlays stored in /boot to dynamically configure the device tree.
The following is my example spi-cs-extend.dts file to create SPIDEV with CSN pins, on GPIO 8, 7, 18. (18 is the GPIO for my RF24 breakout board)
To compile it to a binary I used the following command:
dtc -@ -I dts -O dtb -o spi-cs-extend.dtbo spi-cs-extend.dts
Then I placeed the new spi-cs-extend.dtbo into /boot/overlays/ and added the following line to the /boot/config.txt file.
dtoverlay=spi-cs-extend.
After rebooting, I had a /dev/spidev0.2 which now allows me to communicate with the RF24L01 breakout board.
my spi-cs-extend.dts file
/dts-v1/; /plugin/; / { compatible = "brcm,bcm2835"; fragment@0 { target = <&spi0_cs_pins>; frag0: __overlay__ { brcm,pins = <8 7 18>; }; }; fragment@1 { target = <&spi0>; frag1: __overlay__ { #address-cells = <1>; #size-cells = <0>; cs-gpios = <&gpio 8 1>, <&gpio 7 1>, <&gpio 18 1>; status = "okay"; spidev0_2: spidev@2 { compatible = "spidev"; reg = <2>; #address-cells = <1>; #size-cells = <0>; spi-max-frequency = <125000000>; }; }; }; };