Handler for a serial peripheral interface that connects to multiple devices on one bus such that up to 4 devices can share the same MOSI, MISO and SCLK pins. Each device has its own NSS/CS pin which is software driven by the MultiSlaveSpiHandle.
#include <spiMultislave.h>
Classes | |
| struct | Config |
Public Member Functions | |
| MultiSlaveSpiHandle () | |
| MultiSlaveSpiHandle (const MultiSlaveSpiHandle &other)=delete | |
| SpiHandle::Result | Init (const Config &config) |
| const Config & | GetConfig () const |
| SpiHandle::Result | BlockingTransmit (size_t device_index, uint8_t *buff, size_t size, uint32_t timeout=100) |
| SpiHandle::Result | BlockingReceive (size_t device_index, uint8_t *buff, uint16_t size, uint32_t timeout=100) |
| SpiHandle::Result | BlockingTransmitAndReceive (size_t device_index, uint8_t *tx_buff, uint8_t *rx_buff, size_t size, uint32_t timeout=100) |
| SpiHandle::Result | DmaTransmit (size_t device_index, uint8_t *buff, size_t size, SpiHandle::StartCallbackFunctionPtr start_callback, SpiHandle::EndCallbackFunctionPtr end_callback, void *callback_context) |
| SpiHandle::Result | DmaReceive (size_t device_index, uint8_t *buff, size_t size, SpiHandle::StartCallbackFunctionPtr start_callback, SpiHandle::EndCallbackFunctionPtr end_callback, void *callback_context) |
| SpiHandle::Result | DmaTransmitAndReceive (size_t device_index, uint8_t *tx_buff, uint8_t *rx_buff, size_t size, SpiHandle::StartCallbackFunctionPtr start_callback, SpiHandle::EndCallbackFunctionPtr end_callback, void *callback_context) |
| int | CheckError () |
Static Public Attributes | |
| static constexpr size_t | max_num_devices_ = 4 |
|
inline |
|
delete |
| SpiHandle::Result daisy::MultiSlaveSpiHandle::BlockingReceive | ( | size_t | device_index, |
| uint8_t * | buff, | ||
| uint16_t | size, | ||
| uint32_t | timeout = 100 ) |
Polling Receive
| device_index | the index of the device |
| buff | input buffer |
| size | buffer size |
| timeout | timeout time in ms |
| SpiHandle::Result daisy::MultiSlaveSpiHandle::BlockingTransmit | ( | size_t | device_index, |
| uint8_t * | buff, | ||
| size_t | size, | ||
| uint32_t | timeout = 100 ) |
Blocking transmit
| device_index | the index of the device |
| buff | input buffer |
| size | buffer size |
| timeout | timeout time in ms |
| SpiHandle::Result daisy::MultiSlaveSpiHandle::BlockingTransmitAndReceive | ( | size_t | device_index, |
| uint8_t * | tx_buff, | ||
| uint8_t * | rx_buff, | ||
| size_t | size, | ||
| uint32_t | timeout = 100 ) |
Blocking transmit and receive
| device_index | the index of the device |
| tx_buff | the transmit buffer |
| rx_buff | the receive buffer |
| size | the length of the transaction |
| timeout | timeout time in ms |
| int daisy::MultiSlaveSpiHandle::CheckError | ( | ) |
| SpiHandle::Result daisy::MultiSlaveSpiHandle::DmaReceive | ( | size_t | device_index, |
| uint8_t * | buff, | ||
| size_t | size, | ||
| SpiHandle::StartCallbackFunctionPtr | start_callback, | ||
| SpiHandle::EndCallbackFunctionPtr | end_callback, | ||
| void * | callback_context ) |
DMA-based receive
| device_index | the index of the device |
| buff | receive buffer |
| size | buffer size |
| start_callback | A callback to execute when the transfer starts, or NULL. |
| end_callback | A callback to execute when the transfer finishes, or NULL. |
| callback_context | A pointer that will be passed back to you in the callbacks. |
| SpiHandle::Result daisy::MultiSlaveSpiHandle::DmaTransmit | ( | size_t | device_index, |
| uint8_t * | buff, | ||
| size_t | size, | ||
| SpiHandle::StartCallbackFunctionPtr | start_callback, | ||
| SpiHandle::EndCallbackFunctionPtr | end_callback, | ||
| void * | callback_context ) |
DMA-based transmit
| device_index | the index of the device |
| buff | transmit buffer |
| size | buffer size |
| start_callback | A callback to execute when the transfer starts, or NULL. |
| end_callback | A callback to execute when the transfer finishes, or NULL. |
| callback_context | A pointer that will be passed back to you in the callbacks. |
| SpiHandle::Result daisy::MultiSlaveSpiHandle::DmaTransmitAndReceive | ( | size_t | device_index, |
| uint8_t * | tx_buff, | ||
| uint8_t * | rx_buff, | ||
| size_t | size, | ||
| SpiHandle::StartCallbackFunctionPtr | start_callback, | ||
| SpiHandle::EndCallbackFunctionPtr | end_callback, | ||
| void * | callback_context ) |
DMA-based transmit and receive
| device_index | the index of the device |
| tx_buff | the transmit buffer |
| rx_buff | the receive buffer |
| size | buffer size |
| start_callback | A callback to execute when the transfer starts, or NULL. |
| end_callback | A callback to execute when the transfer finishes, or NULL. |
| callback_context | A pointer that will be passed back to you in the callbacks. |
|
inline |
Returns the current config.
| SpiHandle::Result daisy::MultiSlaveSpiHandle::Init | ( | const Config & | config | ) |
Initializes handler
|
staticconstexpr |