UARTE peripheral driver.
More...
UARTE peripheral driver.
◆ NRFX_UARTE_DEFAULT_CONFIG
#define NRFX_UARTE_DEFAULT_CONFIG |
( |
|
_pin_tx, |
|
|
|
_pin_rx |
|
) |
| |
Value:{ \
.pseltxd = _pin_tx, \
.pselrxd = _pin_rx, \
.pselcts = NRF_UARTE_PSEL_DISCONNECTED, \
.pselrts = NRF_UARTE_PSEL_DISCONNECTED, \
.p_context = NULL, \
.interrupt_priority = NRFX_UARTE_DEFAULT_CONFIG_IRQ_PRIORITY, \
.hal_cfg = { \
NRFX_UARTE_DEFAULT_EXTENDED_STOP_CONFIG \
NRFX_UARTE_DEFAULT_EXTENDED_PARITYTYPE_CONFIG \
} \
}
@ NRF_UARTE_HWFC_DISABLED
Hardware flow control disabled.
Definition: nrf_uarte.h:122
@ NRF_UARTE_BAUDRATE_115200
115200 baud.
Definition: nrf_uarte.h:95
@ NRF_UARTE_PARITY_EXCLUDED
Parity excluded.
Definition: nrf_uarte.h:115
UARTE driver default configuration.
This configuration sets up UARTE with the following options:
- hardware flow control disabled
- no parity bit
- one stop bit
- baudrate: 115200
- Parameters
-
[in] | _pin_tx | TX pin. |
[in] | _pin_rx | RX pin. |
◆ NRFX_UARTE_INST_HANDLER_GET
#define NRFX_UARTE_INST_HANDLER_GET |
( |
|
idx | ) |
NRFX_CONCAT_3(nrfx_uarte_, idx, _irq_handler) |
Macro returning UARTE interrupt handler.
param[in] idx UARTE index.
- Returns
- Interrupt handler.
◆ NRFX_UARTE_INSTANCE
#define NRFX_UARTE_INSTANCE |
( |
|
id | ) |
|
Value:{ \
}
#define NRFX_CONCAT_2(p1, p2)
Macro for concatenating two tokens in macro expansion.
Definition: nrfx_common.h:85
#define NRFX_CONCAT_3(p1, p2, p3)
Macro for concatenating three tokens in macro expansion.
Definition: nrfx_common.h:106
Macro for creating a UARTE driver instance.
◆ nrfx_uarte_event_handler_t
typedef void(* nrfx_uarte_event_handler_t) (nrfx_uarte_event_t const *p_event, void *p_context) |
UARTE interrupt event handler.
- Parameters
-
[in] | p_event | Pointer to event structure. Event is allocated on the stack so it is available only within the context of the event handler. |
[in] | p_context | Context passed to the interrupt handler, set on initialization. |
◆ nrfx_uarte_evt_type_t
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.
|
◆ nrfx_uarte_errorsrc_get()
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_instance | Pointer to the driver instance structure. |
- Returns
- Mask of reported errors.
◆ nrfx_uarte_event_address_get()
Function for getting the address of the specified UARTE event.
- Parameters
-
[in] | p_instance | Pointer to the driver instance structure. |
[in] | event | Event. |
- Returns
- Event address.
◆ nrfx_uarte_init()
Function for initializing the UARTE driver.
This function configures and enables UARTE. After this function GPIO pins are controlled by UARTE.
- Parameters
-
[in] | p_instance | Pointer to the driver instance structure. |
[in] | p_config | Pointer to the structure with the initial configuration. |
[in] | event_handler | Event handler provided by the user. If not provided driver works in blocking mode. |
- Return values
-
NRFX_SUCCESS | Initialization was successful. |
NRFX_ERROR_INVALID_STATE | Driver is already initialized. |
NRFX_ERROR_BUSY | Some other peripheral with the same instance ID is already in use. This is possible only if Peripheral Resource Sharing (PRS) module is enabled. |
◆ nrfx_uarte_rx()
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.
- Warning
- When the double-buffering feature is used and the UARTE interrupt is processed with a delay (for example, due to a higher priority interrupt) long enough for both buffers to get filled completely, the event handler will be invoked only once, to notify that the first buffer has been filled. This is because from hardware perspective it is impossible to deduce in such case if the second buffer was also filled completely or not. To prevent this from happening, keep the UARTE interrupt latency low or use large enough reception buffers.
- Parameters
-
[in] | p_instance | Pointer to the driver instance structure. |
[in] | p_data | Pointer to data. |
[in] | length | Number 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_SUCCESS | Initialization is successful. |
NRFX_ERROR_BUSY | The driver is already receiving (and the secondary buffer has already been set in non-blocking mode). |
NRFX_ERROR_FORBIDDEN | The transfer is aborted from a different context (blocking mode only). |
NRFX_ERROR_INTERNAL | The UARTE peripheral reports an error. |
NRFX_ERROR_INVALID_ADDR | p_data does not point to RAM buffer. |
◆ nrfx_uarte_rx_abort()
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.
- Warning
- When the double-buffering feature is used and the UARTE interrupt is processed with a delay (for example, due to a higher priority interrupt) long enough for the first buffer to be filled completely, the event handler will be supplied with the pointer to the first buffer and the number of bytes received in the second buffer. This is because from hardware perspective it is impossible to deduce the reception of which buffer has been aborted. To prevent this from happening, keep the UARTE interrupt latency low or use large enough reception buffers.
- Parameters
-
[in] | p_instance | Pointer to the driver instance structure. |
◆ nrfx_uarte_rx_ready()
Function for testing the receiver state in blocking mode.
- Parameters
-
[in] | p_instance | Pointer to the driver instance structure. |
- Return values
-
true | The receiver has at least one byte of data to get. |
false | The receiver is empty. |
◆ nrfx_uarte_task_address_get()
Function for getting the address of the specified UARTE task.
- Parameters
-
[in] | p_instance | Pointer to the driver instance structure. |
[in] | task | Task. |
- Returns
- Task address.
◆ nrfx_uarte_tx()
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_instance | Pointer to the driver instance structure. |
[in] | p_data | Pointer to data. |
[in] | length | Number 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_SUCCESS | Initialization was successful. |
NRFX_ERROR_BUSY | Driver is already transferring. |
NRFX_ERROR_FORBIDDEN | The transfer was aborted from a different context (blocking mode only). |
NRFX_ERROR_INVALID_ADDR | p_data does not point to RAM buffer. |
◆ nrfx_uarte_tx_abort()
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_instance | Pointer to the driver instance structure. |
◆ nrfx_uarte_tx_in_progress()
bool nrfx_uarte_tx_in_progress |
( |
nrfx_uarte_t const * |
p_instance | ) |
|
Function for checking if UARTE is currently transmitting.
- Parameters
-
[in] | p_instance | Pointer to the driver instance structure. |
- Return values
-
true | The UARTE is transmitting. |
false | The UARTE is not transmitting. |
◆ nrfx_uarte_uninit()
Function for uninitializing the UARTE driver.
- Parameters
-
[in] | p_instance | Pointer to the driver instance structure. |