Skip to main content

SpiControllerSoftwareProvider Class

Namespace: GHIElectronics.TinyCLR.Devices.Spi.Provider · Assembly: GHIElectronics.TinyCLR.Devices.Spi

Software (bit-bang) SPI provider. Useful when no hardware SPI peripheral is available on the desired pins, or to escape pin-mux conflicts. Significantly slower than the native hardware provider.

public sealed class SpiControllerSoftwareProvider : ISpiControllerProvider

Constructors

SpiControllerSoftwareProvider(int mosiPinNumber, int misoPinNumber, int sckPinNumber)

public SpiControllerSoftwareProvider(int mosiPinNumber, int misoPinNumber, int sckPinNumber) : this(GpioController.GetDefault(), mosiPinNumber, misoPinNumber, sckPinNumber)

Builds a software SPI provider on the default GpioController.

ParameterTypeDescription
mosiPinNumberintPin used as MOSI (controller output).
misoPinNumberintPin used as MISO (controller input).
sckPinNumberintPin used as SCK (clock).

SpiControllerSoftwareProvider(GpioController gpioController, int mosiPinNumber, int misoPinNumber, int sckPinNumber)

public SpiControllerSoftwareProvider(GpioController gpioController, int mosiPinNumber, int misoPinNumber, int sckPinNumber)

Builds a software SPI provider on the supplied GpioController.

ParameterTypeDescription
gpioControllerGpioControllerThe GPIO controller that owns the bus pins.
mosiPinNumberintPin used as MOSI.
misoPinNumberintPin used as MISO.
sckPinNumberintPin used as SCK.

Properties

ChipSelectLineCount

public int ChipSelectLineCount { get; }

Number of hardware chip-select lines exposed by this controller. (inherited)

MinClockFrequency

public int MinClockFrequency { get; }

Minimum SCK frequency in Hz. (inherited)

MaxClockFrequency

public int MaxClockFrequency { get; }

Maximum SCK frequency in Hz. (inherited)

SupportedDataBitLengths

public int[] SupportedDataBitLengths { get; }

Supported frame widths in bits. (inherited)

Methods

Dispose()

public void Dispose()

Releases the GPIO pins held for MOSI/MISO/SCK/CS.

SetActiveSettings(SpiConnectionSettings connectionSettings)

public void SetActiveSettings(SpiConnectionSettings connectionSettings)

Applies a complete set of serial settings (baud, framing, handshake, polarity). (inherited)

ParameterTypeDescription
connectionSettingsSpiConnectionSettings

WriteRead(byte[] writeBuffer, int writeOffset, int writeLength, byte[] readBuffer, int readOffset, int readLength, bool deselectAfter)

public void WriteRead(byte[] writeBuffer, int writeOffset, int writeLength, byte[] readBuffer, int readOffset, int readLength, bool deselectAfter)

Performs a full-duplex transfer. (inherited)

ParameterTypeDescription
writeBufferbyte[]Bytes to transmit, or null for read-only.
writeOffsetintStarting offset within writeBuffer.
writeLengthintNumber of bytes to transmit.
readBufferbyte[]Destination buffer for received bytes, or null to discard.
readOffsetintStarting offset within readBuffer.
readLengthintNumber of bytes to receive.
deselectAfterboolIf false, leaves chip-select asserted after the transfer (for sequential read-after-write).

Write(byte[] writeBuffer, int xOffset, int yOffset, int width, int height, int originalWidth, int columnMultiplier, int rowMultiplier)

public void Write(byte[] writeBuffer, int xOffset, int yOffset, int width, int height, int originalWidth, int columnMultiplier, int rowMultiplier)

Writes a rectangular framebuffer region with optional pixel replication. (inherited)

ParameterTypeDescription
writeBufferbyte[]
xOffsetint
yOffsetint
widthint
heightint
originalWidthint
columnMultiplierint
rowMultiplierint