RNG HAL

group nrf_rng_hal

Hardware access layer (HAL) for managing the Random Number Generator (RNG) peripheral.

Enums

enum nrf_rng_task_t

RNG tasks.

Values:

enumerator NRF_RNG_TASK_START

Start the random number generator.

enumerator NRF_RNG_TASK_STOP

Stop the random number generator.

enum nrf_rng_event_t

RNG events.

Values:

enumerator NRF_RNG_EVENT_VALRDY

New random number generated event.

enum nrf_rng_int_mask_t

RNG interrupts.

Values:

enumerator NRF_RNG_INT_VALRDY_MASK

Mask for enabling or disabling an interrupt on VALRDY event.

enum nrf_rng_short_mask_t

Types of RNG shortcuts.

Values:

enumerator NRF_RNG_SHORT_VALRDY_STOP_MASK

Mask for setting shortcut between EVENT_VALRDY and TASK_STOP.

Functions

NRF_STATIC_INLINE void nrf_rng_int_enable(NRF_RNG_Type *p_reg, uint32_t mask)

Function for enabling interrupts.

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

  • mask[in] Mask of interrupts to be enabled. Use nrf_rng_int_mask_t values for bit masking.

NRF_STATIC_INLINE void nrf_rng_int_disable(NRF_RNG_Type *p_reg, uint32_t mask)

Function for disabling interrupts.

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

  • mask[in] Mask of interrupts to be disabled. Use nrf_rng_int_mask_t values for bit masking.

NRF_STATIC_INLINE uint32_t nrf_rng_int_enable_check(NRF_RNG_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. Use nrf_rng_int_mask_t values for bit masking.

Returns:

Mask of enabled interrupts.

NRF_STATIC_INLINE uint32_t nrf_rng_task_address_get(NRF_RNG_Type const *p_reg, nrf_rng_task_t rng_task)

Function for getting the address of the specified task.

This function can be used by the PPI module.

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

  • rng_task[in] The specified task.

Returns:

Address of the specified task.

NRF_STATIC_INLINE void nrf_rng_task_trigger(NRF_RNG_Type *p_reg, nrf_rng_task_t rng_task)

Function for triggering the specified task.

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

  • rng_task[in] The specified Task.

NRF_STATIC_INLINE uint32_t nrf_rng_event_address_get(NRF_RNG_Type const *p_reg, nrf_rng_event_t rng_event)

Function for getting address of the specified event.

This function can be used by the PPI module.

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

  • rng_event[in] The specified event.

Returns:

Address of the specified event.

NRF_STATIC_INLINE void nrf_rng_event_clear(NRF_RNG_Type *p_reg, nrf_rng_event_t rng_event)

Function for clearing the specified event.

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

  • rng_event[in] The specified event.

NRF_STATIC_INLINE bool nrf_rng_event_check(NRF_RNG_Type const *p_reg, nrf_rng_event_t rng_event)

Function for retrieving the state of the specified event.

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

  • rng_event[in] The specified event.

Return values:
  • true – The event is set.

  • false – The event is not set.

NRF_STATIC_INLINE void nrf_rng_shorts_enable(NRF_RNG_Type *p_reg, uint32_t mask)

Function for setting shortcuts.

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

  • mask[in] Mask of shortcuts.

NRF_STATIC_INLINE void nrf_rng_shorts_disable(NRF_RNG_Type *p_reg, uint32_t mask)

Function for clearing shortcuts.

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

  • mask[in] Mask of shortcuts.

NRF_STATIC_INLINE uint8_t nrf_rng_random_value_get(NRF_RNG_Type const *p_reg)

Function for getting the previously generated random value.

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

Returns:

Previously generated random value.

NRF_STATIC_INLINE void nrf_rng_error_correction_enable(NRF_RNG_Type *p_reg)

Function for enabling digital error correction.

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

NRF_STATIC_INLINE void nrf_rng_error_correction_disable(NRF_RNG_Type *p_reg)

Function for disabling digital error correction.

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

NRF_STATIC_INLINE void nrf_rng_subscribe_set(NRF_RNG_Type *p_reg, nrf_rng_task_t task, uint8_t channel)

Function for setting the subscribe configuration for a given RNG task.

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

  • task[in] Task for which to set the configuration.

  • channel[in] Channel through which to subscribe events.

NRF_STATIC_INLINE void nrf_rng_subscribe_clear(NRF_RNG_Type *p_reg, nrf_rng_task_t task)

Function for clearing the subscribe configuration for a given RNG task.

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

  • task[in] Task for which to clear the configuration.

NRF_STATIC_INLINE void nrf_rng_publish_set(NRF_RNG_Type *p_reg, nrf_rng_event_t event, uint8_t channel)

Function for setting the publish configuration for a given RNG event.

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

  • event[in] Event for which to set the configuration.

  • channel[in] Channel through which to publish the event.

NRF_STATIC_INLINE void nrf_rng_publish_clear(NRF_RNG_Type *p_reg, nrf_rng_event_t event)

Function for clearing the publish configuration for a given RNG event.

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

  • event[in] Event for which to clear the configuration.