Hi Terry,

> >     OLED_RST_PIN = 25
> >     OLED_DC_PIN  = 24
> >     OLED_CS_PIN  = 8
>
> It's the OLED_CS_PIN (and possibly the OLED_DC_PIN) that I will
> probably want to manage.

I'd assume reset and data/command are gated as inputs to each SPI device
on the bus by the chip-select line so D/C doesn't need switching to each
device, just CS.  But I'd examine the data-sheet of the SPI device in
question to seek confirmation.

> I had misunderstood that when I looked at this previously and assumed that 
> SPI0 and SPI1 on the Pi GPIO Pins referred to two discrete buses which could 
> then have 1 to n devices attached and selected by the CS lines.
>
> I can see that I can obviously have two devices attached, based on the above, 
> but more than two might mean a bit more hoop-jumping, assuming it's available 
> at all.

https://www.raspberrypi.org/documentation/hardware/raspberrypi/spi/README.md
says

    The Raspberry Pi is equipped with one SPI bus that has 2 chip
    selects.

so I'm assuming there's not another SPI bus which isn't normally enabled
or allocated pins.

But that seems to contradict with https://pinout.xyz/pinout/spi which
shows

    SPI0: SCLK MOSI MISO CE0 CE1
    SPI1: SCLK MOSI MISO CE0 CE1 CE2

as if there's two buses with three chip-select lines on the second one.
Perhaps I'm misunderstanding the diagram.

Could you demux outputs from the Pi to give more chip-selects lines,
e.g. four GPIOs could drive one of 2⁴=16 CS lines.
https://en.wikipedia.org/wiki/Demux#Digital_demultiplexers

It's the demux's outputs which fan off as CS to each SPI device.
Meanwhile, they all get SCLK, MOSI, RST and D/C straight from the Pi.
You could leave the software thinking there was only one SPI device and
drive the demuxer yourself just before each run of SPI-writing for a
device.  If they were different speed devices then you'd have to change
the bus speed too.

No idea if it would work.  This is a hardware problem.  :-)

It seems it is possible.
https://forum.pjrc.com/threads/34666-16-SPI-devices-Is-it-possible
An I²C port expander to drive 16 CS is an alternative to the 4-to-16
demux.

-- 
Cheers, Ralph.

-- 
  Next meeting: Online, Jitsi, Tuesday, 2020-09-01 20:00
  Check to whom you are replying
  Meetings, mailing list, IRC, ...  http://dorset.lug.org.uk
  New thread, don't hijack:  mailto:dorset@mailman.lug.org.uk

Reply via email to