UART driver. More...
Data Structures | |
struct | nrf_drv_uart_config_t |
Structure for UART configuration. More... | |
struct | nrf_drv_uart_xfer_evt_t |
Structure for UART transfer completion event. More... | |
struct | nrf_drv_uart_error_evt_t |
Structure for UART error event. More... | |
struct | nrf_drv_uart_event_t |
Structure for UART event. More... | |
Macros | |
#define | NRF_DRV_UART_DEFAULT_CONFIG |
UART default configuration. More... | |
Typedefs | |
typedef void(* | nrf_uart_event_handler_t )(nrf_drv_uart_event_t *p_event, void *p_context) |
UART interrupt event handler. More... | |
Enumerations | |
enum | nrf_drv_uart_evt_type_t { NRF_DRV_UART_EVT_TX_DONE, NRF_DRV_UART_EVT_RX_DONE, NRF_DRV_UART_EVT_ERROR } |
Types of UART driver events. More... | |
Functions | |
ret_code_t | nrf_drv_uart_init (nrf_drv_uart_config_t const *p_config, nrf_uart_event_handler_t event_handler) |
Function for initializing the UART driver. More... | |
void | nrf_drv_uart_uninit (void) |
Function for uninitializing the UART driver. | |
__STATIC_INLINE uint32_t | nrf_drv_uart_task_address_get (nrf_uart_task_t task) |
Function for getting the address of a specific UART task. More... | |
__STATIC_INLINE uint32_t | nrf_drv_uart_event_address_get (nrf_uart_event_t event) |
Function for getting the address of a specific UART event. More... | |
ret_code_t | nrf_drv_uart_tx (uint8_t const *const p_data, uint8_t length) |
Function for sending data over UART. More... | |
void | nrf_drv_uart_tx_abort (void) |
Function for aborting any ongoing transmission. More... | |
ret_code_t | nrf_drv_uart_rx (uint8_t *p_data, uint8_t length) |
Function for receiving data over UART. More... | |
void | nrf_drv_uart_rx_enable (void) |
Function for enabling receiver. More... | |
void | nrf_drv_uart_rx_disable (void) |
Function for disabling receiver. More... | |
void | nrf_drv_uart_rx_abort (void) |
Function for aborting any ongoing reception. More... | |
uint32_t | nrf_drv_uart_errorsrc_get (void) |
Function for reading error source mask. Mask contains values from nrf_uart_error_mask_t. More... | |
UART driver.
#define NRF_DRV_UART_DEFAULT_CONFIG |
UART default configuration.
typedef void(* nrf_uart_event_handler_t)(nrf_drv_uart_event_t *p_event, void *p_context) |
UART interrupt event handler.
[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. |
uint32_t nrf_drv_uart_errorsrc_get | ( | void | ) |
Function for reading error source mask. Mask contains values from nrf_uart_error_mask_t.
Mask | of reported errors. |
__STATIC_INLINE uint32_t nrf_drv_uart_event_address_get | ( | nrf_uart_event_t | event | ) |
Function for getting the address of a specific UART event.
[in] | event | Event. |
Event | address. |
ret_code_t nrf_drv_uart_init | ( | nrf_drv_uart_config_t const * | p_config, |
nrf_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.
[in] | p_config | Initial configuration. Default configuration used if NULL. |
[in] | event_handler | Event handler provided by the user. If not provided driver works in blocking mode. |
NRF_SUCCESS | If initialization was successful. |
NRF_ERROR_INVALID_STATE | If driver is already initialized. |
ret_code_t nrf_drv_uart_rx | ( | uint8_t * | p_data, |
uint8_t | length | ||
) |
Function for receiving data over UART.
If an event handler was provided in nrf_drv_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.
[in] | p_data | Pointer to data. |
[in] | length | Number of bytes to receive. |
NRF_SUCCESS | If initialization was successful. |
NRF_ERROR_BUSY | If driver is already receiving. |
NRF_ERROR_INVALID_ADDR | If p_data does not point to RAM buffer (UARTE only). |
NRF_ERROR_FORBIDDEN | If transfer was aborted (blocking mode only). |
void nrf_drv_uart_rx_abort | ( | void | ) |
Function for aborting any ongoing reception.
void nrf_drv_uart_rx_disable | ( | void | ) |
Function for disabling receiver.
Function must be called to close the receiver after it has been explicitly enabled by
void nrf_drv_uart_rx_enable | ( | void | ) |
Function for enabling receiver.
UART has 6 byte long RX FIFO and it will be used to store incoming data. If user will not call UART receive function before FIFO is filled, overrun error will encounter. Enabling receiver without specifying RX buffer is supported only in UART mode (without Easy DMA). Receiver must be explicitly closed by the user
__STATIC_INLINE uint32_t nrf_drv_uart_task_address_get | ( | nrf_uart_task_t | task | ) |
Function for getting the address of a specific UART task.
[in] | task | Task. |
Task | address. |
ret_code_t nrf_drv_uart_tx | ( | uint8_t const *const | p_data, |
uint8_t | length | ||
) |
Function for sending data over UART.
If an event handler was provided in nrf_drv_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.
[in] | p_data | Pointer to data. |
[in] | length | Number of bytes to send. |
NRF_SUCCESS | If initialization was successful. |
NRF_ERROR_BUSY | If driver is already transferring. |
NRF_ERROR_INVALID_ADDR | If p_data does not point to RAM buffer (UARTE only). |
NRF_ERROR_FORBIDDEN | If transfer was aborted (blocking mode only). |
void nrf_drv_uart_tx_abort | ( | void | ) |
Function for aborting any ongoing transmission.