EVE 1.0
UART driver
Collaboration diagram for UART driver:

Modules

 nRF52 UART driver
 
 SC16IS7x0 UART driver
 

Data Structures

struct  uart_state_t
 
struct  uart_api_t
 
struct  uart_t
 

Typedefs

typedef void(* uart_rx_callback_t) (const struct uart_t *Uart, void *CallbackData, enum uart_rx_status_t RxStatus)
 
typedef void(* uart_tx_callback_t) (const struct uart_t *Uart, void *CallbackData)
 
typedef void(* uart_break_callback_t) (const struct uart_t *Uart, void *CallbackData)
 
typedef void(* uart_init_t) (const struct uart_t *Uart)
 

Enumerations

Functions

static void UartInit (const struct uart_t *Uart)
 Name: UartInit
Initializes Uart. More...
 
static void UartDisable (const struct uart_t *Uart)
 Name: UartDisable
Disables UART. More...
 
static uint32_t UartDmaBytesReceived (const struct uart_t *Uart)
 Name: UartDmaBytesReceived
Will return number of received bytes for current DMA transfer. More...
 
static void UartStartBasicTx (const struct uart_t *Uart, uint8_t *DataSrc, uint16_t DataSize, uart_tx_callback_t Callback, void *CallbackData)
 Name: UartStartBasicTx
Transmit data using DMA transfer in basic mode. Using primary DMA descriptor only. More...
 
static void UartStartPingPongTx (const struct uart_t *Uart, uint8_t *PrimDataSrc, uint16_t PrimDataSize, uint8_t *AltDataSrc, uint16_t AltDataSize, uart_tx_callback_t Callback, void *CallbackData)
 Name: UartStartPingPongTx
Transmit data using DMA transfer in PingPong mode. Will alternate between primary and alternate DMA descriptor. More...
 
static void UartRefreshPingPongTx (const struct uart_t *Uart, uint8_t *DataSrc, uint16_t DataSize, bool Stop)
 Name: UartRefreshPingPongTx
Refresh transmit of data using DMA transfer in PingPong mode. More...
 
static struct data_buffer_tUartGetTxBuffer (const struct uart_t *Uart)
 Name: UartGetTxBuffer
Returns the current TX buffer. More...
 
static void UartStartBasicRx (const struct uart_t *Uart, uint8_t *DataDest, uint16_t DataSize, uart_rx_callback_t Callback, void *CallbackData)
 Name: UartStartBasicRx
Receive data using DMA transfer in basic mode. Using primary DMA descriptor only. More...
 
static void UartStartPingPongRx (const struct uart_t *Uart, uint8_t *PrimDataDest, uint16_t PrimDataSize, uint8_t *AltDataDest, uint16_t AltDataSize, uart_rx_callback_t Callback, void *CallbackData)
 Name: UartStartPingPongRx
Receive data using DMA transfer in PingPong mode. Will alternate between primary and alternate DMA descriptor. More...
 
static void UartRefreshPingPongRx (const struct uart_t *Uart, uint8_t *DataDest, uint16_t DataSize, bool Stop)
 Name: UartRefreshPingPongRx
Refresh of receive data using DMA transfer in PingPong mode. Will alternate between primary and alternate DMA descriptor. More...
 
static const struct data_buffer_tUartGetRxBuffer (const struct uart_t *Uart)
 Name: UartGetRxBuffer
Returns the current RX buffer. More...
 
static void UartResetFifo (const struct uart_t *Uart, bool Tx, bool Rx)
 Name: UartResetFifo
Resets FIFO buffer for Tx or Rx or both.
NB: Resetting Rx FIFO stops receiving. More...
 
static void UartCancelRx (const struct uart_t *Uart)
 Name: UartCancelRx
Shuts down DMA, flushes FIFO and disables RX interrupts for the UART. More...
 
static bool UartIsBusyRx (const struct uart_t *Uart)
 Name: UartIsBusyRx
Returns busy status of the UART RX path. More...
 
static void UartCancelTx (const struct uart_t *Uart)
 Name: UartCancelTx
Shuts down DMA, flushes FIFO and disables TX interrupts for the UART. More...
 
static bool UartIsBusyTx (const struct uart_t *Uart)
 Name: UartIsBusyTx
Returns busy status of the UART TX path. More...
 
static void UartSetBaudrate (const struct uart_t *Uart, uint32_t Baudrate)
 Name: UartSetBaudrate
Sets new baudrate to the UART Note that in many situation Rx timeout settings must be adjusted simultaneously (use UartSetRxTimeouts function) More...
 
static void UartSetRxTimeouts (const struct uart_t *Uart, uint32_t RxStartTimeoutUs, uint32_t RxStopTimeoutUs)
 Name: UartSetRxTimeouts
Sets timeout values for the UART Calling code can use value UART_RX_TIMEOUT_DEFAULT as default value. More...
 
static void UartSendBreak (const struct uart_t *Uart, uart_break_callback_t Callback, void *CallbackData)
 Sends break (sets TX to logic 0 for a time of 1 byte transmission) More...
 
static void UartSetRts (const struct uart_t *Uart, bool Active)
 Manually drives RTS pin. HW flow control must be off to use this function. More...
 

Detailed Description

Abstract UART driver header.

This UART driver provides common interface to various UART block(s). Functionality included:

Typedef Documentation

typedef void(* uart_rx_callback_t) (const struct uart_t *Uart, void *CallbackData, enum uart_rx_status_t RxStatus)

The callback is called at completion of an asynchronous receive.

Parameters
UartUART to be used
CallbackDataUser-defined data
...TODO

Definition at line 129 of file uart.h.

typedef void(* uart_tx_callback_t) (const struct uart_t *Uart, void *CallbackData)

The callback is called at completion of an asynchronous transmit.

Parameters
UartUART to be used
CallbackDataUser-defined data

Definition at line 137 of file uart.h.

typedef void(* uart_break_callback_t) (const struct uart_t *Uart, void *CallbackData)

The callback is called at completion of break sending.

Parameters
UartUART to be used
CallbackDataUser-defined data

Definition at line 145 of file uart.h.

typedef void(* uart_init_t) (const struct uart_t *Uart)

UART driver virtual function types

Definition at line 151 of file uart.h.

Enumeration Type Documentation

UART flow control settings

Enumerator
UART_FLOW_CONTROL_DISABLED 

Flow control OFF.

UART_FLOW_CONTROL_CTSRTS 

HW flow control.

UART_FLOW_CONTROL_XONXOFF 

SW flow control.

Definition at line 64 of file uart.h.

UART parity settings

Enumerator
UART_PARITY_NONE 

No parity bit.

UART_PARITY_EVEN 

Parity bit is on. Calculate even parity.

UART_PARITY_ODD 

Parity bit is on. Calculate odd parity.

UART_PARITY_FORCED1 

Parity bit is on and always 1.

UART_PARITY_FORCED0 

Parity bit is on and always 0.

Definition at line 72 of file uart.h.

UART stop bits settings

Enumerator
UART_STOP_1 

One stop bit.

UART_STOP_2 

Two stop bits.

Definition at line 86 of file uart.h.

Status of finished Rx operation

Enumerator
UART_RX_OK 

Receiving completed successfully.

UART_RX_TIMEOUT 

Timeout while receiving (long delay after the last char received, typically 4 chars pause)

UART_RX_ERROR_OVERRUN 

Buffer overrun while receiving.

UART_RX_ERROR_PARITY 

Parity error while receiving.

UART_RX_ERROR_FRAMING 

Frame error (no stop bit) while receiving.

UART_RX_ERROR_BREAK 

Break received.

UART_RX_CANCELLED 

Rx was aborted by UartCancelRx()

Definition at line 93 of file uart.h.

anonymous enum
Enumerator
UART_RX_TIMEOUT_DEFAULT 

No Rx timeout: check buffer and return immedialely.

UART_RX_TIMEOUT_INFINITE 

No Rx timeout: wait forever.

Definition at line 104 of file uart.h.

Length of one UART word.

Enumerator
UART_WORDLEN_DEFAULT 

default word length (8 bit)

UART_WORDLEN_5 

5 bit word length

UART_WORDLEN_6 

6 bit word length

UART_WORDLEN_7 

7 bit word length

UART_WORDLEN_8 

8 bit word length

Definition at line 111 of file uart.h.

Function Documentation

static void UartInit ( const struct uart_t Uart)
inlinestatic

Name: UartInit
Initializes Uart.

Parameters
UartUART parameters to be used.
Returns
void

Definition at line 247 of file uart.h.

References uart_state_t::Uart.

static void UartDisable ( const struct uart_t Uart)
inlinestatic

Name: UartDisable
Disables UART.

Parameters
UartUART parameters to be used.
Returns
void

Definition at line 260 of file uart.h.

References uart_state_t::Uart.

static uint32_t UartDmaBytesReceived ( const struct uart_t Uart)
inlinestatic

Name: UartDmaBytesReceived
Will return number of received bytes for current DMA transfer.

Parameters
UartUART parameters to be used.
Returns
Number of received bytes for current DMA transfer

Definition at line 273 of file uart.h.

References data_buffer_t::Pos, uart_state_t::RxBuffer, uart_state_t::RxBufIndex, and uart_t::State.

static void UartStartBasicTx ( const struct uart_t Uart,
uint8_t *  DataSrc,
uint16_t  DataSize,
uart_tx_callback_t  Callback,
void *  CallbackData 
)
inlinestatic

Name: UartStartBasicTx
Transmit data using DMA transfer in basic mode. Using primary DMA descriptor only.

Parameters
UartUART parameters to be used.
DataSrcSource address for DMA transfer
DataSizeNumber of DMA transfer bytes. Range: 1 through 255
CallbackUser-defined function to be called at completion
CallbackDataUser-defined data for the completion callback
Returns
void

Definition at line 292 of file uart.h.

References uart_state_t::Uart.

static void UartStartPingPongTx ( const struct uart_t Uart,
uint8_t *  PrimDataSrc,
uint16_t  PrimDataSize,
uint8_t *  AltDataSrc,
uint16_t  AltDataSize,
uart_tx_callback_t  Callback,
void *  CallbackData 
)
inlinestatic

Name: UartStartPingPongTx
Transmit data using DMA transfer in PingPong mode. Will alternate between primary and alternate DMA descriptor.

Parameters
UartUART parameters to be used.
PrimDataSrcSource address for DMA transfer using primary descriptor
PrimDataSizeNumber of DMA transfer bytes using primary descriptor. Range: 1 through 1024
AltDataSrcSource address for DMA transfer using alternate descriptor
AltDataSizeNumber of DMA transfer bytes using alternate descriptor. Range: 1 through 1024
CallbackUser-defined function to be called at completion
CallbackDataUser-defined data for the completion callback
Returns
void

Definition at line 314 of file uart.h.

References uart_state_t::Uart.

static void UartRefreshPingPongTx ( const struct uart_t Uart,
uint8_t *  DataSrc,
uint16_t  DataSize,
bool  Stop 
)
inlinestatic

Name: UartRefreshPingPongTx
Refresh transmit of data using DMA transfer in PingPong mode.

Parameters
UartUART parameters to be used.
DataSrcSource address for DMA transfer. NULL to leave descriptor as is.
DataSizeNumber of DMA transfer bytes. Range: 1 through 1024
StopIndicate that DMA transfer shall stop after using this descriptor.
Returns
void

Definition at line 335 of file uart.h.

References uart_state_t::Uart.

static struct data_buffer_t* UartGetTxBuffer ( const struct uart_t Uart)
static

Name: UartGetTxBuffer
Returns the current TX buffer.

Parameters
UartUART parameters to be used.
Returns
Pointer to the active TX buffer

Definition at line 350 of file uart.h.

References uart_t::State, uart_state_t::TxBuffer, and uart_state_t::TxBufIndex.

static void UartStartBasicRx ( const struct uart_t Uart,
uint8_t *  DataDest,
uint16_t  DataSize,
uart_rx_callback_t  Callback,
void *  CallbackData 
)
inlinestatic

Name: UartStartBasicRx
Receive data using DMA transfer in basic mode. Using primary DMA descriptor only.

Parameters
UartUART parameters to be used.
DataDestDestination address for DMA transfer
DataSizeNumber of DMA transfer bytes. Range: 1 through 1024
CallbackUser-defined function to be called at completion or timeout
CallbackDataUser-defined data for the completion callback
Returns
void

Definition at line 369 of file uart.h.

References uart_state_t::Uart.

static void UartStartPingPongRx ( const struct uart_t Uart,
uint8_t *  PrimDataDest,
uint16_t  PrimDataSize,
uint8_t *  AltDataDest,
uint16_t  AltDataSize,
uart_rx_callback_t  Callback,
void *  CallbackData 
)
inlinestatic

Name: UartStartPingPongRx
Receive data using DMA transfer in PingPong mode. Will alternate between primary and alternate DMA descriptor.

Parameters
UartUART parameters to be used.
PrimDataDestDestination address for DMA transfer using primary descriptor
PrimDataSizeNumber of DMA transfer bytes using primary descriptor. Range: 1 through 1024
AltDataDestDestination address for DMA transfer using alternate descriptor
AltDataSizeNumber of DMA transfer bytes using alternate descriptor. Range: 1 through 1024
CallbackUser-defined function to be called at completion or timeout
CallbackDataUser-defined data for the completion callback
Returns
void

Definition at line 391 of file uart.h.

References uart_state_t::Uart.

static void UartRefreshPingPongRx ( const struct uart_t Uart,
uint8_t *  DataDest,
uint16_t  DataSize,
bool  Stop 
)
inlinestatic

Name: UartRefreshPingPongRx
Refresh of receive data using DMA transfer in PingPong mode. Will alternate between primary and alternate DMA descriptor.

Parameters
UartUART parameters to be used.
DataDestDestination address for DMA transfer. NULL to leave descriptor as is.
DataSizeNumber of DMA transfer bytes using primary descriptor. Range: 1 through 1024
StopIndicate that DMA transfer shall stop after using this descriptor.
Returns
void

Definition at line 413 of file uart.h.

References uart_state_t::Uart.

static const struct data_buffer_t* UartGetRxBuffer ( const struct uart_t Uart)
static

Name: UartGetRxBuffer
Returns the current RX buffer.

Parameters
UartUART parameters to be used.
Returns
Pointer to the active RX buffer

Definition at line 428 of file uart.h.

References uart_state_t::RxBuffer, uart_state_t::RxBufIndex, and uart_t::State.

static void UartResetFifo ( const struct uart_t Uart,
bool  Tx,
bool  Rx 
)
inlinestatic

Name: UartResetFifo
Resets FIFO buffer for Tx or Rx or both.
NB: Resetting Rx FIFO stops receiving.

Parameters
UartUART parameters to be used.
TxSet to TRUE to reset Tx FIFO.
RxSet to TRUE to reset Rx FIFO.
Returns
void

Definition at line 445 of file uart.h.

References uart_state_t::Uart.

static void UartCancelRx ( const struct uart_t Uart)
inlinestatic

Name: UartCancelRx
Shuts down DMA, flushes FIFO and disables RX interrupts for the UART.

Parameters
UartUART parameters to be used.
Returns
void

Definition at line 458 of file uart.h.

References uart_state_t::Uart.

static bool UartIsBusyRx ( const struct uart_t Uart)
inlinestatic

Name: UartIsBusyRx
Returns busy status of the UART RX path.

Parameters
UartUART parameters to be used.
Returns
true if UART is receiving data

Definition at line 471 of file uart.h.

References uart_state_t::Uart.

static void UartCancelTx ( const struct uart_t Uart)
inlinestatic

Name: UartCancelTx
Shuts down DMA, flushes FIFO and disables TX interrupts for the UART.

Parameters
UartUART parameters to be used.

Definition at line 483 of file uart.h.

References uart_state_t::Uart.

static bool UartIsBusyTx ( const struct uart_t Uart)
inlinestatic

Name: UartIsBusyTx
Returns busy status of the UART TX path.

Parameters
UartUART parameters to be used.
Returns
true if UART is sending data

Definition at line 496 of file uart.h.

References uart_state_t::Uart.

static void UartSetBaudrate ( const struct uart_t Uart,
uint32_t  Baudrate 
)
inlinestatic

Name: UartSetBaudrate
Sets new baudrate to the UART Note that in many situation Rx timeout settings must be adjusted simultaneously (use UartSetRxTimeouts function)

Parameters
UartUART parameters to be used.
BaudrateNew baudrate in bps.
Returns
void

Definition at line 512 of file uart.h.

References uart_state_t::Baudrate, uart_t::State, and uart_state_t::Uart.

static void UartSetRxTimeouts ( const struct uart_t Uart,
uint32_t  RxStartTimeoutUs,
uint32_t  RxStopTimeoutUs 
)
inlinestatic

Name: UartSetRxTimeouts
Sets timeout values for the UART Calling code can use value UART_RX_TIMEOUT_DEFAULT as default value.

Parameters
UartUART parameters to be used.
RxStartTimeoutUsMax time the driver will wait for the first symbol in the message. UART_RX_TIMEOUT_DEFAULT can be used to set the timeout to default. UART_RX_TIMEOUT_INFINITE can be used to disable the timeout.
RxStopTimeoutUsMax time the driver will wait for the next symbol in the message UART_RX_TIMEOUT_DEFAULT can be used to set the timeout to default. UART_RX_TIMEOUT_INFINITE can be used to disable the timeout.
Returns
void

Definition at line 533 of file uart.h.

References uart_state_t::RxStartTimeoutUs, uart_state_t::RxStopTimeoutUs, and uart_state_t::Uart.

static void UartSendBreak ( const struct uart_t Uart,
uart_break_callback_t  Callback,
void *  CallbackData 
)
inlinestatic

Sends break (sets TX to logic 0 for a time of 1 byte transmission)

Parameters
UartUART parameters to be used.
CallbackFunction to be called after the break signal is sent.
CallbackDataPointer to the user data to be supplied as callback parameter.

Definition at line 547 of file uart.h.

References uart_state_t::Uart.

static void UartSetRts ( const struct uart_t Uart,
bool  Active 
)
inlinestatic

Manually drives RTS pin. HW flow control must be off to use this function.

Parameters
UartUART parameters to be used.
ActiveTRUE: set RTS active (logic 0) FALSE: set RTS passive (logical 1)

Definition at line 562 of file uart.h.

References uart_state_t::Uart.