Skip to main content

Class SpiBus

Represents an SPI communication bus for communicating to peripherals that implement the SPI protocol.

Assembly: Meadow.F7.dll​
View Source​
Declaration
public class SpiBus : ISpiBus

Implements:
Meadow.Hardware.ISpiBus

Properties​

Configuration​

Configuration to use for this instance of the SPIBus.

View Source​
Declaration
public SpiClockConfiguration Configuration { get; }

SupportedSpeeds​

Gets an array of all of the speeds that the SPI bus supports.

View Source​
Declaration
public Frequency[] SupportedSpeeds { get; }

Methods​

Read(IDigitalOutputPort?, Span<byte>, ChipSelectMode)​

Reads data from the SPI bus into the buffer.

View Source​
Declaration
public void Read(IDigitalOutputPort? chipSelect, Span<byte> readBuffer, ChipSelectMode csMode = ChipSelectMode.ActiveLow)
Parameters​
TypeNameDescription
Meadow.Hardware.IDigitalOutputPortchipSelectPort to use as the chip select to activate the bus.
System.Span<System.Byte>readBufferData to write
Meadow.Hardware.ChipSelectModecsModeDescribes which level on the chip select activates the peripheral.

Write(IDigitalOutputPort?, Span<byte>, ChipSelectMode)​

Writes data to the SPI bus

View Source​
Declaration
public void Write(IDigitalOutputPort? chipSelect, Span<byte> writeBuffer, ChipSelectMode csMode = ChipSelectMode.ActiveLow)
Parameters​
TypeNameDescription
Meadow.Hardware.IDigitalOutputPortchipSelectIPin to use as the chip select to activate the bus
System.Span<System.Byte>writeBufferData to write
Meadow.Hardware.ChipSelectModecsModeDescribes which level on the chip select activates the bus

Exchange(IDigitalOutputPort?, Span<byte>, Span<byte>, ChipSelectMode)​

Writes data from the write buffer to a peripheral on the bus while at the same time reading return data into the read buffer.

View Source​
Declaration
public void Exchange(IDigitalOutputPort? chipSelect, Span<byte> writeBuffer, Span<byte> readBuffer, ChipSelectMode csMode = ChipSelectMode.ActiveLow)
Parameters​
TypeNameDescription
Meadow.Hardware.IDigitalOutputPortchipSelectPort to use as the chip select to activate the peripheral.
System.Span<System.Byte>writeBufferBuffer to read data from.
System.Span<System.Byte>readBufferBuffer to read returning data into.
Meadow.Hardware.ChipSelectModecsModeDescribes which level on the chip select activates the peripheral.

Implements​