I am working with someone else's code, and I have a question about several of the SPI transactions that are performed. The hardware configuration consists of a Raspberry Pi (master) and a motor driver board (slave). They are using the spidev
Python library. The code to initialize and configure the SPI connection proceeds as follows:
import spidev
bus = 0 # SPI bus (channel 0 for Pi)
device = 0 # Device / chip select
spi = spidev.SpiDev() # Enable SPI
spi.open(bus,device) # Open connection on bus to device
# Set SPI speed and mode
spi.max_speed_hz = SPI_freq
spi.mode = 1
Then, they use xfer2()
to perform the SPI transactions.
spi.xfer2((0x28, 0x00, 0x01)) #0x280001
spi.xfer2((0x38, 0x00, 0x01)) #0x380001
spi.xfer2((0x20, 0x00, 0x0F)) #0x20000F
spi.xfer2((0x30, 0x00, 0x00)) #0x300000
My question is this: 1.) What is actually happening in this SPI transaction? and 2.) What is the purpose of splitting, say, 0x280001
into a tuple of three, like (0x28, 0x00, 0x01)
?