nrfx 2.5
Data Structures | Macros | Enumerations | Functions
UART HAL

Hardware access layer for managing the UART peripheral. More...

Data Structures

struct  nrf_uart_config_t
 Structure for UART transmission configuration. More...
 

Macros

#define NRF_UART_PSEL_DISCONNECTED   0xFFFFFFFF
 Pin disconnected value.
 

Enumerations

enum  nrf_uart_task_t {
  NRF_UART_TASK_STARTRX = offsetof(NRF_UART_Type, TASKS_STARTRX),
  NRF_UART_TASK_STOPRX = offsetof(NRF_UART_Type, TASKS_STOPRX),
  NRF_UART_TASK_STARTTX = offsetof(NRF_UART_Type, TASKS_STARTTX),
  NRF_UART_TASK_STOPTX = offsetof(NRF_UART_Type, TASKS_STOPTX),
  NRF_UART_TASK_SUSPEND = offsetof(NRF_UART_Type, TASKS_SUSPEND)
}
 UART tasks. More...
 
enum  nrf_uart_event_t {
  NRF_UART_EVENT_CTS = offsetof(NRF_UART_Type, EVENTS_CTS),
  NRF_UART_EVENT_NCTS = offsetof(NRF_UART_Type, EVENTS_NCTS),
  NRF_UART_EVENT_RXDRDY = offsetof(NRF_UART_Type, EVENTS_RXDRDY),
  NRF_UART_EVENT_TXDRDY = offsetof(NRF_UART_Type, EVENTS_TXDRDY),
  NRF_UART_EVENT_ERROR = offsetof(NRF_UART_Type, EVENTS_ERROR),
  NRF_UART_EVENT_RXTO = offsetof(NRF_UART_Type, EVENTS_RXTO)
}
 UART events. More...
 
enum  nrf_uart_int_mask_t {
  NRF_UART_INT_MASK_CTS = UART_INTENCLR_CTS_Msk,
  NRF_UART_INT_MASK_NCTS = UART_INTENCLR_NCTS_Msk,
  NRF_UART_INT_MASK_RXDRDY = UART_INTENCLR_RXDRDY_Msk,
  NRF_UART_INT_MASK_TXDRDY = UART_INTENCLR_TXDRDY_Msk,
  NRF_UART_INT_MASK_ERROR = UART_INTENCLR_ERROR_Msk,
  NRF_UART_INT_MASK_RXTO = UART_INTENCLR_RXTO_Msk
}
 UART interrupts. More...
 
enum  nrf_uart_baudrate_t {
  NRF_UART_BAUDRATE_1200 = UART_BAUDRATE_BAUDRATE_Baud1200,
  NRF_UART_BAUDRATE_2400 = UART_BAUDRATE_BAUDRATE_Baud2400,
  NRF_UART_BAUDRATE_4800 = UART_BAUDRATE_BAUDRATE_Baud4800,
  NRF_UART_BAUDRATE_9600 = UART_BAUDRATE_BAUDRATE_Baud9600,
  NRF_UART_BAUDRATE_14400 = UART_BAUDRATE_BAUDRATE_Baud14400,
  NRF_UART_BAUDRATE_19200 = UART_BAUDRATE_BAUDRATE_Baud19200,
  NRF_UART_BAUDRATE_28800 = UART_BAUDRATE_BAUDRATE_Baud28800,
  NRF_UART_BAUDRATE_31250 = UART_BAUDRATE_BAUDRATE_Baud31250,
  NRF_UART_BAUDRATE_38400 = UART_BAUDRATE_BAUDRATE_Baud38400,
  NRF_UART_BAUDRATE_56000 = UART_BAUDRATE_BAUDRATE_Baud56000,
  NRF_UART_BAUDRATE_57600 = UART_BAUDRATE_BAUDRATE_Baud57600,
  NRF_UART_BAUDRATE_76800 = UART_BAUDRATE_BAUDRATE_Baud76800,
  NRF_UART_BAUDRATE_115200 = UART_BAUDRATE_BAUDRATE_Baud115200,
  NRF_UART_BAUDRATE_230400 = UART_BAUDRATE_BAUDRATE_Baud230400,
  NRF_UART_BAUDRATE_250000 = UART_BAUDRATE_BAUDRATE_Baud250000,
  NRF_UART_BAUDRATE_460800 = UART_BAUDRATE_BAUDRATE_Baud460800,
  NRF_UART_BAUDRATE_921600 = UART_BAUDRATE_BAUDRATE_Baud921600,
  NRF_UART_BAUDRATE_1000000 = UART_BAUDRATE_BAUDRATE_Baud1M
}
 Baudrates supported by UART. More...
 
enum  nrf_uart_error_mask_t {
  NRF_UART_ERROR_OVERRUN_MASK = UART_ERRORSRC_OVERRUN_Msk,
  NRF_UART_ERROR_PARITY_MASK = UART_ERRORSRC_PARITY_Msk,
  NRF_UART_ERROR_FRAMING_MASK = UART_ERRORSRC_FRAMING_Msk,
  NRF_UART_ERROR_BREAK_MASK = UART_ERRORSRC_BREAK_Msk
}
 Types of UART error masks. More...
 
enum  nrf_uart_parity_t {
  NRF_UART_PARITY_EXCLUDED = UART_CONFIG_PARITY_Excluded << UART_CONFIG_PARITY_Pos,
  NRF_UART_PARITY_INCLUDED = UART_CONFIG_PARITY_Included << UART_CONFIG_PARITY_Pos
}
 Types of UART parity modes. More...
 
enum  nrf_uart_hwfc_t {
  NRF_UART_HWFC_DISABLED = UART_CONFIG_HWFC_Disabled,
  NRF_UART_HWFC_ENABLED = UART_CONFIG_HWFC_Enabled
}
 Types of UART flow control modes. More...
 
enum  nrf_uart_stop_t {
  NRF_UART_STOP_ONE = UART_CONFIG_STOP_One << UART_CONFIG_STOP_Pos,
  NRF_UART_STOP_TWO = UART_CONFIG_STOP_Two << UART_CONFIG_STOP_Pos
}
 Types of UART stop bit modes. More...
 
enum  nrf_uart_paritytype_t {
  NRF_UART_PARITYTYPE_EVEN = UART_CONFIG_PARITYTYPE_Even << UART_CONFIG_PARITYTYPE_Pos,
  NRF_UART_PARITYTYPE_ODD = UART_CONFIG_PARITYTYPE_Odd << UART_CONFIG_PARITYTYPE_Pos
}
 Types of UART parity types. More...
 

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. More...
 
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. More...
 
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. More...
 
NRF_STATIC_INLINE void nrf_uart_int_enable (NRF_UART_Type *p_reg, uint32_t mask)
 Function for enabling the specified interrupt. More...
 
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. More...
 
NRF_STATIC_INLINE void nrf_uart_int_disable (NRF_UART_Type *p_reg, uint32_t mask)
 Function for disabling the specified interrupts. More...
 
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. More...
 
NRF_STATIC_INLINE void nrf_uart_enable (NRF_UART_Type *p_reg)
 Function for enabling UART. More...
 
NRF_STATIC_INLINE void nrf_uart_disable (NRF_UART_Type *p_reg)
 Function for disabling UART. More...
 
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. More...
 
NRF_STATIC_INLINE void nrf_uart_txrx_pins_disconnect (NRF_UART_Type *p_reg)
 Function for disconnecting TX/RX pins. More...
 
NRF_STATIC_INLINE uint32_t nrf_uart_tx_pin_get (NRF_UART_Type const *p_reg)
 Function for getting TX pin selection. More...
 
NRF_STATIC_INLINE uint32_t nrf_uart_rx_pin_get (NRF_UART_Type const *p_reg)
 Function for getting RX pin selection. More...
 
NRF_STATIC_INLINE uint32_t nrf_uart_rts_pin_get (NRF_UART_Type const *p_reg)
 Function for getting RTS pin selection. More...
 
NRF_STATIC_INLINE uint32_t nrf_uart_cts_pin_get (NRF_UART_Type const *p_reg)
 Function for getting CTS pin selection. More...
 
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. More...
 
NRF_STATIC_INLINE void nrf_uart_hwfc_pins_disconnect (NRF_UART_Type *p_reg)
 Function for disconnecting flow control pins. More...
 
NRF_STATIC_INLINE uint8_t nrf_uart_rxd_get (NRF_UART_Type const *p_reg)
 Function for reading RX data. More...
 
NRF_STATIC_INLINE void nrf_uart_txd_set (NRF_UART_Type *p_reg, uint8_t txd)
 Function for setting Tx data. More...
 
NRF_STATIC_INLINE void nrf_uart_task_trigger (NRF_UART_Type *p_reg, nrf_uart_task_t task)
 Function for starting an UART task. More...
 
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. More...
 
NRF_STATIC_INLINE void nrf_uart_configure (NRF_UART_Type *p_reg, nrf_uart_config_t const *p_cfg)
 Function for configuring UART. More...
 
NRF_STATIC_INLINE void nrf_uart_baudrate_set (NRF_UART_Type *p_reg, nrf_uart_baudrate_t baudrate)
 Function for setting UART baud rate. More...
 

Detailed Description

Hardware access layer for managing the UART peripheral.

Enumeration Type Documentation

◆ nrf_uart_baudrate_t

Baudrates supported by UART.

Enumerator
NRF_UART_BAUDRATE_1200 

1200 baud.

NRF_UART_BAUDRATE_2400 

2400 baud.

NRF_UART_BAUDRATE_4800 

4800 baud.

NRF_UART_BAUDRATE_9600 

9600 baud.

NRF_UART_BAUDRATE_14400 

14400 baud.

NRF_UART_BAUDRATE_19200 

19200 baud.

NRF_UART_BAUDRATE_28800 

28800 baud.

NRF_UART_BAUDRATE_31250 

31250 baud.

NRF_UART_BAUDRATE_38400 

38400 baud.

NRF_UART_BAUDRATE_56000 

56000 baud.

NRF_UART_BAUDRATE_57600 

57600 baud.

NRF_UART_BAUDRATE_76800 

76800 baud.

NRF_UART_BAUDRATE_115200 

115200 baud.

NRF_UART_BAUDRATE_230400 

230400 baud.

NRF_UART_BAUDRATE_250000 

250000 baud.

NRF_UART_BAUDRATE_460800 

460800 baud.

NRF_UART_BAUDRATE_921600 

921600 baud.

NRF_UART_BAUDRATE_1000000 

1000000 baud.

◆ nrf_uart_error_mask_t

Types of UART error masks.

Enumerator
NRF_UART_ERROR_OVERRUN_MASK 

Overrun error.

NRF_UART_ERROR_PARITY_MASK 

Parity error.

NRF_UART_ERROR_FRAMING_MASK 

Framing error.

NRF_UART_ERROR_BREAK_MASK 

Break error.

◆ nrf_uart_event_t

UART events.

Enumerator
NRF_UART_EVENT_CTS 

Event from CTS line activation.

NRF_UART_EVENT_NCTS 

Event from CTS line deactivation.

NRF_UART_EVENT_RXDRDY 

Event from data ready in RXD.

NRF_UART_EVENT_TXDRDY 

Event from data sent from TXD.

NRF_UART_EVENT_ERROR 

Event from error detection.

NRF_UART_EVENT_RXTO 

Event from receiver timeout.

◆ nrf_uart_hwfc_t

Types of UART flow control modes.

Enumerator
NRF_UART_HWFC_DISABLED 

Hardware flow control disabled.

NRF_UART_HWFC_ENABLED 

Hardware flow control enabled.

◆ nrf_uart_int_mask_t

UART interrupts.

Enumerator
NRF_UART_INT_MASK_CTS 

CTS line activation interrupt.

NRF_UART_INT_MASK_NCTS 

CTS line deactivation interrupt.

NRF_UART_INT_MASK_RXDRDY 

Data ready in RXD interrupt.

NRF_UART_INT_MASK_TXDRDY 

Data sent from TXD interrupt.

NRF_UART_INT_MASK_ERROR 

Error detection interrupt.

NRF_UART_INT_MASK_RXTO 

Receiver timeout interrupt.

◆ nrf_uart_parity_t

Types of UART parity modes.

Enumerator
NRF_UART_PARITY_EXCLUDED 

Parity excluded.

NRF_UART_PARITY_INCLUDED 

Parity included.

◆ nrf_uart_paritytype_t

Types of UART parity types.

Enumerator
NRF_UART_PARITYTYPE_EVEN 

Parity even.

NRF_UART_PARITYTYPE_ODD 

Parity odd.

◆ nrf_uart_stop_t

Types of UART stop bit modes.

Enumerator
NRF_UART_STOP_ONE 

One stop bit.

NRF_UART_STOP_TWO 

Two stop bits.

◆ nrf_uart_task_t

UART tasks.

Enumerator
NRF_UART_TASK_STARTRX 

Task for starting reception.

NRF_UART_TASK_STOPRX 

Task for stopping reception.

NRF_UART_TASK_STARTTX 

Task for starting transmission.

NRF_UART_TASK_STOPTX 

Task for stopping transmission.

NRF_UART_TASK_SUSPEND 

Task for suspending UART.

Function Documentation

◆ nrf_uart_baudrate_set()

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
[in]p_regPointer to the structure of registers of the peripheral.
[in]baudrateBaud rate.

◆ nrf_uart_configure()

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

Function for configuring UART.

Parameters
[in]p_regPointer to the structure of registers of the peripheral.
[in]p_cfgPointer to UART settings structure.

◆ nrf_uart_cts_pin_get()

NRF_STATIC_INLINE uint32_t nrf_uart_cts_pin_get ( NRF_UART_Type const *  p_reg)

Function for getting CTS pin selection.

Parameters
[in]p_regPointer to the structure of registers of the peripheral.
Returns
CTS pin selection.

◆ nrf_uart_disable()

NRF_STATIC_INLINE void nrf_uart_disable ( NRF_UART_Type *  p_reg)

Function for disabling UART.

Parameters
[in]p_regPointer to the structure of registers of the peripheral.

◆ nrf_uart_enable()

NRF_STATIC_INLINE void nrf_uart_enable ( NRF_UART_Type *  p_reg)

Function for enabling UART.

Parameters
[in]p_regPointer to the structure of registers of the peripheral.

◆ nrf_uart_errorsrc_get_and_clear()

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
[in]p_regPointer to the structure of registers of the peripheral.
Returns
Mask with error source flags.

◆ nrf_uart_event_address_get()

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
[in]p_regPointer to the structure of registers of the peripheral.
[in]eventDesired event.
Returns
Address of the specified event register.

◆ nrf_uart_event_check()

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
[in]p_regPointer to the structure of registers of the peripheral.
[in]eventEvent to be checked.
Return values
trueThe event has been generated.
falseThe event has not been generated.

◆ nrf_uart_event_clear()

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
[in]p_regPointer to the structure of registers of the peripheral.
[in]eventEvent to clear.

◆ nrf_uart_hwfc_pins_disconnect()

NRF_STATIC_INLINE void nrf_uart_hwfc_pins_disconnect ( NRF_UART_Type *  p_reg)

Function for disconnecting flow control pins.

Parameters
[in]p_regPointer to the structure of registers of the peripheral.

◆ nrf_uart_hwfc_pins_set()

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
[in]p_regPointer to the structure of registers of the peripheral.
[in]pselrtsRTS pin number.
[in]pselctsCTS pin number.

◆ nrf_uart_int_disable()

NRF_STATIC_INLINE void nrf_uart_int_disable ( NRF_UART_Type *  p_reg,
uint32_t  mask 
)

Function for disabling the specified interrupts.

Parameters
[in]p_regPointer to the structure of registers of the peripheral.
[in]maskMask of interrupts to be disabled.

◆ nrf_uart_int_enable()

NRF_STATIC_INLINE void nrf_uart_int_enable ( NRF_UART_Type *  p_reg,
uint32_t  mask 
)

Function for enabling the specified interrupt.

Parameters
[in]p_regPointer to the structure of registers of the peripheral.
[in]maskMask of interrupts to be enabled.

◆ nrf_uart_int_enable_check()

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
[in]p_regPointer to the structure of registers of the peripheral.
[in]maskMask of interrupts to be checked.
Returns
Mask of enabled interrupts.

◆ nrf_uart_rts_pin_get()

NRF_STATIC_INLINE uint32_t nrf_uart_rts_pin_get ( NRF_UART_Type const *  p_reg)

Function for getting RTS pin selection.

Parameters
[in]p_regPointer to the structure of registers of the peripheral.
Returns
RTS pin selection.

◆ nrf_uart_rx_pin_get()

NRF_STATIC_INLINE uint32_t nrf_uart_rx_pin_get ( NRF_UART_Type const *  p_reg)

Function for getting RX pin selection.

Parameters
[in]p_regPointer to the structure of registers of the peripheral.
Returns
RX pin selection.

◆ nrf_uart_rxd_get()

NRF_STATIC_INLINE uint8_t nrf_uart_rxd_get ( NRF_UART_Type const *  p_reg)

Function for reading RX data.

Parameters
[in]p_regPointer to the structure of registers of the peripheral.
Returns
Received byte.

◆ nrf_uart_task_address_get()

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
[in]p_regPointer to the structure of registers of the peripheral.
[in]taskTask.
Returns
Task address.

◆ nrf_uart_task_trigger()

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
[in]p_regPointer to the structure of registers of the peripheral.
[in]taskTask.

◆ nrf_uart_tx_pin_get()

NRF_STATIC_INLINE uint32_t nrf_uart_tx_pin_get ( NRF_UART_Type const *  p_reg)

Function for getting TX pin selection.

Parameters
[in]p_regPointer to the structure of registers of the peripheral.
Returns
TX pin selection.

◆ nrf_uart_txd_set()

NRF_STATIC_INLINE void nrf_uart_txd_set ( NRF_UART_Type *  p_reg,
uint8_t  txd 
)

Function for setting Tx data.

Parameters
[in]p_regPointer to the structure of registers of the peripheral.
[in]txdByte.

◆ nrf_uart_txrx_pins_disconnect()

NRF_STATIC_INLINE void nrf_uart_txrx_pins_disconnect ( NRF_UART_Type *  p_reg)

Function for disconnecting TX/RX pins.

Parameters
[in]p_regPointer to the structure of registers of the peripheral.

◆ nrf_uart_txrx_pins_set()

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
[in]p_regPointer to the structure of registers of the peripheral.
[in]pseltxdTXD pin number.
[in]pselrxdRXD pin number.

Documentation feedback | Developer Zone | Subscribe | Updated