|
Treehopper C# API
|
Represents a peripheral attached to the SPI bus More...
Public Member Functions | |
| SpiDevice (Spi spiModule, SpiChipSelectPin chipSelect, ChipSelectMode chipSelectMode=ChipSelectMode.SpiActiveLow, double speedMhz=6, SpiMode mode=SpiMode.Mode00) | |
| Construct an SPI device attached to a particular module More... | |
| Task< byte[]> | SendReceiveAsync (byte[] dataToSend, SpiBurstMode burst=SpiBurstMode.NoBurst) |
| Start an SPI transaction More... | |
Properties | |
| SpiChipSelectPin | ChipSelect [get, protected set] |
| Get or set the pin to use for chip-select duties. More... | |
| SpiMode | Mode [get, protected set] |
| Get or set the SPI module's mode More... | |
| double | Frequency [get, set] |
| Gets or sets the Frequency, in MHz, that this device will use for SPI communication. More... | |
| ChipSelectMode | ChipSelectMode [get, protected set] |
| The chip select mode to use with transactions More... | |
Represents a peripheral attached to the SPI bus
| SpiDevice | ( | Spi | spiModule, |
| SpiChipSelectPin | chipSelect, | ||
| ChipSelectMode | chipSelectMode = ChipSelectMode.SpiActiveLow, |
||
| double | speedMhz = 6, |
||
| SpiMode | mode = SpiMode.Mode00 |
||
| ) |
Construct an SPI device attached to a particular module
| spiModule | The module this device is attached to |
| chipSelect | The chip select pin used by this device |
| chipSelectMode | The ChipSelectMode to use with this device |
| speedMhz | The speed to operate this device at |
| mode | The SpiMode of this device |
| Task<byte[]> SendReceiveAsync | ( | byte [] | dataToSend, |
| SpiBurstMode | burst = SpiBurstMode.NoBurst |
||
| ) |
Start an SPI transaction
| dataToSend | The data to send |
| burst | The burst mode, if any, to use |
|
getprotected set |
Get or set the pin to use for chip-select duties.
Almost every SPI peripheral chip has some sort of chip select (which may be called load, strobe, or enable, depending on the type of chip). You can use any Pin for chip-select duties as long as it belongs to the same board as this SPI peripheral (i.e., you can't use a pin from one Treehopper as a chip-select for the SPI port on another Treehopper). Chip-selects are controlled at the firmware, not peripheral, level, which offers quite a bit of flexibility in choosing the behavior. Make sure to set ChipSelectMode properly for your device.
|
getprotected set |
Get or set the SPI module's mode
The SPI module supports the four SPI modes: 00, 01, 10, 11. See SpiMode for more info.
|
getset |
Gets or sets the Frequency, in MHz, that this device will use for SPI communication.
The SPI module can operate from 0.09375 MHz (93.75 kHz) to 24 MHz. Setting Frequency outside of those limits will result in clipping, plus a debug notice. Note that SPI transfers are managed by the CPU, as Treehopper's MCU has no DMA. As a result, there are diminishing performance returns above 8 MHz, as dead space starts appearing between bytes as the SPI module waits for the CPU to push the next byte into the register.
|
getprotected set |
The chip select mode to use with transactions