libUARTE

nRF5 SDK v15.3.0

Module for reliable communication over UARTE. More...

Macros

#define NRF_LIBUARTE_DEFINE (_name, _uarte_idx, _timer_idx)

Typedefs

typedef void(* nrf_libuarte_evt_handler_t )(void *context, nrf_libuarte_evt_t *p_evt)

Enumerations

enum nrf_libuarte_evt_type_t {
NRF_LIBUARTE_EVT_RX_DATA ,
NRF_LIBUARTE_EVT_RX_BUF_REQ ,
NRF_LIBUARTE_EVT_TX_DONE ,
NRF_LIBUARTE_EVT_ERROR
}
enum nrf_libuarte_ppi_channel_t {
NRF_LIBUARTE_PPI_CH_EXT_TRIGGER_STARTRX_EN_ENDRX_STARTX ,
NRF_LIBUARTE_PPI_CH_RXSTARTED_EXT_TSK ,
NRF_LIBUARTE_PPI_CH_EXT_STOP_STOPRX ,
NRF_LIBUARTE_PPI_CH_EXT_STOP_GROUPS_EN ,
NRF_LIBUARTE_PPI_CH_RXRDY_TIMER_COUNT ,
NRF_LIBUARTE_PPI_CH_RX_MAX ,
NRF_LIBUARTE_PPI_CH_ENDRX_STARTRX = NRF_LIBUARTE_PPI_CH_RX_MAX,
NRF_LIBUARTE_PPI_CH_ENDRX_EXT_TSK ,
NRF_LIBUARTE_PPI_CH_RX_GROUP_MAX ,
NRF_LIBUARTE_PPI_CH_ENDTX_STARTTX = NRF_LIBUARTE_PPI_CH_RX_GROUP_MAX,
NRF_LIBUARTE_PPI_CH_MAX
}
PPI channels used by libuarte.
enum nrf_libuarte_ppi_group_t {
NRF_LIBUARTE_PPI_GROUP_ENDRX_STARTRX ,
NRF_LIBUARTE_PPI_GROUP_ENDRX_EXT_RXDONE_TSK ,
NRF_LIBUARTE_PPI_GROUP_MAX
}
PPI groups used by libuarte. More...

Functions

ret_code_t nrf_libuarte_init (const nrf_libuarte_t *const p_libuarte, nrf_libuarte_config_t *p_config, nrf_libuarte_evt_handler_t evt_handler, void *context)
Function for initializing the libUARTE library. More...
void nrf_libuarte_uninit (const nrf_libuarte_t *const p_libuarte)
Function for uninitializing the libUARTE library. More...
ret_code_t nrf_libuarte_tx (const nrf_libuarte_t *const p_libuarte, uint8_t *p_data, size_t len)
Function for sending data over UARTE using EasyDMA. More...
ret_code_t nrf_libuarte_rx_start (const nrf_libuarte_t *const p_libuarte, uint8_t *p_data, size_t len, bool ext_trigger_en)
Function for starting receiving data with additional configuration of external trigger to start receiving. More...
void nrf_libuarte_rx_buf_rsp (const nrf_libuarte_t *const p_libuarte, uint8_t *p_data, size_t len)
Function for setting a buffer for data that will be later received in UARTE. More...
void nrf_libuarte_rx_stop (const nrf_libuarte_t *const p_libuarte)
Function for stopping receiving data over UARTE. More...

Variables

const IRQn_Type libuarte_irqn []

Detailed Description

Module for reliable communication over UARTE.

Macro Definition Documentation

#define NRF_LIBUARTE_DEFINE ( _name,
_uarte_idx,
_timer_idx
)
Value:
STATIC_ASSERT (_uarte_idx < UARTE_COUNT, "UARTE instance not present" );\
STATIC_ASSERT( CONCAT_2 (NRF_LIBUARTE_UARTE,_uarte_idx) == 1, "UARTE instance not enabled" );\
STATIC_ASSERT(CONCAT_3(NRFX_TIMER,_timer_idx, _ENABLED) == 1, "Timer instance not enabled" );\
static nrf_libuarte_ctrl_blk_t CONCAT_2 (_name, ctrl_blk); \
static const nrf_libuarte_t _name = { \
.ctrl_blk = & CONCAT_2 (_name, ctrl_blk), \
.timer = NRFX_TIMER_INSTANCE (_timer_idx), \
.uarte = CONCAT_2 (NRF_UARTE, _uarte_idx),\
}

Enumeration Type Documentation

Enumerator
NRF_LIBUARTE_EVT_RX_DATA

Data received.

NRF_LIBUARTE_EVT_RX_BUF_REQ

Requesting new buffer for receiving data.

NRF_LIBUARTE_EVT_TX_DONE

Requested TX transfer completed.

NRF_LIBUARTE_EVT_ERROR

Error reported by the UARTE peripheral.

PPI groups used by libuarte.

Enumerator
NRF_LIBUARTE_PPI_GROUP_ENDRX_STARTRX

Group used for controlling PPI connection between ENDRX and STARTRX.

NRF_LIBUARTE_PPI_GROUP_ENDRX_EXT_RXDONE_TSK

Group used for controlling PPI connection between ENDRX and RXDONE.

Function Documentation

ret_code_t nrf_libuarte_init ( const nrf_libuarte_t *const p_libuarte ,
nrf_libuarte_config_t * p_config ,
nrf_libuarte_evt_handler_t evt_handler ,
void * context
)

Function for initializing the libUARTE library.

Parameters
[in] p_libuarte Pointer to libuarte instance.
[in] p_config Pointer to the structure with initial configuration.
[in] evt_handler Event handler provided by the user. Must not be NULL.
[in] context User context passed in the callback.
Returns
NRF_SUCCESS when properly initialized. NRF_ERROR_INTERNAL otherwise.
void nrf_libuarte_rx_buf_rsp ( const nrf_libuarte_t *const p_libuarte ,
uint8_t * p_data ,
size_t len
)

Function for setting a buffer for data that will be later received in UARTE.

Parameters
p_libuarte Pointer to libuarte instance.
p_data Pointer to data.
len Number of bytes to receive. Maximum possible length is dependent on the used SoC (see the MAXCNT register description in the Product Specification). The library checks it with an assertion.
ret_code_t nrf_libuarte_rx_start ( const nrf_libuarte_t *const p_libuarte ,
uint8_t * p_data ,
size_t len ,
bool ext_trigger_en
)

Function for starting receiving data with additional configuration of external trigger to start receiving.

Parameters
p_libuarte Pointer to libuarte instance.
p_data Pointer to data.
len Number of bytes to receive. Maximum possible length is dependent on the used SoC (see the MAXCNT register description in the Product Specification). The library checks it with an assertion.
ext_trigger_en True to disable immediate start.
Return values
NRF_ERROR_INTERNAL Error during PPI channel configuration.
NRF_SUCCESS Buffer set for receiving.
void nrf_libuarte_rx_stop ( const nrf_libuarte_t *const p_libuarte )

Function for stopping receiving data over UARTE.

Parameters
p_libuarte Pointer to libuarte instance.
ret_code_t nrf_libuarte_tx ( const nrf_libuarte_t *const p_libuarte ,
uint8_t * p_data ,
size_t len
)

Function for sending data over UARTE using EasyDMA.

Parameters
[in] p_libuarte Pointer to libuarte instance.
[in] p_data Pointer to data.
[in] len Number of bytes to send.
Return values
NRF_ERROR_BUSY Data is transferring.
NRF_ERROR_INTERNAL Error during PPI channel configuration.
NRF_SUCCESS Buffer set for sending.
void nrf_libuarte_uninit ( const nrf_libuarte_t *const p_libuarte )

Function for uninitializing the libUARTE library.

Parameters
[in] p_libuarte Pointer to libuarte instance.