UART HAL

group nrf_uart_hal

Hardware access layer for managing the UART peripheral.

Defines

NRF_UART_PSEL_DISCONNECTED

Pin disconnected value.

Enums

enum nrf_uart_task_t

UART tasks.

Values:

enumerator NRF_UART_TASK_STARTRX

Task for starting reception.

enumerator NRF_UART_TASK_STOPRX

Task for stopping reception.

enumerator NRF_UART_TASK_STARTTX

Task for starting transmission.

enumerator NRF_UART_TASK_STOPTX

Task for stopping transmission.

enumerator NRF_UART_TASK_SUSPEND

Task for suspending UART.

enum nrf_uart_event_t

UART events.

Values:

enumerator NRF_UART_EVENT_CTS

Event from CTS line activation.

enumerator NRF_UART_EVENT_NCTS

Event from CTS line deactivation.

enumerator NRF_UART_EVENT_RXDRDY

Event from data ready in RXD.

enumerator NRF_UART_EVENT_TXDRDY

Event from data sent from TXD.

enumerator NRF_UART_EVENT_ERROR

Event from error detection.

enumerator NRF_UART_EVENT_RXTO

Event from receiver timeout.

enum nrf_uart_int_mask_t

UART interrupts.

Values:

enumerator NRF_UART_INT_MASK_CTS

CTS line activation interrupt.

enumerator NRF_UART_INT_MASK_NCTS

CTS line deactivation interrupt.

enumerator NRF_UART_INT_MASK_RXDRDY

Data ready in RXD interrupt.

enumerator NRF_UART_INT_MASK_TXDRDY

Data sent from TXD interrupt.

enumerator NRF_UART_INT_MASK_ERROR

Error detection interrupt.

enumerator NRF_UART_INT_MASK_RXTO

Receiver timeout interrupt.

enum nrf_uart_baudrate_t

Baudrates supported by UART.

Values:

enumerator NRF_UART_BAUDRATE_1200

1200 baud.

enumerator NRF_UART_BAUDRATE_2400

2400 baud.

enumerator NRF_UART_BAUDRATE_4800

4800 baud.

enumerator NRF_UART_BAUDRATE_9600

9600 baud.

enumerator NRF_UART_BAUDRATE_14400

14400 baud.

enumerator NRF_UART_BAUDRATE_19200

19200 baud.

enumerator NRF_UART_BAUDRATE_28800

28800 baud.

enumerator NRF_UART_BAUDRATE_31250

31250 baud.

enumerator NRF_UART_BAUDRATE_38400

38400 baud.

enumerator NRF_UART_BAUDRATE_56000

56000 baud.

enumerator NRF_UART_BAUDRATE_57600

57600 baud.

enumerator NRF_UART_BAUDRATE_76800

76800 baud.

enumerator NRF_UART_BAUDRATE_115200

115200 baud.

enumerator NRF_UART_BAUDRATE_230400

230400 baud.

enumerator NRF_UART_BAUDRATE_250000

250000 baud.

enumerator NRF_UART_BAUDRATE_460800

460800 baud.

enumerator NRF_UART_BAUDRATE_921600

921600 baud.

enumerator NRF_UART_BAUDRATE_1000000

1000000 baud.

enum nrf_uart_error_mask_t

Types of UART error masks.

Values:

enumerator NRF_UART_ERROR_OVERRUN_MASK

Overrun error.

enumerator NRF_UART_ERROR_PARITY_MASK

Parity error.

enumerator NRF_UART_ERROR_FRAMING_MASK

Framing error.

enumerator NRF_UART_ERROR_BREAK_MASK

Break error.

enum nrf_uart_parity_t

Types of UART parity modes.

Values:

enumerator NRF_UART_PARITY_EXCLUDED

Parity excluded.

enumerator NRF_UART_PARITY_INCLUDED

Parity included.

enum nrf_uart_hwfc_t

Types of UART flow control modes.

Values:

enumerator NRF_UART_HWFC_DISABLED

Hardware flow control disabled.

enumerator NRF_UART_HWFC_ENABLED

Hardware flow control enabled.

enum nrf_uart_stop_t

Types of UART stop bit modes.

Values:

enumerator NRF_UART_STOP_ONE

One stop bit.

enumerator NRF_UART_STOP_TWO

Two stop bits.

enum nrf_uart_paritytype_t

Types of UART parity types.

Values:

enumerator NRF_UART_PARITYTYPE_EVEN

Parity even.

enumerator NRF_UART_PARITYTYPE_ODD

Parity odd.

Functions

NRF_STATIC_INLINE void nrf_uart_event_clear(NRF_UART_Type *p_reg, nrf_uart_event_t event)

Function for clearing the specified UART event.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

  • event[in] Event to clear.

NRF_STATIC_INLINE bool nrf_uart_event_check(NRF_UART_Type const *p_reg, nrf_uart_event_t event)

Function for retrieving the state of the UART event.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

  • event[in] Event to be checked.

Return values:
  • true – The event has been generated.

  • false – The event has not been generated.

NRF_STATIC_INLINE uint32_t nrf_uart_event_address_get(NRF_UART_Type const *p_reg, nrf_uart_event_t event)

Function for returning the address of the specified UART event register.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

  • event[in] Desired event.

Returns:

Address of the specified event register.

NRF_STATIC_INLINE void nrf_uart_int_enable(NRF_UART_Type *p_reg, uint32_t mask)

Function for enabling the specified interrupt.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

  • mask[in] Mask of interrupts to be enabled.

NRF_STATIC_INLINE uint32_t nrf_uart_int_enable_check(NRF_UART_Type const *p_reg, uint32_t mask)

Function for checking if the specified interrupts are enabled.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

  • mask[in] Mask of interrupts to be checked.

Returns:

Mask of enabled interrupts.

NRF_STATIC_INLINE void nrf_uart_int_disable(NRF_UART_Type *p_reg, uint32_t mask)

Function for disabling the specified interrupts.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

  • mask[in] Mask of interrupts to be disabled.

NRF_STATIC_INLINE uint32_t nrf_uart_errorsrc_get_and_clear(NRF_UART_Type *p_reg)

Function for getting error source mask. Function is clearing error source flags after reading.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

Returns:

Mask with error source flags.

NRF_STATIC_INLINE void nrf_uart_enable(NRF_UART_Type *p_reg)

Function for enabling UART.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

NRF_STATIC_INLINE void nrf_uart_disable(NRF_UART_Type *p_reg)

Function for disabling UART.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

NRF_STATIC_INLINE void nrf_uart_txrx_pins_set(NRF_UART_Type *p_reg, uint32_t pseltxd, uint32_t pselrxd)

Function for configuring TX/RX pins.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

  • pseltxd[in] TXD pin number.

  • pselrxd[in] RXD pin number.

NRF_STATIC_INLINE void nrf_uart_txrx_pins_disconnect(NRF_UART_Type *p_reg)

Function for disconnecting TX/RX pins.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

NRF_STATIC_INLINE uint32_t nrf_uart_tx_pin_get(NRF_UART_Type const *p_reg)

Function for getting TX pin selection.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

Returns:

TX pin selection.

NRF_STATIC_INLINE uint32_t nrf_uart_rx_pin_get(NRF_UART_Type const *p_reg)

Function for getting RX pin selection.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

Returns:

RX pin selection.

NRF_STATIC_INLINE uint32_t nrf_uart_rts_pin_get(NRF_UART_Type const *p_reg)

Function for getting RTS pin selection.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

Returns:

RTS pin selection.

NRF_STATIC_INLINE uint32_t nrf_uart_cts_pin_get(NRF_UART_Type const *p_reg)

Function for getting CTS pin selection.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

Returns:

CTS pin selection.

NRF_STATIC_INLINE void nrf_uart_hwfc_pins_set(NRF_UART_Type *p_reg, uint32_t pselrts, uint32_t pselcts)

Function for configuring flow control pins.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

  • pselrts[in] RTS pin number.

  • pselcts[in] CTS pin number.

NRF_STATIC_INLINE void nrf_uart_hwfc_pins_disconnect(NRF_UART_Type *p_reg)

Function for disconnecting flow control pins.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

NRF_STATIC_INLINE uint8_t nrf_uart_rxd_get(NRF_UART_Type const *p_reg)

Function for reading RX data.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

Returns:

Received byte.

NRF_STATIC_INLINE void nrf_uart_txd_set(NRF_UART_Type *p_reg, uint8_t txd)

Function for setting Tx data.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

  • txd[in] Byte.

NRF_STATIC_INLINE void nrf_uart_task_trigger(NRF_UART_Type *p_reg, nrf_uart_task_t task)

Function for starting an UART task.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

  • task[in] Task.

NRF_STATIC_INLINE uint32_t nrf_uart_task_address_get(NRF_UART_Type const *p_reg, nrf_uart_task_t task)

Function for returning the address of the specified task register.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

  • task[in] Task.

Returns:

Task address.

NRF_STATIC_INLINE void nrf_uart_configure(NRF_UART_Type *p_reg, nrf_uart_config_t const *p_cfg)

Function for configuring UART.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

  • p_cfg[in] Pointer to UART settings structure.

NRF_STATIC_INLINE void nrf_uart_baudrate_set(NRF_UART_Type *p_reg, nrf_uart_baudrate_t baudrate)

Function for setting UART baud rate.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

  • baudrate[in] Baud rate.

struct nrf_uart_config_t
#include <nrf_uart.h>

Structure for UART transmission configuration.

Public Members

nrf_uart_hwfc_t hwfc

Flow control configuration.

nrf_uart_parity_t parity

Parity configuration.

nrf_uart_stop_t stop

Stop bits.

nrf_uart_paritytype_t paritytype

Parity type.