python – Raspberry pi: How to use custom chip select with spidev without interfering with the default CE pins
I currently have a board attached to my raspberrypi with 2 spi devices on it. I looked at the source code of the library of this board found at: github.com/abelectronicsuk/ABElectronics_Python_Libraries/blob/master/ADCDACPi/ADCDACPi.py
The two devices use:
spiADC.open(0,0)
and
spiDAC.open(0,1)
I am adding a third spi device (call it INA). I have used GPIO 23 as the CS pin for that. But to use functions like xfer2 I need to use INA.open, otherwise I get errors.
I attempted INA.open(0,2) but got the error:
FileNotFoundError: [Errno 2] No such file or directory
I have only seen examples with spidev.open(0,0) and spidev(0,1), so I don’t know if there is a limit. I attempted to use INA.open(0,0) and INA.no_cs hoping this would not interfere with spiADC. But as expected it did.
I have pulled GPIO23, which I was using as the CS line for the INA, low manually and then attempted xfer2 with INA:
INA_cs_line.set_value(0)
rec = INA.xfer2(sendTX)
INA_cs_line.set_value(1)
I have verified with the oscilloscope that when using INA.xfer2 also the CS line of spiADC is pulled low as it is also at (0,0).
Hence my question, how do I open an spidev connection with a specified a custom specified pin as CS. Or, if I pull the CS low for the third chip manually, how do I use INA.xfer2 (which it seems requires INA.open), without it interfering with the other SPI device’s CS line.
Read more here: Source link