Closed biemster closed 1 year ago
It's on raspberry pi's pinout diagram:
Thanks @dernasherbrezon for your response, but I'm afraid you did not understand my question. I'm working on non-rpi hardware: a QCA9533 based wifi repeater. There are multiple devices on my SPI bus, so I have to set the correct CS line to get the sx1278 to listen to the SPI bus.
I can of course pull down the pin before I start using your code, but it would be nice if the code handles this itself? Or is the CS pin already configurable in your code, and I just could not find it yet?
Ah, I see. No sx127x doesn't deal with pins. It accepts only correctly configured spi device. Actually esp32 and linux correctly pull down CS line before transfer command and data. So you don't need to do anything specific.
When there is only one device on the bus right? If you have multiple, like in below figure:
one has to pull down the corresponding CS line of the device you want to talk to.
I understand this is not supported yet in your code, could you give me a pointer where to add this myself? (I'll probably go the /dev/gpiochip0
route)
This is supported by linux kernel. When it initialises "/dev/spidevX.X" it will map CS1 to "/dev/spidev0.0", CS2 to "/dev/spidev0.1" &etc. So when you use linux API:
#include <linux/gpio.h>
#include <linux/spi/spidev.h>
Linux kernel will control what application is using the controller and allow only sequential access to it. Then based on the accessed device, linux kernel will pull low corresponding CS line before transfer.
Ah, did not know that! Thanks for that info! So I guess I have to set which gpio I want to use as CS line in the DTS? Anyway thanks for clearing this up for me, I'll figure that out myself. Great project btw!
I have multiple devices on my SPI bus (on QCA9533), and need to assign a CS line to each. In the rpi example the code mentions spidev0.0 has this standard on GPIO8, where should I define the pin in my case? Or should I pull this pin up before running this code?