RNG driver

group nrfx_rng

Random Number Generator (RNG) peripheral driver.

Defines

NRFX_RNG_DEFAULT_CONFIG

RNG default configuration. Basic usage:

nrfx_rng_config_t config = NRFX_RNG_DEFAULT_CONFIG;
if (nrfx_rng_init(&config, handler)
{ ...

This configuration sets up randon number generator with the following options:

  • error correction enabled

Typedefs

typedef void (*nrfx_rng_evt_handler_t)(uint8_t rng_data)

RNG driver event handler type.

Functions

nrfx_err_t nrfx_rng_init(nrfx_rng_config_t const *p_config, nrfx_rng_evt_handler_t handler)

Function for initializing the nrfx_rng module.

Parameters:
  • p_config[in] Pointer to the structure with the initial configuration.

  • handler[in] Event handler provided by the user. Must not be NULL.

Return values:
  • NRFX_SUCCESS – Driver was successfully initialized.

  • NRFX_ERROR_ALREADY – Driver was already initialized.

void nrfx_rng_start(void)

Function for starting the generation of random values.

New data should be handled by handler passed to the nrfx_rng_init() function.

void nrfx_rng_stop(void)

Function for stopping the generation of random values.

Function disables interrupts in peripheral and stops the generation of new random values.

void nrfx_rng_uninit(void)

Function for uninitializing the nrfx_rng module.

bool nrfx_rng_init_check(void)

Function for checking if the RNG driver is initialized.

Return values:
  • true – Driver is already initialized.

  • false – Driver is not initialized.

struct nrfx_rng_config_t
#include <nrfx_rng.h>

Struct for RNG configuration.

Public Members

bool error_correction

Error correction flag.

uint8_t interrupt_priority

Interrupt priority.