nRF5 SDK v17.1.0
Modules | Data Structures | Macros | Typedefs | Enumerations | Functions
UARTE driver

UARTE peripheral driver. More...

Modules

 UARTE peripheral driver configuration
 

Data Structures

struct  nrfx_uarte_t
 Structure for the UARTE driver instance. More...
 
struct  nrfx_uarte_config_t
 Structure for the UARTE configuration. More...
 
struct  nrfx_uarte_xfer_evt_t
 Structure for the UARTE transfer completion event. More...
 
struct  nrfx_uarte_error_evt_t
 Structure for UARTE error event. More...
 
struct  nrfx_uarte_event_t
 Structure for UARTE event. More...
 

Macros

#define NRFX_UARTE_INSTANCE(id)
 Macro for creating a UARTE driver instance. More...
 
#define NRFX_UARTE_DEFAULT_CONFIG
 UARTE default configuration. More...
 

Typedefs

typedef void(* nrfx_uarte_event_handler_t )(nrfx_uarte_event_t const *p_event, void *p_context)
 UARTE interrupt event handler. More...
 

Enumerations

enum  nrfx_uarte_evt_type_t {
  NRFX_UARTE_EVT_TX_DONE,
  NRFX_UARTE_EVT_RX_DONE,
  NRFX_UARTE_EVT_ERROR
}
 Types of UARTE driver events. More...
 

Functions

nrfx_err_t nrfx_uarte_init (nrfx_uarte_t const *p_instance, nrfx_uarte_config_t const *p_config, nrfx_uarte_event_handler_t event_handler)
 Function for initializing the UARTE driver. More...
 
void nrfx_uarte_uninit (nrfx_uarte_t const *p_instance)
 Function for uninitializing the UARTE driver. More...
 
__STATIC_INLINE uint32_t nrfx_uarte_task_address_get (nrfx_uarte_t const *p_instance, nrf_uarte_task_t task)
 Function for getting the address of the specified UARTE task. More...
 
__STATIC_INLINE uint32_t nrfx_uarte_event_address_get (nrfx_uarte_t const *p_instance, nrf_uarte_event_t event)
 Function for getting the address of the specified UARTE event. More...
 
nrfx_err_t nrfx_uarte_tx (nrfx_uarte_t const *p_instance, uint8_t const *p_data, size_t length)
 Function for sending data over UARTE. More...
 
bool nrfx_uarte_tx_in_progress (nrfx_uarte_t const *p_instance)
 Function for checking if UARTE is currently transmitting. More...
 
void nrfx_uarte_tx_abort (nrfx_uarte_t const *p_instance)
 Function for aborting any ongoing transmission. More...
 
nrfx_err_t nrfx_uarte_rx (nrfx_uarte_t const *p_instance, uint8_t *p_data, size_t length)
 Function for receiving data over UARTE. More...
 
bool nrfx_uarte_rx_ready (nrfx_uarte_t const *p_instance)
 Function for testing the receiver state in blocking mode. More...
 
void nrfx_uarte_rx_abort (nrfx_uarte_t const *p_instance)
 Function for aborting any ongoing reception. More...
 
uint32_t nrfx_uarte_errorsrc_get (nrfx_uarte_t const *p_instance)
 Function for reading error source mask. Mask contains values from nrf_uarte_error_mask_t. More...
 

Detailed Description

UARTE peripheral driver.

Macro Definition Documentation

#define NRFX_UARTE_DEFAULT_CONFIG
Value:
{ \
.pseltxd = NRF_UARTE_PSEL_DISCONNECTED, \
.pselrxd = NRF_UARTE_PSEL_DISCONNECTED, \
.pselcts = NRF_UARTE_PSEL_DISCONNECTED, \
.pselrts = NRF_UARTE_PSEL_DISCONNECTED, \
.p_context = NULL, \
.interrupt_priority = NRFX_UARTE_DEFAULT_CONFIG_IRQ_PRIORITY, \
}

UARTE default configuration.

#define NRFX_UARTE_INSTANCE (   id)
Value:
{ \
.p_reg = NRFX_CONCAT_2(NRF_UARTE, id), \
.drv_inst_idx = NRFX_CONCAT_3(NRFX_UARTE, id, _INST_IDX), \
}

Macro for creating a UARTE driver instance.

Typedef Documentation

typedef void(* nrfx_uarte_event_handler_t)(nrfx_uarte_event_t const *p_event, void *p_context)

UARTE interrupt event handler.

Parameters
[in]p_eventPointer to event structure. Event is allocated on the stack so it is available only within the context of the event handler.
[in]p_contextContext passed to the interrupt handler, set on initialization.

Enumeration Type Documentation

Types of UARTE driver events.

Enumerator
NRFX_UARTE_EVT_TX_DONE 

Requested TX transfer completed.

NRFX_UARTE_EVT_RX_DONE 

Requested RX transfer completed.

NRFX_UARTE_EVT_ERROR 

Error reported by UART peripheral.

Function Documentation

uint32_t nrfx_uarte_errorsrc_get ( nrfx_uarte_t const *  p_instance)

Function for reading error source mask. Mask contains values from nrf_uarte_error_mask_t.

Note
Function must be used in the blocking mode only. In case of non-blocking mode, an error event is generated. Function clears error sources after reading.
Parameters
[in]p_instancePointer to the driver instance structure.
Returns
Mask of reported errors.
__STATIC_INLINE uint32_t nrfx_uarte_event_address_get ( nrfx_uarte_t const *  p_instance,
nrf_uarte_event_t  event 
)

Function for getting the address of the specified UARTE event.

Parameters
[in]p_instancePointer to the driver instance structure.
[in]eventEvent.
Returns
Event address.
nrfx_err_t nrfx_uarte_init ( nrfx_uarte_t const *  p_instance,
nrfx_uarte_config_t const *  p_config,
nrfx_uarte_event_handler_t  event_handler 
)

Function for initializing the UARTE driver.

This function configures and enables UARTE. After this function GPIO pins are controlled by UARTE.

Parameters
[in]p_instancePointer to the driver instance structure.
[in]p_configPointer to the structure with the initial configuration.
[in]event_handlerEvent handler provided by the user. If not provided driver works in blocking mode.
Return values
NRFX_SUCCESSInitialization was successful.
NRFX_ERROR_INVALID_STATEDriver is already initialized.
NRFX_ERROR_BUSYSome other peripheral with the same instance ID is already in use. This is possible only if Peripheral Resource Sharing (PRS) module is enabled.
nrfx_err_t nrfx_uarte_rx ( nrfx_uarte_t const *  p_instance,
uint8_t *  p_data,
size_t  length 
)

Function for receiving data over UARTE.

If an event handler is provided in the nrfx_uarte_init() call, this function returns immediately and the handler is called when the transfer is done. Otherwise, the transfer is performed in blocking mode, that is this function returns when the transfer is finished. Blocking mode is not using interrupt so there is no context switching inside the function. The receive buffer pointer is double-buffered in non-blocking mode. The secondary buffer can be set immediately after starting the transfer and will be filled when the primary buffer is full. The double-buffering feature allows receiving data continuously.

Note
Peripherals using EasyDMA (including UARTE) require the transfer buffers to be placed in the Data RAM region. If this condition is not met, this function fails with the error code NRFX_ERROR_INVALID_ADDR.
Parameters
[in]p_instancePointer to the driver instance structure.
[in]p_dataPointer to data.
[in]lengthNumber of bytes to receive. Maximum possible length is dependent on the used SoC (see the MAXCNT register description in the Product Specification). The driver checks it with assertion.
Return values
NRFX_SUCCESSInitialization is successful.
NRFX_ERROR_BUSYThe driver is already receiving (and the secondary buffer has already been set in non-blocking mode).
NRFX_ERROR_FORBIDDENThe transfer is aborted from a different context (blocking mode only).
NRFX_ERROR_INTERNALThe UARTE peripheral reports an error.
NRFX_ERROR_INVALID_ADDRp_data does not point to RAM buffer.
void nrfx_uarte_rx_abort ( nrfx_uarte_t const *  p_instance)

Function for aborting any ongoing reception.

Note
NRFX_UARTE_EVT_RX_DONE event will be generated in non-blocking mode. It will contain number of bytes received until the abort was called. The event handler will be called from the UARTE interrupt context.
Parameters
[in]p_instancePointer to the driver instance structure.
bool nrfx_uarte_rx_ready ( nrfx_uarte_t const *  p_instance)

Function for testing the receiver state in blocking mode.

Parameters
[in]p_instancePointer to the driver instance structure.
Return values
trueThe receiver has at least one byte of data to get.
falseThe receiver is empty.
__STATIC_INLINE uint32_t nrfx_uarte_task_address_get ( nrfx_uarte_t const *  p_instance,
nrf_uarte_task_t  task 
)

Function for getting the address of the specified UARTE task.

Parameters
[in]p_instancePointer to the driver instance structure.
[in]taskTask.
Returns
Task address.
nrfx_err_t nrfx_uarte_tx ( nrfx_uarte_t const *  p_instance,
uint8_t const *  p_data,
size_t  length 
)

Function for sending data over UARTE.

If an event handler is provided in nrfx_uarte_init() call, this function returns immediately and the handler is called when the transfer is done. Otherwise, the transfer is performed in blocking mode, that is this function returns when the transfer is finished. Blocking mode is not using interrupt so there is no context switching inside the function.

Note
Peripherals using EasyDMA (including UARTE) require the transfer buffers to be placed in the Data RAM region. If this condition is not met, this function will fail with the error code NRFX_ERROR_INVALID_ADDR.
Parameters
[in]p_instancePointer to the driver instance structure.
[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 driver checks it with assertion.
Return values
NRFX_SUCCESSInitialization was successful.
NRFX_ERROR_BUSYDriver is already transferring.
NRFX_ERROR_FORBIDDENThe transfer was aborted from a different context (blocking mode only).
NRFX_ERROR_INVALID_ADDRp_data does not point to RAM buffer.
void nrfx_uarte_tx_abort ( nrfx_uarte_t const *  p_instance)

Function for aborting any ongoing transmission.

Note
NRFX_UARTE_EVT_TX_DONE event will be generated in non-blocking mode. It will contain number of bytes sent until the abort was called. The event handler will be called from the UARTE interrupt context.
Parameters
[in]p_instancePointer to the driver instance structure.
bool nrfx_uarte_tx_in_progress ( nrfx_uarte_t const *  p_instance)

Function for checking if UARTE is currently transmitting.

Parameters
[in]p_instancePointer to the driver instance structure.
Return values
trueThe UARTE is transmitting.
falseThe UARTE is not transmitting.
void nrfx_uarte_uninit ( nrfx_uarte_t const *  p_instance)

Function for uninitializing the UARTE driver.

Parameters
[in]p_instancePointer to the driver instance structure.

Documentation feedback | Developer Zone | Subscribe | Updated