nRF5 SDK v16.0.0
Modules | Data Structures | Macros | Typedefs | Enumerations | Functions
libUARTE asynchronous library

Module for reliable communication over UARTE. More...

Modules

 libUARTE_async library configuration
 

Data Structures

struct  nrf_libuarte_async_data_t
 Structure for libuarte async transfer completion event. More...
 
struct  nrf_libuarte_async_overrun_err_evt_t
 Structu for software error event. More...
 
struct  nrf_libuarte_async_evt_t
 Structure for libuarte error event. More...
 
struct  nrf_libuarte_async_config_t
 Structure for libuarte async configuration. More...
 
struct  nrf_libuarte_async_ctrl_blk_t
 nrf_libuarte_async control block (placed in RAM). More...
 
struct  nrf_libuarte_app_timer_ctrl_blk_t
 
struct  nrf_libuarte_async_t
 nrf_libuarte_async instance structure (placed in ROM). More...
 

Macros

#define NRF_LIBUARTE_ASYNC_WITH_APP_TIMER   0
 
#define NRF_LIBUARTE_PERIPHERAL_NOT_USED   255
 
#define LIBUARTE_ASYNC_DEBRACKET(...)   __VA_ARGS__
 
#define __LIBUARTE_ASYNC_ARG_2(ignore_this, val,...)   val
 
#define __LIBUARTE_ASYNC_ARG_2_DEBRACKET(ignore_this, val,...)   LIBUARTE_ASYNC_DEBRACKET val
 
#define _LIBUARTE_ASYNC_EVAL(_eval_flag, _iftrue, _iffalse)   _LIBUARTE_ASYNC_EVAL1(_eval_flag, _iftrue, _iffalse)
 
#define _LIBUARTE_ASYNC_EVAL1(_eval_flag, _iftrue, _iffalse)   _LIBUARTE_ASYNC_EVAL2(_LIBUARTE_ASYNC_ZZZZ##_eval_flag, _iftrue, _iffalse)
 
#define _LIBUARTE_ASYNC_ZZZZ1   _LIBUARTE_ASYNC_YYYY,
 
#define _LIBUARTE_ASYNC_EVAL2(one_or_two_args, _iftrue, _iffalse)   __LIBUARTE_ASYNC_ARG_2_DEBRACKET(one_or_two_args _iftrue, _iffalse)
 
#define NRF_LIBUARTE_ASYNC_DEFINE(_name, _uarte_idx, _timer0_idx, _rtc1_idx, _timer1_idx, _rx_buf_size, _rx_buf_cnt)
 Macro for creating instance of libuarte_async. More...
 

Typedefs

typedef void(* nrf_libuarte_async_evt_handler_t )(void *context, nrf_libuarte_async_evt_t *p_evt)
 Interrupt event handler. More...
 

Enumerations

enum  nrf_libuarte_async_evt_type_t {
  NRF_LIBUARTE_ASYNC_EVT_RX_DATA,
  NRF_LIBUARTE_ASYNC_EVT_TX_DONE,
  NRF_LIBUARTE_ASYNC_EVT_ERROR,
  NRF_LIBUARTE_ASYNC_EVT_OVERRUN_ERROR
}
 Types of libuarte driver events. More...
 
enum  nrf_libuarte_async_ppi_channel_t {
  NRF_LIBUARTE_ASYNC_PPI_CH_RXRDY_CLEAR,
  NRF_LIBUARTE_ASYNC_PPI_CH_COMPARE_SHUTDOWN,
  NRF_LIBUARTE_ASYNC_PPI_CH_MAX
}
 

Functions

void nrf_libuarte_async_timeout_handler (const nrf_libuarte_async_t *p_libuarte)
 
ret_code_t nrf_libuarte_async_init (const nrf_libuarte_async_t *const p_libuarte, nrf_libuarte_async_config_t const *p_config, nrf_libuarte_async_evt_handler_t evt_handler, void *context)
 Function for initializing the libuarte async library. More...
 
void nrf_libuarte_async_uninit (const nrf_libuarte_async_t *const p_libuarte)
 Function for uninitializing the libuarte async library. More...
 
void nrf_libuarte_async_enable (const nrf_libuarte_async_t *const p_libuarte)
 Function for enabling receiver. More...
 
void nrf_libuarte_async_rts_clear (const nrf_libuarte_async_t *const p_libuarte)
 Function for deasserting RTS to pause the transmission. More...
 
void nrf_libuarte_async_rts_set (const nrf_libuarte_async_t *const p_libuarte)
 Function for asserting RTS to restart the transmission. More...
 
ret_code_t nrf_libuarte_async_tx (const nrf_libuarte_async_t *const p_libuarte, uint8_t *p_data, size_t length)
 Function for sending data asynchronously over UARTE. More...
 
void nrf_libuarte_async_rx_free (const nrf_libuarte_async_t *const p_libuarte, uint8_t *p_data, size_t length)
 Function for deallocating received buffer data. More...
 

Detailed Description

Module for reliable communication over UARTE.

Macro Definition Documentation

#define NRF_LIBUARTE_ASYNC_DEFINE (   _name,
  _uarte_idx,
  _timer0_idx,
  _rtc1_idx,
  _timer1_idx,
  _rx_buf_size,
  _rx_buf_cnt 
)

Macro for creating instance of libuarte_async.

Libuarte_async requires one timer-like peripheral (RTC or TIMER) for triggering RX timeout. Macro will create instance only for peripheral which is used.

Parameters
_nameInstance name.
_uarte_idxUARTE instance used.
_timer0_idxTIMER instance used by libuarte for bytes counting.
_rtc1_idxRTC instance used for timeout. If set to NRF_LIBUARTE_PERIPHERAL_NOT_USED then TIMER instance is used or app_timer instance if _timer1_idx is also set to NRF_LIBUARTE_PERIPHERAL_NOT_USED.
_timer1_idxTIMER instance used for timeout. If set to NRF_LIBUARTE_PERIPHERAL_NOT_USED then RTC instance is used or app_timer instance if _rtc1_idx is also set to NRF_LIBUARTE_PERIPHERAL_NOT_USED.
_rx_buf_sizeSize of single RX buffer. Size impacts accepted latency between buffer request and providing next buffer. Next must be provided within before _rx_buf_size bytes is received.
_rx_buf_cntNumber of buffers in the RX buffer pool. Size impacts accepted latency between NRF_LIBUARTE_ASYNC_EVT_RX_DATA event and nrf_libuarte_async_rx_free.

Typedef Documentation

typedef void(* nrf_libuarte_async_evt_handler_t)(void *context, nrf_libuarte_async_evt_t *p_evt)

Interrupt event handler.

Parameters
[in]p_evtPointer to event structure. Event is allocated on the stack so it is available only within the context of the event handler.

Enumeration Type Documentation

Types of libuarte driver events.

Enumerator
NRF_LIBUARTE_ASYNC_EVT_RX_DATA 

Requested TX transfer completed.

NRF_LIBUARTE_ASYNC_EVT_TX_DONE 

Requested RX transfer completed.

NRF_LIBUARTE_ASYNC_EVT_ERROR 

Error reported by UARTE peripheral.

NRF_LIBUARTE_ASYNC_EVT_OVERRUN_ERROR 

Error reported by the driver.

Function Documentation

void nrf_libuarte_async_enable ( const nrf_libuarte_async_t *const  p_libuarte)

Function for enabling receiver.

Parameters
p_libuarteLibuarte_async instance.
ret_code_t nrf_libuarte_async_init ( const nrf_libuarte_async_t *const  p_libuarte,
nrf_libuarte_async_config_t const *  p_config,
nrf_libuarte_async_evt_handler_t  evt_handler,
void *  context 
)

Function for initializing the libuarte async library.

Parameters
[in]p_libuarteLibuarte_async instance.
[in]p_configPointer to the structure with initial configuration.
[in]evt_handlerEvent handler provided by the user. Must not be NULL.
[in]contextUser context passed to the event handler.
Returns
NRF_SUCCESS when properly initialized. NRF_ERROR_INTERNAL otherwise.
void nrf_libuarte_async_rts_clear ( const nrf_libuarte_async_t *const  p_libuarte)

Function for deasserting RTS to pause the transmission.

Flow control must be enabled.

Parameters
p_libuarteLibuarte_async instance.
void nrf_libuarte_async_rts_set ( const nrf_libuarte_async_t *const  p_libuarte)

Function for asserting RTS to restart the transmission.

Flow control must be enabled.

Parameters
p_libuarteLibuarte_async instance.
void nrf_libuarte_async_rx_free ( const nrf_libuarte_async_t *const  p_libuarte,
uint8_t *  p_data,
size_t  length 
)

Function for deallocating received buffer data.

Parameters
[in]p_libuarteLibuarte_async instance.
[in]p_dataPointer to data.
[in]lengthNumber of bytes to free.
ret_code_t nrf_libuarte_async_tx ( const nrf_libuarte_async_t *const  p_libuarte,
uint8_t *  p_data,
size_t  length 
)

Function for sending data asynchronously over UARTE.

Parameters
[in]p_libuarteLibuarte_async instance.
[in]p_dataPointer to data.
[in]lengthNumber of bytes to send. Maximum possible length is dependent on the used SoC (see the MAXCNT register description in the Product Specification). The library checks it with assertion.
Return values
NRF_ERROR_BUSYData is transferring.
NRF_ERROR_INTERNALError during configuration.
NRF_SUCCESSBuffer set for sending.
void nrf_libuarte_async_uninit ( const nrf_libuarte_async_t *const  p_libuarte)

Function for uninitializing the libuarte async library.

Parameters
[in]p_libuarteLibuarte_async instance.

Documentation feedback | Developer Zone | Subscribe | Updated