| nRF5 SDK v12.0.0 |

Choose documentation: | nRF5 SDK | S130 SoftDevice API | S132 SoftDevice API | S212 SoftDevice API | S332 SoftDevice API

All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
Macros | Enumerations | Functions
UART HAL
UART driver and HAL

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

## Macros
#define | NRF_UART_PSEL_DISCONNECTED 0xFFFFFFFF

## 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_38400 = UART_BAUDRATE_BAUDRATE_Baud38400, 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...

## Functions
__STATIC_INLINE void | nrf_uart_event_clear (NRF_UART_Type *p_reg, nrf_uart_event_t event)
| Function for clearing a specific UART event. More...
__STATIC_INLINE bool | nrf_uart_event_check (NRF_UART_Type *p_reg, nrf_uart_event_t event)
| Function for checking the state of a specific UART event. More...
__STATIC_INLINE uint32_t | nrf_uart_event_address_get (NRF_UART_Type *p_reg, nrf_uart_event_t event)
| Function for returning the address of a specific UART event register. More...
__STATIC_INLINE void | nrf_uart_int_enable (NRF_UART_Type *p_reg, uint32_t int_mask)
| Function for enabling a specific interrupt. More...
__STATIC_INLINE bool | nrf_uart_int_enable_check (NRF_UART_Type *p_reg, uint32_t int_mask)
| Function for retrieving the state of a given interrupt. More...
__STATIC_INLINE void | nrf_uart_int_disable (NRF_UART_Type *p_reg, uint32_t int_mask)
| Function for disabling specific interrupts. More...
__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...
__STATIC_INLINE void | nrf_uart_enable (NRF_UART_Type *p_reg)
| Function for enabling UART. More...
__STATIC_INLINE void | nrf_uart_disable (NRF_UART_Type *p_reg)
| Function for disabling UART. More...
__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...
__STATIC_INLINE void | nrf_uart_txrx_pins_disconnect (NRF_UART_Type *p_reg)
| Function for disconnecting TX/RX pins. More...
__STATIC_INLINE uint32_t | nrf_uart_tx_pin_get (NRF_UART_Type *p_reg)
| Function for getting TX pin. More...
__STATIC_INLINE uint32_t | nrf_uart_rx_pin_get (NRF_UART_Type *p_reg)
| Function for getting RX pin. More...
__STATIC_INLINE uint32_t | nrf_uart_rts_pin_get (NRF_UART_Type *p_reg)
| Function for getting RTS pin. More...
__STATIC_INLINE uint32_t | nrf_uart_cts_pin_get (NRF_UART_Type *p_reg)
| Function for getting CTS pin. More...
__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...
__STATIC_INLINE void | nrf_uart_hwfc_pins_disconnect (NRF_UART_Type *p_reg)
| Function for disconnecting flow control pins. More...
__STATIC_INLINE uint8_t | nrf_uart_rxd_get (NRF_UART_Type *p_reg)
| Function for reading RX data. More...
__STATIC_INLINE void | nrf_uart_txd_set (NRF_UART_Type *p_reg, uint8_t txd)
| Function for setting Tx data. More...
__STATIC_INLINE void | nrf_uart_task_trigger (NRF_UART_Type *p_reg, nrf_uart_task_t task)
| Function for starting an UART task. More...
__STATIC_INLINE uint32_t | nrf_uart_task_address_get (NRF_UART_Type *p_reg, nrf_uart_task_t task)
| Function for returning the address of a specific task register. More...
__STATIC_INLINE void | nrf_uart_configure (NRF_UART_Type *p_reg, nrf_uart_parity_t parity, nrf_uart_hwfc_t hwfc)
| Function for configuring UART. More...
__STATIC_INLINE void | nrf_uart_baudrate_set (NRF_UART_Type *p_reg, nrf_uart_baudrate_t baudrate)
| Function for setting UART baudrate. More...

## Detailed Description

Hardware access layer for accessing the UART peripheral.

## Enumeration Type Documentation

enum 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_38400 | 38400 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.

enum 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.

enum 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.

enum nrf_uart_hwfc_t

Types of UART flow control modes.

Enumerator
NRF_UART_HWFC_DISABLED | HW flow control disabled.
NRF_UART_HWFC_ENABLED | HW flow control enabled.

enum 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.

enum nrf_uart_parity_t

Types of UART parity modes.

Enumerator
NRF_UART_PARITY_EXCLUDED | Parity excluded.
NRF_UART_PARITY_INCLUDED | Parity included.

enum 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

__STATIC_INLINE void nrf_uart_baudrate_set | ( | NRF_UART_Type * | p_reg,
|  | nrf_uart_baudrate_t | baudrate
| ) |  |

Function for setting UART baudrate.

Parameters

  p_reg | Pointer to the peripheral registers structure.
  baudrate | Baudrate.

__STATIC_INLINE void nrf_uart_configure | ( | NRF_UART_Type * | p_reg,
|  | nrf_uart_parity_t | parity,
|  | nrf_uart_hwfc_t | hwfc
| ) |  |

Function for configuring UART.

Parameters

  p_reg | Pointer to the peripheral registers structure.
  hwfc | Hardware flow control. Enabled if true.
  parity | Parity. Included if true.

__STATIC_INLINE uint32_t nrf_uart_cts_pin_get | ( | NRF_UART_Type * | p_reg | ) |

Function for getting CTS pin.

Parameters

  p_reg | Pointer to the peripheral registers structure.

__STATIC_INLINE void nrf_uart_disable | ( | NRF_UART_Type * | p_reg | ) |

Function for disabling UART.

Parameters

  p_reg | Pointer to the peripheral registers structure.

__STATIC_INLINE void nrf_uart_enable | ( | NRF_UART_Type * | p_reg | ) |

Function for enabling UART.

Parameters

  p_reg | Pointer to the peripheral registers structure.

__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 | Pointer to the peripheral registers structure.

Returns
  Mask with error source flags.

__STATIC_INLINE uint32_t nrf_uart_event_address_get | ( | NRF_UART_Type * | p_reg,
|  | nrf_uart_event_t | event
| ) |  |

Function for returning the address of a specific UART event register.

Parameters

  [in] | p_reg | Pointer to the peripheral registers structure.
  [in] | event | Desired event.

Return values

  Address | of specified event register.

__STATIC_INLINE bool nrf_uart_event_check | ( | NRF_UART_Type * | p_reg,
|  | nrf_uart_event_t | event
| ) |  |

Function for checking the state of a specific UART event.

Parameters

  [in] | p_reg | Pointer to the peripheral registers structure.
  [in] | event | Event to check.

Return values

  True | if event is set, False otherwise.

__STATIC_INLINE void nrf_uart_event_clear | ( | NRF_UART_Type * | p_reg,
|  | nrf_uart_event_t | event
| ) |  |

Function for clearing a specific UART event.

Parameters

  [in] | p_reg | Pointer to the peripheral registers structure.
  [in] | event | Event to clear.

__STATIC_INLINE void nrf_uart_hwfc_pins_disconnect | ( | NRF_UART_Type * | p_reg | ) |

Function for disconnecting flow control pins.

Parameters

  p_reg | Pointer to the peripheral registers structure.

__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 | Pointer to the peripheral registers structure.
  pselrts | RTS pin number.
  pselcts | CTS pin number.

__STATIC_INLINE void nrf_uart_int_disable | ( | NRF_UART_Type * | p_reg,
|  | uint32_t | int_mask
| ) |  |

Function for disabling specific interrupts.

Parameters

  p_reg | Pointer to the peripheral registers structure.
  int_mask | Interrupts to disable.

__STATIC_INLINE void nrf_uart_int_enable | ( | NRF_UART_Type * | p_reg,
|  | uint32_t | int_mask
| ) |  |

Function for enabling a specific interrupt.

Parameters

  p_reg | Pointer to the peripheral registers structure.
  int_mask | Interrupts to enable.

__STATIC_INLINE bool nrf_uart_int_enable_check | ( | NRF_UART_Type * | p_reg,
|  | uint32_t | int_mask
| ) |  |

Function for retrieving the state of a given interrupt.

Parameters

  p_reg | Pointer to the peripheral registers structure.
  int_mask | Mask of interrupt to check.

Return values

  true | If the interrupt is enabled.
  false | If the interrupt is not enabled.

__STATIC_INLINE uint32_t nrf_uart_rts_pin_get | ( | NRF_UART_Type * | p_reg | ) |

Function for getting RTS pin.

Parameters

  p_reg | Pointer to the peripheral registers structure.

__STATIC_INLINE uint32_t nrf_uart_rx_pin_get | ( | NRF_UART_Type * | p_reg | ) |

Function for getting RX pin.

Parameters

  p_reg | Pointer to the peripheral registers structure.

__STATIC_INLINE uint8_t nrf_uart_rxd_get | ( | NRF_UART_Type * | p_reg | ) |

Function for reading RX data.

Parameters

  p_reg | Pointer to the peripheral registers structure.

Returns
  Received byte.

__STATIC_INLINE uint32_t nrf_uart_task_address_get | ( | NRF_UART_Type * | p_reg,
|  | nrf_uart_task_t | task
| ) |  |

Function for returning the address of a specific task register.

Parameters

  p_reg | Pointer to the peripheral registers structure.
  task | Task.

Returns
  Task address.

__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 | Pointer to the peripheral registers structure.
  task | Task.

__STATIC_INLINE uint32_t nrf_uart_tx_pin_get | ( | NRF_UART_Type * | p_reg | ) |

Function for getting TX pin.

Parameters

  p_reg | Pointer to the peripheral registers structure.

__STATIC_INLINE void nrf_uart_txd_set | ( | NRF_UART_Type * | p_reg,
|  | uint8_t | txd
| ) |  |

Function for setting Tx data.

Parameters

  p_reg | Pointer to the peripheral registers structure.
  txd | Byte.

__STATIC_INLINE void nrf_uart_txrx_pins_disconnect | ( | NRF_UART_Type * | p_reg | ) |

Function for disconnecting TX/RX pins.

Parameters

  p_reg | Pointer to the peripheral registers structure.

__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 | Pointer to the peripheral registers structure.
  pseltxd | TXD pin number.
  pselrxd | RXD pin number.