Class daisy::UartHandler¶
ClassList > daisy > UartHandler
#include <uart.h>
Classes¶
Type | Name |
---|---|
struct | Config |
Public Types¶
Type | Name |
---|---|
typedef void(* | CircularRxCallbackFunctionPtr |
enum | DmaDirection |
typedef void(* | EndCallbackFunctionPtr |
enum | Result |
typedef void(* | StartCallbackFunctionPtr |
Public Functions¶
Detailed Description¶
Uart Peripheral
Author:
shensley
Date:
March 2020
Public Types Documentation¶
typedef CircularRxCallbackFunctionPtr¶
typedef void(* daisy::UartHandler::CircularRxCallbackFunctionPtr) (uint8_t *data, size_t size, void *context, Result result);
A callback to be executed when using circular/listening mode includes a callback context, as well as the data to be handled This fires either after half of the size of the user-defined buffer has been transferred from peripheral to memory, or after an IDLE frame is detected.
Parameters:
data
byte-buffer to fill with datasize
size of the "data" byte buffercontext
user-defined context variable to pass state to the callbackresult
state of the UART Handler result, should be OK if things are OK.
enum DmaDirection¶
typedef EndCallbackFunctionPtr¶
A callback to be executed after a standard dma transfer is completed.
enum Result¶
Return values for Uart functions.
typedef StartCallbackFunctionPtr¶
A callback to be executed right before a standard dma transfer is started.
Public Functions Documentation¶
function BlockingReceive¶
Result daisy::UartHandler::BlockingReceive (
uint8_t * buffer,
uint16_t size,
uint32_t timeout=100
)
Polling Receive
Parameters:
buffer
input buffersize
buffer sizetimeout
How long to timeout for in milliseconds
Returns:
Whether the receive was successful or not
function BlockingTransmit¶
Blocking transmit
Parameters:
buff
input buffersize
buffer sizetimeout
how long in milliseconds the function will wait before returning without successful communication
function CheckError¶
Returns:
the result of HAL_UART_GetError() to the user.
function DmaListenStart¶
Result daisy::UartHandler::DmaListenStart (
uint8_t * buff,
size_t size,
CircularRxCallbackFunctionPtr cb,
void * callback_context
)
Starts the DMA Reception in "Listen" mode. In this mode the DMA is configured for circular behavior, and the IDLE interrupt is enabled.
At TC, HT, and IDLE interrupts data must be processed.
Size must be set so that at maximum bandwidth, the software has time to process N bytes before the next circular IRQ is fired
Parameters:
buff
buffer of data accessible by DMA.size
size of buffercb
callback that happens containing new bytes to process in softwarecallback_context
pointer to user-defined data accessible from callback
function DmaListenStop¶
Stops the DMA Reception during listen mode
function DmaReceive¶
Result daisy::UartHandler::DmaReceive (
uint8_t * buff,
size_t size,
UartHandler::StartCallbackFunctionPtr start_callback,
UartHandler::EndCallbackFunctionPtr end_callback,
void * callback_context
)
DMA-based receive
Parameters:
*buff
input buffersize
buffer sizestart_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.
Returns:
Whether the receive was successful or not
function DmaTransmit¶
Result daisy::UartHandler::DmaTransmit (
uint8_t * buff,
size_t size,
UartHandler::StartCallbackFunctionPtr start_callback,
UartHandler::EndCallbackFunctionPtr end_callback,
void * callback_context
)
DMA-based transmit
Parameters:
*buff
input buffersize
buffer sizestart_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.
Returns:
Whether the transmit was successful or not
function GetConfig¶
Returns the current config.
function Init¶
Initializes the UART Peripheral
function IsListening¶
Returns whether listen the DmaListen mode is active or not
function PollReceive¶
Will be deprecated soon! Wrapper for BlockingTransmit
function PollTx¶
Will be deprecated soon! Wrapper for BlockingTransmit
function UartHandler [½]¶
function UartHandler [2/2]¶
function operator=¶
The documentation for this class was generated from the following file external-docs/libDaisy/src/per/uart.h