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) |
A callback to be executed after a dma transfer is completed.
A callback to be executed right before a dma transfer is started.
|
strong |
|
inline |
Polling Receive
buffer | input buffer |
size | buffer size |
timeout | How long to timeout for in milliseconds |
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. |