Multiple devices using board.SPI

CircuitPython on hardware including Adafruit's boards, and CircuitPython libraries using Blinka on host computers.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
willipe53
 
Posts: 4
Joined: Mon Nov 16, 2020 5:14 pm

Multiple devices using board.SPI

Post by willipe53 »

Is there any way to use multiple SPI devices when using board.SPI? e.g.:

Code: Select all

disp_spi = board.SPI(0) #or maybe board.SPI((0,0)) which would address /dev/spidev0.0
led_spi = board.SPI(1) #or maybe board.SPI((0,1)) which would address /dev/spidev0.1
I have an SPI display connected to CE0 and a MAX7219 IC connected to CE1. For the display, I'm using adafruit_rgb_display which seems to use Adafruit_PureIO behind the scenes. For the MAX7219, I wish to communicate directly over SPI, e.g.:

Code: Select all

led_spi.writebytes((1,0b0000010))
Before I switch to spidev or something else and learn that, was hoping there was a simple way to set up two references in Python using board.SPI so that I can avoid unwinding adafruit_rgb_display and replacing it with something more primitive.

User avatar
dastels
 
Posts: 15667
Joined: Tue Oct 20, 2015 3:22 pm

Re: Multiple devices using board.SPI

Post by dastels »

Do you need multiple SPI busses? SPI is a bus that can connect to multiple devices. Each device has to have a dedicated select signal. Be careful in that some devices assume they are the only on on the bus. I know of one display chip that is like that. It's mentioned in the tutorial guide though along with to deal with it.

That said, most MCUs can support multiple SPI busses. How depends on the MCU.

Dave

Locked
Please be positive and constructive with your questions and comments.

Return to “Adafruit CircuitPython”