![]() |
nrfx 4.5.0
|
UARTE peripheral driver. More...
Topics | |
| UARTE peripheral driver configuration | |
| Flags used for RX. | |
| Flags used for TX. | |
| Flags used for TX event. | |
Data Structures | |
| struct | nrfx_uarte_rx_cache_t |
| Structure used internally to handle reception through cache buffers. More... | |
| struct | nrfx_uarte_rx_evt_t |
| Structure for NRFX_UARTE_EVT_RX_DONE event. More... | |
| struct | nrfx_uarte_tx_evt_t |
| Structure for the NRFX_UARTE_EVT_TX_DONE event. More... | |
| struct | nrfx_uarte_error_evt_t |
| Structure for the NRFX_UARTE_EVT_ERROR. More... | |
| struct | nrfx_uarte_rx_disabled_evt_t |
| Structure for the NRFX_UARTE_EVT_RX_DISABLED. More... | |
| struct | nrfx_uarte_event_t |
| Structure for UARTE event. More... | |
| struct | nrfx_uarte_t |
| Structure for the UARTE driver instance. More... | |
| struct | nrfx_uarte_config_t |
| Structure for the UARTE configuration. More... | |
Macros | |
| #define | NRFX_UARTE_INSTANCE(reg) |
| Macro for creating a UARTE driver instance. | |
| #define | NRFX_UARTE_DEFAULT_CONFIG(_pin_tx, _pin_rx) |
| UARTE driver default configuration. | |
Typedefs | |
| typedef void(* | nrfx_uarte_event_handler_t) (nrfx_uarte_event_t const *p_event, void *p_context) |
| UARTE interrupt event handler. | |
Enumerations | |
| enum | nrfx_uarte_event_type_t { NRFX_UARTE_EVT_TX_DONE , NRFX_UARTE_EVT_RX_DONE , NRFX_UARTE_EVT_ERROR , NRFX_UARTE_EVT_RX_BUF_REQUEST , NRFX_UARTE_EVT_RX_DISABLED , NRFX_UARTE_EVT_RX_BUF_TOO_LATE , NRFX_UARTE_EVT_RX_BYTE , NRFX_UARTE_EVT_TRIGGER } |
| Types of UARTE driver events. More... | |
Functions | |
| int | nrfx_uarte_init (nrfx_uarte_t *p_instance, nrfx_uarte_config_t const *p_config, nrfx_uarte_event_handler_t event_handler) |
| Function for initializing the UARTE driver. | |
| int | nrfx_uarte_reconfigure (nrfx_uarte_t *p_instance, nrfx_uarte_config_t const *p_config) |
| Function for reconfiguring the UARTE driver. | |
| void | nrfx_uarte_uninit (nrfx_uarte_t *p_instance) |
| Function for uninitializing the UARTE driver. | |
| bool | nrfx_uarte_init_check (nrfx_uarte_t const *p_instance) |
| Function for checking if the UARTE driver instance is initialized. | |
| NRFX_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. | |
| NRFX_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. | |
| int | nrfx_uarte_tx (nrfx_uarte_t *p_instance, uint8_t const *p_data, size_t length, uint32_t flags) |
| Function for sending data over UARTE. | |
| bool | nrfx_uarte_tx_in_progress (nrfx_uarte_t const *p_instance) |
| Function for checking if UARTE is currently transmitting. | |
| int | nrfx_uarte_tx_abort (nrfx_uarte_t *p_instance, bool sync) |
| Function for aborting any ongoing transmission. | |
| int | nrfx_uarte_rx_enable (nrfx_uarte_t *p_instance, uint32_t flags) |
| Function for enabling the receiver. | |
| int | nrfx_uarte_rx_buffer_set (nrfx_uarte_t *p_instance, uint8_t *p_data, size_t length) |
| Function for providing reception buffer. | |
| int | nrfx_uarte_rx_ready (nrfx_uarte_t const *p_instance, size_t *p_rx_amount) |
| Function for testing the receiver state in blocking mode. | |
| int | nrfx_uarte_rx_abort (nrfx_uarte_t *p_instance, bool disable_all, bool sync) |
| Function for aborting any ongoing reception. | |
| uint32_t | nrfx_uarte_errorsrc_get (nrfx_uarte_t const *p_instance) |
| Function for reading error source mask. | |
| bool | nrfx_uarte_rx_new_data_check (nrfx_uarte_t *p_instance) |
| Function for checking if there was new RX data since the last check. | |
| NRFX_STATIC_INLINE void | nrfx_uarte_rxdrdy_enable (nrfx_uarte_t const *p_instance) |
| Function for enabling NRFX_UARTE_EVT_RX_BYTE event. | |
| NRFX_STATIC_INLINE void | nrfx_uarte_rxdrdy_disable (nrfx_uarte_t const *p_instance) |
| Function for disabling NRFX_UARTE_EVT_RX_BYTE event. | |
| int | nrfx_uarte_int_trigger (nrfx_uarte_t *p_instance) |
| Function for triggering UARTE interrupt. | |
| void | nrfx_uarte_irq_handler (nrfx_uarte_t *p_instance) |
| Driver interrupt handler. | |
UARTE peripheral driver.
| #define NRFX_UARTE_DEFAULT_CONFIG | ( | _pin_tx, | |
| _pin_rx ) |
UARTE driver default configuration.
This configuration sets up UARTE with the following options:
| [in] | _pin_tx | TX pin. |
| [in] | _pin_rx | RX pin. |
| #define NRFX_UARTE_INSTANCE | ( | reg | ) |
Macro for creating a UARTE driver instance.
| typedef void(* nrfx_uarte_event_handler_t) (nrfx_uarte_event_t const *p_event, void *p_context) |
UARTE 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 the interrupt handler, set on initialization. |
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_EVT_RX_BUF_REQUEST | Request for a RX buffer. |
| NRFX_UARTE_EVT_RX_DISABLED | Receiver is disabled. |
| NRFX_UARTE_EVT_RX_BUF_TOO_LATE | RX buffer request handled too late. |
| NRFX_UARTE_EVT_RX_BYTE | Byte was received. |
| NRFX_UARTE_EVT_TRIGGER | Result of nrfx_uarte_int_trigger. |
| 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.
| [in] | p_instance | Pointer to the driver instance structure. |
| NRFX_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.
| [in] | p_instance | Pointer to the driver instance structure. |
| [in] | event | Event. |
| int nrfx_uarte_init | ( | nrfx_uarte_t * | 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 UARTE but peripheral is kept disabled to reduce power consumption.
| [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. |
| 0 | Initialization was successful. |
| -EALREADY | The driver is already initialized. |
| -EINVAL | Invalid configuration. |
| -EBUSY | Some other peripheral with the same instance ID is already in use. This is possible only if Peripheral Resource Sharing (PRS) module is enabled. |
| -ECANCELED | Peripheral was not properly deinitialized after use. |
| bool nrfx_uarte_init_check | ( | nrfx_uarte_t const * | p_instance | ) |
Function for checking if the UARTE driver instance is initialized.
| [in] | p_instance | Pointer to the driver instance structure. |
| true | Instance is already initialized. |
| false | Instance is not initialized. |
| int nrfx_uarte_int_trigger | ( | nrfx_uarte_t * | p_instance | ) |
Function for triggering UARTE interrupt.
Function can be used to jump into UARTE interrupt context. User handler is called with the event NRFX_UARTE_EVT_TRIGGER.
| [in] | p_instance | Pointer to the driver instance structure. |
| 0 | If interrupt is successfully triggered. |
| -EPERM | Failure. User handler is not configured. |
| void nrfx_uarte_irq_handler | ( | nrfx_uarte_t * | p_instance | ) |
Driver interrupt handler.
| [in] | p_instance | Pointer to the driver instance structure. |
| int nrfx_uarte_reconfigure | ( | nrfx_uarte_t * | p_instance, |
| nrfx_uarte_config_t const * | p_config ) |
Function for reconfiguring the UARTE driver.
| [in] | p_instance | Pointer to the driver instance structure. |
| [in] | p_config | Pointer to the structure with the configuration. |
| 0 | Reconfiguration was successful. |
| -EBUSY | The driver is during transfer. |
| -EINPROGRESS | The driver is uninitialized. |
| -ECANCELED | Peripheral was not properly deinitialized after use. |
| int nrfx_uarte_rx_abort | ( | nrfx_uarte_t * | p_instance, |
| bool | disable_all, | ||
| bool | sync ) |
Function for aborting any ongoing reception.
| [in] | p_instance | Pointer to the driver instance structure. |
| [in] | disable_all | If true, UARTE is stopped. If false and there is a second RX buffer provided, only the first transfer is stopped. |
| [in] | sync | If true, receiver is disabled synchronously. |
| 0 | Successfully initiate disabling or disabled (synchronous mode). |
| -EINPROGRESS | Receiver was not enabled. |
| int nrfx_uarte_rx_buffer_set | ( | nrfx_uarte_t * | p_instance, |
| uint8_t * | p_data, | ||
| size_t | length ) |
Function for providing reception buffer.
The function should be called as a response to the NRFX_UARTE_EVT_RX_BUF_REQUEST event. If the function is called before enabling the receiver, the first buffer is configured. If the function is called and there is no active buffer but the receiver is enabled but not started, it starts reception.
| [in] | p_instance | Pointer to the driver instance structure. |
| [in] | p_data | Pointer to a buffer. |
| [in] | length | Buffer length. |
| 0 | Buffer successfully set. |
| -EINPROGRESS | Buffer provided without pending request. |
| -EACCES | No cache buffer provided or blocking mode is used, transfer cannot be handled. |
| -EBUSY | Previous buffer is still in use. |
| -EPERM | Provided uncached buffer after providing cached one. |
| int nrfx_uarte_rx_enable | ( | nrfx_uarte_t * | p_instance, |
| uint32_t | flags ) |
Function for enabling the receiver.
The event handler will be called from the caller context with the NRFX_UARTE_EVT_RX_BUF_REQUEST event. The user may respond and provide a buffer using nrfx_uarte_rx_buffer_set. An error is returned if buffer is not provided. After that, the receiver is started and another NRFX_UARTE_EVT_RX_BUF_REQUEST is generated. If a new buffer is not provided, then the receiver is disabled once the first buffer becomes full. If a new buffer is provided, then the receiver will seamlessly switch to a new buffer (using a hardware shortcut).
| [in] | p_instance | Pointer to the driver instance structure. |
| [in] | flags | Option flags. See Flags used for RX.. |
| 0 | Receiver successfully enabled. |
| -EBUSY | When receiver is already enabled. |
| -ENOMEM | When buffer was not provided. |
| bool nrfx_uarte_rx_new_data_check | ( | nrfx_uarte_t * | p_instance | ) |
Function for checking if there was new RX data since the last check.
Function checks NRF_UARTE_EVENT_RXDRDY event and clears it if it was set.
| [in] | p_instance | Pointer to the driver instance structure. |
| true | At least one byte was received since the last check. |
| false | No new data was received since the last check. |
| int nrfx_uarte_rx_ready | ( | nrfx_uarte_t const * | p_instance, |
| size_t * | p_rx_amount ) |
Function for testing the receiver state in blocking mode.
| [in] | p_instance | Pointer to the driver instance structure. |
| [out] | p_rx_amount | Pointer to the variable to be filled with the number of received bytes. Can be NULL. |
| 0 | The receiving operation is completed. |
| -EBUSY | The receiver did not complete the operation. |
| -EALREADY | The receiver is disabled. |
| -EPERM | Operation is not supporting in the current configuration. |
| NRFX_STATIC_INLINE void nrfx_uarte_rxdrdy_disable | ( | nrfx_uarte_t const * | p_instance | ) |
Function for disabling NRFX_UARTE_EVT_RX_BYTE event.
The function disables the RXDRDY hardware event. See the nrfx_uarte_rxdrdy_enable for more details. The event can be disabled at any time.
| [in] | p_instance | Pointer to the driver instance structure. |
| NRFX_STATIC_INLINE void nrfx_uarte_rxdrdy_enable | ( | nrfx_uarte_t const * | p_instance | ) |
Function for enabling NRFX_UARTE_EVT_RX_BYTE event.
The function enables the NRF_UARTE_EVENT_RXDRDY hardware event which is generated whenever a byte is received in RXD registers. The event indicates only that data is received, hence it must not be used yet because it may not be present yet in the RAM buffer handled by the EasyDMA. The event can be used only to detect a receiver activity. The event can be enabled at any time. Enabling it may increase the number of interrupts (after each received byte).
| [in] | p_instance | Pointer to the driver instance structure. |
| NRFX_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.
| [in] | p_instance | Pointer to the driver instance structure. |
| [in] | task | Task. |
| int nrfx_uarte_tx | ( | nrfx_uarte_t * | p_instance, |
| uint8_t const * | p_data, | ||
| size_t | length, | ||
| uint32_t | flags ) |
Function for sending data over UARTE.
If an event handler is provided in nrfx_uarte_init() call, this function returns immediately (unless special flags are used) 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.
| [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. |
| [in] | flags | Option flags. See Flags used for TX.. |
| 0 | Initialization was successful. |
| -EBUSY | Driver is busy transferring the data. |
| -EPERM | The transfer was aborted from a different context (blocking mode only) or transfer cannot be performed due to driver state, configuration or transfer parameters. |
| -EACCES | p_data does not point to RAM buffer and cache buffer is not provided or attempted to use non DMA buffer with linked transfer (see NRFX_UARTE_TX_LINK). |
| -E2BIG | Flag NRFX_UARTE_TX_EARLY_RETURN is used but length exceeds internal buffer size. |
| -ECANCELED | Peripheral was not properly deinitialized after use. |
| int nrfx_uarte_tx_abort | ( | nrfx_uarte_t * | p_instance, |
| bool | sync ) |
Function for aborting any ongoing transmission.
| [in] | p_instance | Pointer to the driver instance structure. |
| [in] | sync | If true operation is synchronous. Transmitter is stopped upon function return and no event is generated. |
| 0 | Successfully initiated abort or when transmitter synchronously stopped. |
| -EINPROGRESS | Attempt to asynchronously abort when no transfer is active. |
| bool nrfx_uarte_tx_in_progress | ( | nrfx_uarte_t const * | p_instance | ) |
Function for checking if UARTE is currently transmitting.
| [in] | p_instance | Pointer to the driver instance structure. |
| true | The UARTE is transmitting. |
| false | The UARTE is not transmitting. |
| void nrfx_uarte_uninit | ( | nrfx_uarte_t * | p_instance | ) |
Function for uninitializing the UARTE driver.
| [in] | p_instance | Pointer to the driver instance structure. |