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
asked Mar 29, 2020 at 16:55
1
  • What are you trying to connect using spi? Commented Mar 29, 2020 at 17:31

1 Answer 1

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.

answered Mar 29, 2020 at 17:12

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.