EVE 1.0
nRF52 HW Random number generator

nRF52 hardware random number generator (RNG) APIs. More...

Collaboration diagram for nRF52 HW Random number generator:

Data Structures

struct  rng_config_t
 Struct for RNG configuration. More...
 

Macros

#define NRF_DRV_RNG_DEFAULT_CONFIG
 RNG default configuration.
 

Functions

uint32_t RngInit (void)
 Function for initializing the nrf_drv_rng module. More...
 
void RngDeinit (void)
 Function for deinitializing the nrf_drv_rng module.
 
uint32_t RngBytesAvailable (uint8_t *bytes_available)
 Function for getting the number of currently available random bytes. More...
 
uint32_t RngPoolCapacity (uint8_t *pool_capacity)
 Function for querying the capacity of the application random pool. More...
 
uint32_t RngRand (uint8_t *buffer, uint8_t length)
 Function for getting the vector of random numbers. More...
 
uint32_t RngBlockRand (uint8_t *buffer, uint32_t length)
 Blocking function for getting an arbitrary array of random numbers. More...
 

Detailed Description

nRF52 hardware random number generator (RNG) APIs.

Function Documentation

uint32_t RngInit ( void  )

Function for initializing the nrf_drv_rng module.

Return values
NRF_SUCCESSDriver was successfully initialized.
NRF_ERROR_INVALID_STATEDriver was already initialized.
NRF_ERROR_INVALID_LENGTHPool size have to be a power of 2.
NRF_ERROR_SOFTDEVICE_NOT_ENABLEDSoftDevice is present, but not enabled.
uint32_t RngBytesAvailable ( uint8_t *  bytes_available)

Function for getting the number of currently available random bytes.

Parameters
[out]bytes_availableThe number of bytes currently available in the pool.
Return values
NRF_SUCCESSIf the number of available random bytes was written to bytes_available.
uint32_t RngPoolCapacity ( uint8_t *  pool_capacity)

Function for querying the capacity of the application random pool.

Parameters
[out]pool_capacityThe capacity of the pool.
Return values
NRF_SUCCESSIf the capacity of the pool was written to pool_capacity.
uint32_t RngRand ( uint8_t *  buffer,
uint8_t  length 
)

Function for getting the vector of random numbers.

Parameters
[out]bufferPointer to uint8_t buffer for storing the bytes.
[in]lengthNumber of bytes to take from the pool and place in buffer.
Return values
NRF_SUCCESSIf the requested bytes were written to buffer.
NRF_ERROR_NO_MEMIf no bytes were written to the buffer
NRF_ERROR_SOC_RAND_NOT_ENOUGH_VALUESIf no bytes were written to the buffer
uint32_t RngBlockRand ( uint8_t *  buffer,
uint32_t  length 
)

Blocking function for getting an arbitrary array of random numbers.

Note
This function may execute for a substantial amount of time depending on the length of the buffer required and on the state of the current internal pool of random numbers.
Parameters
[out]bufferPointer to buffer for storing the bytes.
[in]lengthNumber of bytes place in buffer.
Return values
NRF_SUCCESSIf the requested bytes were written to buffer.