I'd like to connect multiple different SPI devices to a Raspberry Pi Zero W (at least 5), with a few specific requirements. The devices would be, if possible:
- 1x ENC28J60 Ethernet SPI adapter - this must be always available to receive telecommand
- 1x MicroSD adaptor
- 3-4x ADC ADS1248
As I understand, the Pi Zero has one main, and one auxiliary SPI interface, with 2 CS pins on the former and 3 on the latter.
Using device tree, I've attempted to configure and enable the interfaces for this, though it's still not working properly. I've done the following to enable the interfaces, using default pin-outs for the wiring:
dtparam=spi=on
dtoverlay=enc28j60
dtoverlay=spi1-3cs
In /dev/, I can then see spidev0.1, 1.1, 1.1, and 1.2 all visible - 0.0 is not visible but I presume this is being used for Ethernet. I have confirmed that all 5 CE pins are being pulled high by default.
Currently, the Ethernet and MicroSD adapters are on SPI0, with CE0 for ethernet and CE1 for MicroSD. The Ethernet adapter works perfectly, so good start there. I can't see or mount any SD card volume, though, and I've had trouble finding how to do so - does anyone know how to fix this and use the SD as redundant storage?
Additionally, is it even possible to maintain uninterrupted (or at least always contactable) Ethernet connection despite sharing a bus while possibility simultaneously writing to the SD card? Would the OS handle this, or is this a bad idea? The Ethernet adapter's interrupt pin is connected, if that helps.
For the ADCs, I was intending to have them all on SPI1 (or 2 here, and the SD card adapter if I can't share it with Ethernet on SPI0), using CE0, CE1, CE2, and DRDY pins as required by the datasheet. We are able to get these working individually currently using the busio Python library and board to provide an SPI interface handle on a separate Pi, but this does not work with the Ethernet adapter (I assume as board looks for spidev0.0 by default?). Either way, I would rather convert this to work with SPI1, or bit-banged separately if I really need (especially if we need >4 ADCs), either way using the pigpio Python library as I've previously used it to solve I2C issues with great success, and I would like to keep consistency across the platform and stick to one major library where possible to avoid any conflicts. Does this approach sound sensible, or am I making some flawed assumptions that means this cannot work?
Summary of key questions, as there's a fair bit of text:
- How do I use make the SD card available?
- Is it possible to share SPI0 with continuous Ethernet and intermittent SD card use?
- Is my described approach for the 3+ ADCs sound, or likely to cause major issues?
Thanks very much for any advice, it is greatly appreciated!