daisy::SpiHandle¶
Module: LIBDAISY / PERIPHERAL / SERIAL
#include <spi.h>
Public Classes¶
Name | |
---|---|
struct | Config |
Public Types¶
Name | |
---|---|
enum class | Result |
enum class | DmaDirection |
typedef void(*)(void *context) | StartCallbackFunctionPtr |
typedef void(*)(void *context, Result result) | EndCallbackFunctionPtr |
Public Functions¶
Name | |
---|---|
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() |
Detailed Description¶
Handler for serial peripheral interface
Public Types Documentation¶
enum Result¶
Enumerator | Value | Description |
---|---|---|
OK | & | |
ERR | & |
Return values for Spi functions.
enum DmaDirection¶
Enumerator | Value | Description |
---|---|---|
RX | & | |
TX | & | |
RX_TX | & |
typedef StartCallbackFunctionPtr¶
A callback to be executed right before a dma transfer is started.
typedef EndCallbackFunctionPtr¶
A callback to be executed after a dma transfer is completed.
Public Functions Documentation¶
function SpiHandle¶
function SpiHandle¶
function operator=¶
function Init¶
Initializes handler
function GetConfig¶
Returns the current config.
function BlockingTransmit¶
Parameters:
- buff input buffer
- size buffer size
- timeout how long in milliseconds the function will wait before returning without successful communication
Blocking transmit
function BlockingReceive¶
Parameters:
- buffer input buffer
- size buffer size
- timeout How long to timeout for in milliseconds
Return: Whether the receive was successful or not
Polling Receive
function BlockingTransmitAndReceive¶
Result BlockingTransmitAndReceive(
uint8_t * tx_buff,
uint8_t * rx_buff,
size_t size,
uint32_t timeout =100
)
Parameters:
- 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
Blocking transmit and receive
function DmaTransmit¶
Result DmaTransmit(
uint8_t * buff,
size_t size,
SpiHandle::StartCallbackFunctionPtr start_callback,
SpiHandle::EndCallbackFunctionPtr end_callback,
void * callback_context
)
Parameters:
- ***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.
Return: Whether the transmit was successful or not
DMA-based transmit
function DmaReceive¶
Result DmaReceive(
uint8_t * buff,
size_t size,
SpiHandle::StartCallbackFunctionPtr start_callback,
SpiHandle::EndCallbackFunctionPtr end_callback,
void * callback_context
)
Parameters:
- ***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.
Return: Whether the receive was successful or not
DMA-based receive
function DmaTransmitAndReceive¶
Result DmaTransmitAndReceive(
uint8_t * tx_buff,
uint8_t * rx_buff,
size_t size,
SpiHandle::StartCallbackFunctionPtr start_callback,
SpiHandle::EndCallbackFunctionPtr end_callback,
void * callback_context
)
Parameters:
- 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.
Return: Whether the receive was successful or not
DMA-based transmit and receive
function CheckError¶
Return: the result of HAL_SPI_GetError() to the user.
---¶
Updated on 2024-01-03 at 19:41:01 +0000