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.
| Parameter | Type | Description |
|---|---|---|
mosiPinNumber | int | Pin used as MOSI (controller output). |
misoPinNumber | int | Pin used as MISO (controller input). |
sckPinNumber | int | Pin 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.
| Parameter | Type | Description |
|---|---|---|
gpioController | GpioController | The GPIO controller that owns the bus pins. |
mosiPinNumber | int | Pin used as MOSI. |
misoPinNumber | int | Pin used as MISO. |
sckPinNumber | int | Pin 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)
| Parameter | Type | Description |
|---|---|---|
connectionSettings | SpiConnectionSettings |
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)
| Parameter | Type | Description |
|---|---|---|
writeBuffer | byte[] | Bytes to transmit, or null for read-only. |
writeOffset | int | Starting offset within writeBuffer. |
writeLength | int | Number of bytes to transmit. |
readBuffer | byte[] | Destination buffer for received bytes, or null to discard. |
readOffset | int | Starting offset within readBuffer. |
readLength | int | Number of bytes to receive. |
deselectAfter | bool | If 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)
| Parameter | Type | Description |
|---|---|---|
writeBuffer | byte[] | |
xOffset | int | |
yOffset | int | |
width | int | |
height | int | |
originalWidth | int | |
columnMultiplier | int | |
rowMultiplier | int |