0

I have a Waveshare Can/RS485 Hat on my Pi. The Hat uses SPI0 with CS0 going to the CAN side. CS1 goes to the RS485 side.

I have a new device that uses SPI also. As I explore the sample code, initializing the bus uses the following code:

spi=busio.SPI(board.SCK, MOSI=board.MOSI, MISO=board.MISO) cs=digitalio.DigitalInOut(board.D5)

How do I get the initialization to look at SPI1 rather than SPI0?

I would think that there would be some parameter that specifies SPI0 or SPI1 in the initialization.

Any thoughts?

1
  • Hi and welcome! Can you edit your post to include a link to the sample code/documentation?
    – David
    Jan 6 at 8:57
1

Which SPI bus is selected is defined by the line :

spi=busio.SPI(board.SCK, MOSI=board.MOSI, MISO=board.MISO)

The board module specifies which pins are used by the pi. if you type "dir(board)" in the python terminal after importing board, it shows you the available pins. You can see pins SCLK_1, MOSI_1 and MISO_1 defined in the function. Replace the ones in your function with those.

2
  • Adi... I have been doing a bunch of reading from various source to no end. Thanks for the reply. I have changed the "spi= line" to have the SPI1 pins (ie: board.SCLK_1, board.MOSI_1, and board.MISO_1. My chip select is set to D5. Still no joy. Jan 12 at 21:10
  • Adding to the comment above: I am running the Waveshare CAN Hat on SPI0. When the overlay is used, the spidev0.1 does not exist. spidev0.1 as well as any spidev1.0, 1.1, or 1.2 all are shown. When I connect my new board (max31865 RTD Amp), and wire it into spi1.0, I get "OSError: [Errno 22] Invalid argument within an Adafruit_PureIO/spi.py file. It seems like the max31865 only works on spi0.0 Jan 12 at 21:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.