25 #include "uartdrv_config.h"
42 #define ECODE_EMDRV_UARTDRV_OK (ECODE_OK)
43 #define ECODE_EMDRV_UARTDRV_WAITING (ECODE_EMDRV_UARTDRV_BASE | 0x00000001)
44 #define ECODE_EMDRV_UARTDRV_ILLEGAL_HANDLE (ECODE_EMDRV_UARTDRV_BASE | 0x00000002)
45 #define ECODE_EMDRV_UARTDRV_PARAM_ERROR (ECODE_EMDRV_UARTDRV_BASE | 0x00000003)
46 #define ECODE_EMDRV_UARTDRV_BUSY (ECODE_EMDRV_UARTDRV_BASE | 0x00000004)
47 #define ECODE_EMDRV_UARTDRV_ILLEGAL_OPERATION (ECODE_EMDRV_UARTDRV_BASE | 0x00000005)
48 #define ECODE_EMDRV_UARTDRV_IDLE (ECODE_EMDRV_UARTDRV_BASE | 0x00000008)
49 #define ECODE_EMDRV_UARTDRV_ABORTED (ECODE_EMDRV_UARTDRV_BASE | 0x00000009)
50 #define ECODE_EMDRV_UARTDRV_QUEUE_FULL (ECODE_EMDRV_UARTDRV_BASE | 0x0000000A)
51 #define ECODE_EMDRV_UARTDRV_QUEUE_EMPTY (ECODE_EMDRV_UARTDRV_BASE | 0x0000000B)
52 #define ECODE_EMDRV_UARTDRV_PARITY_ERROR (ECODE_EMDRV_UARTDRV_BASE | 0x0000000C)
53 #define ECODE_EMDRV_UARTDRV_FRAME_ERROR (ECODE_EMDRV_UARTDRV_BASE | 0x0000000D)
54 #define ECODE_EMDRV_UARTDRV_DMA_ALLOC_ERROR (ECODE_EMDRV_UARTDRV_BASE | 0x0000000E)
55 #define ECODE_EMDRV_UARTDRV_CLOCK_ERROR (ECODE_EMDRV_UARTDRV_BASE | 0x0000000F)
58 #define UARTDRV_STATUS_RXEN (1 << 0)
59 #define UARTDRV_STATUS_TXEN (1 << 1)
60 #define UARTDRV_STATUS_RXBLOCK (1 << 3)
61 #define UARTDRV_STATUS_TXTRI (1 << 4)
62 #define UARTDRV_STATUS_TXC (1 << 5)
63 #define UARTDRV_STATUS_TXBL (1 << 6)
64 #define UARTDRV_STATUS_RXDATAV (1 << 7)
65 #define UARTDRV_STATUS_RXFULL (1 << 8)
66 #define UARTDRV_STATUS_TXIDLE (1 << 13)
98 typedef enum UARTDRV_UartType
100 uartdrvUartTypeUart = 0,
101 uartdrvUartTypeLeuart = 1
102 } UARTDRV_UartType_t;
130 UARTDRV_Count_t transferCount);
154 #define DEFINE_BUF_QUEUE(qSize, qName) \
158 volatile uint16_t used; \
159 const uint16_t size; \
160 UARTDRV_Buffer_t fifo[qSize]; \
162 static volatile _##qName qName = \
180 #if defined( _USART_ROUTELOC0_MASK )
181 uint8_t portLocationTx;
182 uint8_t portLocationRx;
189 #if defined(USART_CTRL_MVDIS)
199 #if defined( _USART_ROUTELOC1_MASK )
200 uint8_t portLocationCts;
201 uint8_t portLocationRts;
220 #if defined( _LEUART_ROUTELOC0_MASK )
221 uint8_t portLocationTx;
222 uint8_t portLocationRx;
248 unsigned int txDmaCh;
249 unsigned int rxDmaCh;
250 DMADRV_PeripheralSignal_t txDmaSignal;
251 DMADRV_PeripheralSignal_t rxDmaSignal;
266 volatile bool rxDmaActive;
267 volatile bool txDmaActive;
268 volatile uint8_t txDmaPaused;
272 UARTDRV_UartType_t type;
291 UARTDRV_Count_t *bytesReceived,
292 UARTDRV_Count_t *bytesRemaining);
296 UARTDRV_Count_t *bytesSent,
297 UARTDRV_Count_t *bytesRemaining);
305 UARTDRV_Count_t count,
310 UARTDRV_Count_t count,
315 UARTDRV_Count_t count);
319 UARTDRV_Count_t count);
323 UARTDRV_Count_t count);
327 UARTDRV_Count_t maxLength);
375 #if defined(EMDRV_UARTDRV_HW_FLOW_CONTROL_ENABLE)
376 #undef EMDRV_UARTDRV_FLOW_CONTROL_ENABLE
377 #define EMDRV_UARTDRV_FLOW_CONTROL_ENABLE EMDRV_UARTDRV_HW_FLOW_CONTROL_ENABLE
Clock management unit (CMU) API.
USART_TypeDef * port
The peripheral used for UART.
Ecode_t UARTDRV_Transmit(UARTDRV_Handle_t handle, uint8_t *data, UARTDRV_Count_t count, UARTDRV_Callback_t callback)
Start a non-blocking transmit.
uint8_t UARTDRV_GetTransmitDepth(UARTDRV_Handle_t handle)
Returns the number of queued transmit operations.
uint8_t ctsPin
CTS pin number.
enum UARTDRV_AbortType UARTDRV_AbortType_t
Transfer abort type.
Abort all current and queued operations.
Ecode_t transferStatus
Completion status of transfer operation.
uint8_t ctsPin
CTS pin number.
GPIO_Port_TypeDef rtsPort
RTS pin port number.
uint32_t baudRate
UART baud rate.
UARTDRV_Buffer_FifoQueue_t * rxQueue
Receive operation queue.
Energy Aware drivers error code definitions.
UARTDRV_FlowControlState_t UARTDRV_FlowControlGetSelfStatus(UARTDRV_Handle_t handle)
Checks the self's flow control status.
USART_Parity_TypeDef parity
Parity configuration.
USART_Stopbits_TypeDef stopBits
Number of stop bits.
UARTDRV_AbortType
Transfer abort type.
CMSIS Cortex-M Peripheral Access Layer for Silicon Laboratories microcontroller devices.
volatile UARTDRV_Count_t itemsRemaining
Transfer items remaining.
Universal synchronous/asynchronous receiver/transmitter (USART/UART) peripheral API.
UARTDRV_FlowControlType_t fcType
Flow control mode.
Ecode_t UARTDRV_InitUart(UARTDRV_Handle_t handle, const UARTDRV_InitUart_t *initData)
Initialize a U(S)ART driver instance.
Ecode_t UARTDRV_FlowControlSet(UARTDRV_Handle_t handle, UARTDRV_FlowControlState_t state)
Set UART flow control state. Set nRTS pin if hardware flow control is enabled. Send XON/XOFF if softw...
uint32_t baudRate
UART baud rate.
const uint16_t size
Size of FIFO.
uint8_t portLocation
Location number for UART pins.
uint8_t rtsPin
RTS pin number.
GPIO_Port_TypeDef ctsPort
CTS pin port number.
This driver controls the state.
UARTDRV_Count_t transferCount
Transfer item count.
LEUART_Stopbits_TypeDef stopBits
Number of stop bits.
enum UARTDRV_FlowControlState UARTDRV_FlowControlState_t
Flow Control state.
Transfer operation FIFO queue typedef.
UARTDRV_HandleData_t * UARTDRV_Handle_t
Handle pointer.
UARTDRV_Buffer_FifoQueue_t * txQueue
Transmit operation queue.
uint8_t rtsPin
RTS pin number.
UARTDRV_FlowControlType
Flow Control method.
nRTS/nCTS hardware handshake
Ecode_t UARTDRV_ForceTransmit(UARTDRV_Handle_t handle, uint8_t *data, UARTDRV_Count_t count)
Direct transmit without interrupts or callback. Blocking function that ignores flow control if enable...
LEUART_TypeDef * port
The peripheral used for LEUART.
volatile uint16_t head
Index of next byte to send.
Ecode_t UARTDRV_ReceiveB(UARTDRV_Handle_t handle, uint8_t *data, UARTDRV_Count_t count)
Start a blocking receive.
GPIO_Port_TypeDef rtsPort
RTS pin port number.
General Purpose IO (GPIO) peripheral API.
uint32_t Ecode_t
Typedef for API function error code return values.
The UART peripheral controls nRTS/nCTS.
UARTDRV_Callback_t callback
Completion callback.
struct UARTDRV_HandleData UARTDRV_HandleData_t
volatile uint16_t used
Number of bytes queued.
UARTDRV_FlowControlType_t fcType
Flow control mode.
Low Energy Universal Asynchronous Receiver/Transmitter (LEUART) peripheral API.
volatile uint16_t tail
Index of where to enqueue next message.
void(* UARTDRV_Callback_t)(struct UARTDRV_HandleData *handle, Ecode_t transferStatus, uint8_t *data, UARTDRV_Count_t transferCount)
UARTDRV transfer completion callback function.
__STATIC_INLINE Ecode_t UARTDRV_Init(UARTDRV_Handle_t handle, UARTDRV_InitUart_t *initData)
Initialize a U(S)ART driver instance.
Ecode_t UARTDRV_Receive(UARTDRV_Handle_t handle, uint8_t *data, UARTDRV_Count_t count, UARTDRV_Callback_t callback)
Start a non-blocking receive.
Ecode_t UARTDRV_DeInit(UARTDRV_Handle_t handle)
Deinitialize a UART driver instance.
Abort current and queued receive operations.
LEUART_Parity_TypeDef parity
Parity configuration.
UARTDRV_Count_t UARTDRV_ForceReceive(UARTDRV_Handle_t handle, uint8_t *data, UARTDRV_Count_t maxLength)
Direct receive without interrupts or callback. Blocking function.
UARTDRV_Status_t UARTDRV_GetPeripheralStatus(UARTDRV_Handle_t handle)
Returns the status of the UART peripheral associated with a given handle.
uint32_t UARTDRV_Count_t
UART transfer count.
UARTDRV_Status_t UARTDRV_GetReceiveStatus(UARTDRV_Handle_t handle, uint8_t **buffer, UARTDRV_Count_t *bytesReceived, UARTDRV_Count_t *bytesRemaining)
Check the status of the UART and gather information about any ongoing receive operations.
Ecode_t UARTDRV_PauseTransmit(UARTDRV_Handle_t handle)
Pause an ongoing transmit operation.
uint8_t UARTDRV_GetReceiveDepth(UARTDRV_Handle_t handle)
Returns the number of queued receive operations.
enum UARTDRV_FlowControlType UARTDRV_FlowControlType_t
Flow Control method.
uint8_t * data
Transfer data buffer.
GPIO_Port_TypeDef ctsPort
CTS pin port number.
Ecode_t UARTDRV_Abort(UARTDRV_Handle_t handle, UARTDRV_AbortType_t type)
Abort ongoing UART transfers.
UARTDRV_Status_t UARTDRV_GetTransmitStatus(UARTDRV_Handle_t handle, uint8_t **buffer, UARTDRV_Count_t *bytesSent, UARTDRV_Count_t *bytesRemaining)
Check the status of the UART and gather information about any ongoing transmit operations.
uint8_t portLocation
Location number for LEUART pins.
Ecode_t UARTDRV_InitLeuart(UARTDRV_Handle_t handle, const UARTDRV_InitLeuart_t *initData)
Initialize a LEUART driver instance.
UARTDRV_FlowControlState_t UARTDRV_FlowControlGetPeerStatus(UARTDRV_Handle_t handle)
Checks the peer's flow control status.
UARTDRV_Buffer_FifoQueue_t * rxQueue
Receive operation queue.
Ecode_t UARTDRV_TransmitB(UARTDRV_Handle_t handle, uint8_t *data, UARTDRV_Count_t count)
Start a blocking transmit.
UARTDRV_FlowControlState
Flow Control state.
Ecode_t UARTDRV_FlowControlIgnoreRestrain(UARTDRV_Handle_t handle)
Enables transmission when restrained by flow control.
UARTDRV_Buffer_FifoQueue_t * txQueue
Transmit operation queue.
Abort current and queued transmit operations.
uint32_t UARTDRV_Status_t
UART status return type. Bitfield of UARTDRV_STATUS_* values.
Ecode_t UARTDRV_ResumeTransmit(UARTDRV_Handle_t handle)
Resume a paused transmit operation.
bool mvdis
Majority Vote Disable for 16x, 8x and 6x oversampling modes.
USART_OVS_TypeDef oversampling
Oversampling mode.
Ecode_t UARTDRV_FlowControlSetPeerStatus(UARTDRV_Handle_t handle, UARTDRV_FlowControlState_t state)
Set peer UART flow control state. Pause/resume transmit accordingly. Only for manual software flow co...