Handler for serial peripheral interface
#include <spi.h>
Classes | |
| struct | Config |
Public Types | |
| enum class | Result { OK , ERR } |
| enum class | DmaDirection { RX , TX , RX_TX } |
| typedef void(*) | StartCallbackFunctionPtr(void *context) |
| typedef void(*) | EndCallbackFunctionPtr(void *context, Result result) |
Public Member Functions | |
| SpiHandle () | |
| SpiHandle (const SpiHandle &other)=default | |
| SpiHandle & | operator= (const SpiHandle &other)=default |
| Result | Init (const Config &config) |
| const Config & | GetConfig () const |
| Result | BlockingTransmit (uint8_t *buff, size_t size, uint32_t timeout=100) |
| Result | BlockingReceive (uint8_t *buffer, uint16_t size, uint32_t timeout) |
| Result | BlockingTransmitAndReceive (uint8_t *tx_buff, uint8_t *rx_buff, size_t size, uint32_t timeout=100) |
| Result | DmaTransmit (uint8_t *buff, size_t size, SpiHandle::StartCallbackFunctionPtr start_callback, SpiHandle::EndCallbackFunctionPtr end_callback, void *callback_context) |
| Result | DmaReceive (uint8_t *buff, size_t size, SpiHandle::StartCallbackFunctionPtr start_callback, SpiHandle::EndCallbackFunctionPtr end_callback, void *callback_context) |
| Result | DmaTransmitAndReceive (uint8_t *tx_buff, uint8_t *rx_buff, size_t size, SpiHandle::StartCallbackFunctionPtr start_callback, SpiHandle::EndCallbackFunctionPtr end_callback, void *callback_context) |
| int | CheckError () |
| void(*) daisy::SpiHandle::EndCallbackFunctionPtr(void *context, Result result) |
A callback to be executed after a dma transfer is completed.
| void(*) daisy::SpiHandle::StartCallbackFunctionPtr(void *context) |
A callback to be executed right before a dma transfer is started.
|
strong |
|
strong |
|
inline |
|
default |
| Result daisy::SpiHandle::BlockingReceive | ( | uint8_t * | buffer, |
| uint16_t | size, | ||
| uint32_t | timeout ) |
Polling Receive
| buffer | input buffer |
| size | buffer size |
| timeout | How long to timeout for in milliseconds |
| Result daisy::SpiHandle::BlockingTransmit | ( | uint8_t * | buff, |
| size_t | size, | ||
| uint32_t | timeout = 100 ) |
Blocking transmit
| buff | input buffer |
| size | buffer size |
| timeout | how long in milliseconds the function will wait before returning without successful communication |
| Result daisy::SpiHandle::BlockingTransmitAndReceive | ( | uint8_t * | tx_buff, |
| uint8_t * | rx_buff, | ||
| size_t | size, | ||
| uint32_t | timeout = 100 ) |
Blocking transmit and receive
| tx_buff | the transmit buffer |
| rx_buff | the receive buffer |
| size | the length of the transaction |
| timeout | how long in milliseconds the function will wait before returning without successful communication |
| int daisy::SpiHandle::CheckError | ( | ) |
| Result daisy::SpiHandle::DmaReceive | ( | uint8_t * | buff, |
| size_t | size, | ||
| SpiHandle::StartCallbackFunctionPtr | start_callback, | ||
| SpiHandle::EndCallbackFunctionPtr | end_callback, | ||
| void * | callback_context ) |
DMA-based receive
| *buff | input buffer |
| size | buffer size |
| start_callback | A callback to execute when the transfer starts, or NULL. The callback is called from an interrupt, so keep it fast. |
| end_callback | A callback to execute when the transfer finishes, or NULL. The callback is called from an interrupt, so keep it fast. |
| callback_context | A pointer that will be passed back to you in the callbacks. |
| Result daisy::SpiHandle::DmaTransmit | ( | uint8_t * | buff, |
| size_t | size, | ||
| SpiHandle::StartCallbackFunctionPtr | start_callback, | ||
| SpiHandle::EndCallbackFunctionPtr | end_callback, | ||
| void * | callback_context ) |
DMA-based transmit
| *buff | input buffer |
| size | buffer size |
| start_callback | A callback to execute when the transfer starts, or NULL. The callback is called from an interrupt, so keep it fast. |
| end_callback | A callback to execute when the transfer finishes, or NULL. The callback is called from an interrupt, so keep it fast. |
| callback_context | A pointer that will be passed back to you in the callbacks. |
| Result daisy::SpiHandle::DmaTransmitAndReceive | ( | 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
| 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. The callback is called from an interrupt, so keep it fast. |
| end_callback | A callback to execute when the transfer finishes, or NULL. The callback is called from an interrupt, so keep it fast. |
| callback_context | A pointer that will be passed back to you in the callbacks. |
| const Config & daisy::SpiHandle::GetConfig | ( | ) | const |
Returns the current config.