UART peripheral driver. More...
Data Structures |
|
| struct | nrfx_uart_t |
|
UART driver instance data structure.
More...
|
|
| struct | nrfx_uart_config_t |
|
Structure for UART configuration.
More...
|
|
| struct | nrfx_uart_xfer_evt_t |
|
Structure for UART transfer completion event.
More...
|
|
| struct | nrfx_uart_error_evt_t |
|
Structure for UART error event.
More...
|
|
| struct | nrfx_uart_event_t |
|
Structure for UART event.
More...
|
|
Macros |
|
| #define | NRFX_UART_INSTANCE (id) |
|
Macro for creating a UART driver instance.
More...
|
|
| #define | NRFX_UART_DEFAULT_CONFIG |
|
UART default configuration.
More...
|
|
Typedefs |
|
| typedef void(* | nrfx_uart_event_handler_t )( nrfx_uart_event_t const *p_event, void *p_context) |
|
UART interrupt event handler.
More...
|
|
Enumerations |
|
| enum | { NRFX_UART_ENABLED_COUNT } |
| enum |
nrfx_uart_evt_type_t
{
NRFX_UART_EVT_TX_DONE , NRFX_UART_EVT_RX_DONE , NRFX_UART_EVT_ERROR } |
|
Types of UART driver events.
More...
|
|
Functions |
|
| nrfx_err_t | nrfx_uart_init ( nrfx_uart_t const *p_instance, nrfx_uart_config_t const *p_config, nrfx_uart_event_handler_t event_handler) |
|
Function for initializing the UART driver.
More...
|
|
| void | nrfx_uart_uninit ( nrfx_uart_t const *p_instance) |
|
Function for uninitializing the UART driver.
More...
|
|
| __STATIC_INLINE uint32_t | nrfx_uart_task_address_get ( nrfx_uart_t const *p_instance, nrf_uart_task_t task) |
|
Function for getting the address of a specific UART task.
More...
|
|
| __STATIC_INLINE uint32_t | nrfx_uart_event_address_get ( nrfx_uart_t const *p_instance, nrf_uart_event_t event) |
|
Function for getting the address of a specific UART event.
More...
|
|
| nrfx_err_t | nrfx_uart_tx ( nrfx_uart_t const *p_instance, uint8_t const *p_data, size_t length) |
|
Function for sending data over UART.
More...
|
|
| bool | nrfx_uart_tx_in_progress ( nrfx_uart_t const *p_instance) |
|
Function for checking if UART is currently transmitting.
More...
|
|
| void | nrfx_uart_tx_abort ( nrfx_uart_t const *p_instance) |
|
Function for aborting any ongoing transmission.
More...
|
|
| nrfx_err_t | nrfx_uart_rx ( nrfx_uart_t const *p_instance, uint8_t *p_data, size_t length) |
|
Function for receiving data over UART.
More...
|
|
| bool | nrfx_uart_rx_ready ( nrfx_uart_t const *p_instance) |
|
Function for testing the receiver state in blocking mode.
More...
|
|
| void | nrfx_uart_rx_enable ( nrfx_uart_t const *p_instance) |
|
Function for enabling the receiver.
More...
|
|
| void | nrfx_uart_rx_disable ( nrfx_uart_t const *p_instance) |
|
Function for disabling the receiver.
More...
|
|
| void | nrfx_uart_rx_abort ( nrfx_uart_t const *p_instance) |
|
Function for aborting any ongoing reception.
More...
|
|
| uint32_t | nrfx_uart_errorsrc_get ( nrfx_uart_t const *p_instance) |
|
Function for reading error source mask. Mask contains values from
nrf_uart_error_mask_t
.
More...
|
|
| void | nrfx_uart_0_irq_handler (void) |
Detailed Description
UART peripheral driver.
Macro Definition Documentation
| #define NRFX_UART_DEFAULT_CONFIG |
UART default configuration.
| #define NRFX_UART_INSTANCE | ( | id | ) |
Macro for creating a UART driver instance.
Typedef Documentation
| typedef void(* nrfx_uart_event_handler_t)( nrfx_uart_event_t const *p_event, void *p_context) |
UART 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 interrupt handler, set on initialization.
Enumeration Type Documentation
| enum nrfx_uart_evt_type_t |
Function Documentation
| uint32_t nrfx_uart_errorsrc_get | ( | nrfx_uart_t const * | p_instance | ) |
Function for reading error source mask. Mask contains values from nrf_uart_error_mask_t .
- Note
- Function should be used in 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.
- Return values
-
Mask of reported errors.
| __STATIC_INLINE uint32_t nrfx_uart_event_address_get | ( | nrfx_uart_t const * | p_instance , |
| nrf_uart_event_t | event | ||
| ) |
Function for getting the address of a specific UART event.
- Parameters
-
[in] p_instance Pointer to the driver instance structure. [in] event Event.
- Returns
- Event address.
| nrfx_err_t nrfx_uart_init | ( | nrfx_uart_t const * | p_instance , |
| nrfx_uart_config_t const * | p_config , | ||
| nrfx_uart_event_handler_t | event_handler | ||
| ) |
Function for initializing the UART driver.
This function configures and enables UART. After this function GPIO pins are controlled by UART.
- Parameters
-
[in] p_instance Pointer to the driver instance structure. [in] p_config Pointer to the structure with initial configuration. [in] event_handler Event handler provided by the user. If not provided driver works in blocking mode.
- Return values
-
NRFX_SUCCESS If initialization was successful. NRFX_ERROR_INVALID_STATE If driver is already initialized. NRFX_ERROR_BUSY If 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_err_t nrfx_uart_rx | ( | nrfx_uart_t const * | p_instance , |
| uint8_t * | p_data , | ||
| size_t | length | ||
| ) |
Function for receiving data over UART.
If an event handler was provided in the nrfx_uart_init() call, this function returns immediately and the handler is called when the transfer is done. Otherwise, the transfer is performed in blocking mode, i.e. 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.
- Parameters
-
[in] p_instance Pointer to the driver instance structure. [in] p_data Pointer to data. [in] length Number of bytes to receive.
- Return values
-
NRFX_SUCCESS If initialization was successful. NRFX_ERROR_BUSY If the driver is already receiving (and the secondary buffer has already been set in non-blocking mode). NRFX_ERROR_FORBIDDEN If the transfer was aborted from a different context (blocking mode only, also see nrfx_uart_rx_disable ). NRFX_ERROR_INTERNAL If UART peripheral reported an error.
| void nrfx_uart_rx_abort | ( | nrfx_uart_t const * | p_instance | ) |
Function for aborting any ongoing reception.
- Note
- NRFX_UART_EVT_TX_DONE event will be generated in non-blocking mode. It will contain number of bytes received until abort was called. The event handler will be called from the UART interrupt context.
- Parameters
-
[in] p_instance Pointer to the driver instance structure.
| void nrfx_uart_rx_disable | ( | nrfx_uart_t const * | p_instance | ) |
Function for disabling the receiver.
This function must be called to close the receiver after it has been explicitly enabled by
- See Also
- nrfx_uart_rx_enable .
- Parameters
-
[in] p_instance Pointer to the driver instance structure.
| void nrfx_uart_rx_enable | ( | nrfx_uart_t const * | p_instance | ) |
Function for enabling the receiver.
UART has a 6-byte-long RX FIFO and it is used to store incoming data. If a user does not call the UART receive function before the FIFO is filled, an overrun error will appear. The receiver must be explicitly closed by the user
- See Also
- nrfx_uart_rx_disable .
- Parameters
-
[in] p_instance Pointer to the driver instance structure.
| bool nrfx_uart_rx_ready | ( | nrfx_uart_t const * | p_instance | ) |
Function for testing the receiver state in blocking mode.
- Parameters
-
[in] p_instance Pointer to the driver instance structure.
- Return values
-
true If the receiver has at least one byte of data to get. false If the receiver is empty.
| __STATIC_INLINE uint32_t nrfx_uart_task_address_get | ( | nrfx_uart_t const * | p_instance , |
| nrf_uart_task_t | task | ||
| ) |
Function for getting the address of a specific UART task.
- Parameters
-
[in] p_instance Pointer to the driver instance structure. [in] task Task.
- Returns
- Task address.
| nrfx_err_t nrfx_uart_tx | ( | nrfx_uart_t const * | p_instance , |
| uint8_t const * | p_data , | ||
| size_t | length | ||
| ) |
Function for sending data over UART.
If an event handler was provided in nrfx_uart_init() call, this function returns immediately and the handler is called when the transfer is done. Otherwise, the transfer is performed in blocking mode, i.e. this function returns when the transfer is finished. Blocking mode is not using interrupt so there is no context switching inside the function.
- Parameters
-
[in] p_instance Pointer to the driver instance structure. [in] p_data Pointer to data. [in] length Number of bytes to send.
- Return values
-
NRFX_SUCCESS If initialization was successful. NRFX_ERROR_BUSY If driver is already transferring. NRFX_ERROR_FORBIDDEN If the transfer was aborted from a different context (blocking mode only).
| void nrfx_uart_tx_abort | ( | nrfx_uart_t const * | p_instance | ) |
Function for aborting any ongoing transmission.
- Note
- NRFX_UART_EVT_TX_DONE event will be generated in non-blocking mode. It will contain number of bytes sent until abort was called. The event handler will be called from the function context.
- Parameters
-
[in] p_instance Pointer to the driver instance structure.
| bool nrfx_uart_tx_in_progress | ( | nrfx_uart_t const * | p_instance | ) |
Function for checking if UART is currently transmitting.
- Parameters
-
[in] p_instance Pointer to the driver instance structure.
- Return values
-
true If UART is transmitting. false If UART is not transmitting.
| void nrfx_uart_uninit | ( | nrfx_uart_t const * | p_instance | ) |
Function for uninitializing the UART driver.
- Parameters
-
[in] p_instance Pointer to the driver instance structure.