1

I'm trying to program the SPI in Python but the documentation is terrible. SPI Docs

I found some sites that show how to get started but I need to know how to change modes, set clock polarity, and set clock idle state. I can't find anything on the internet that shows how to do this in Python. One site showed code for mode = 0, but what is mode 0?

Here is the code I have for setting it up.

# We only have SPI bus 0 available to us on the Pi
bus = 0
#Device is the chip select pin. Set to 0 or 1, depending on the connections
device = 0 #worked on 0 and 1
# Enable SPI
spi = spidev.SpiDev()
# Open a connection to a specific bus and device (chip select pin)
spi.open(bus, device)
# Set SPI speed and mode
spi.max_speed_hz = 500000
spi.mode = 1
  • What are you trying to connect using spi? – CoderMike Mar 29 at 17:31
1

The documentation you link is to the UART.

See https://pypi.org/project/spidev/ for the available spidev module documentation.

As for the meaning of mode perhaps look at a SPI wiki.

| improve this answer | |

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.