- class wpilib.SPI(port)¶
Represents a SPI bus port
Parameters: port – the physical SPI port
- class Port¶
- kMXP = 4¶
- kOnboardCS0 = 0¶
- kOnboardCS1 = 1¶
- kOnboardCS2 = 2¶
- kOnboardCS3 = 3¶
- SPI.devices = 0¶
- SPI.read(initiate, size)¶
Read a word from the receive FIFO.
Waits for the current transfer to complete if the receive FIFO is empty.
If the receive FIFO is empty, there is no active transfer, and initiate is False, errors.
- initiate – If True, this function pushes “0” into the transmit buffer and initiates a transfer. If False, this function assumes that data is already in the receive FIFO from a previous write.
- size – Number of bytes to read.
received data bytes
Configure the chip select line to be active high.
Configure the chip select line to be active low.
Configure the clock output line to be active high. This is sometimes called clock polarity low or clock idle low.
Configure the clock output line to be active low. This is sometimes called clock polarity high or clock idle high.
Configure the rate of the generated clock signal. The default value is 500,000 Hz. The maximum value is 4,000,000 Hz.
Parameters: hz – The clock rate in Hertz.
Configure the order that bits are sent and received on the wire to be least significant bit first.
Configure the order that bits are sent and received on the wire to be most significant bit first.
Configure that the data is stable on the falling edge and the data changes on the rising edge.
Configure that the data is stable on the rising edge and the data changes on the falling edge.
Perform a simultaneous read/write transaction with the device
Parameters: dataToSend – The data to be written out to the device Returns: data received from the device
Write data to the slave device. Blocks until there is space in the output FIFO.
If not running in output only mode, also saves the data received on the MISO input during the transfer into the receive FIFO.
Parameters: dataToSend – Data to send (bytes)