nrfcxx  0.1.0
C++-17 Framework for Nordic nRF5 Devices
Static Public Member Functions
nrfcxx::periph::RNG Class Reference

Wrapper around the nRF51 RNG peripheral. More...

#include <nrfcxx/periph.hpp>

Static Public Member Functions

static void * fill (void *dest, size_t count)
 Fill a block of memory with random bytes. More...
 
template<typename T , typename = std::enable_if<std::is_integral<T>::value>>
static T generate ()
 Generate a random value of the specified type. More...
 

Detailed Description

Wrapper around the nRF51 RNG peripheral.

Random bytes are generated in the background and kept in a buffer, from which fill() reads values.

See also
NRFCXX_PERIPH_RNG_BUFFER_SIZE

Member Function Documentation

◆ fill()

static void* nrfcxx::periph::RNG::fill ( void *  dest,
size_t  count 
)
static

Fill a block of memory with random bytes.

Parameters
destpointer to area to be filled
countnumber of bytes to be written starting at dest
Returns
dest
Note
It is safe to invoke this from any context including FLIHs and blocks in which interrupts are disabled.

◆ generate()

template<typename T , typename = std::enable_if<std::is_integral<T>::value>>
static T nrfcxx::periph::RNG::generate ( )
inlinestatic

Generate a random value of the specified type.

This delegates to fill() to obtain a block of random octets of the required length.

Template Parameters
Tany integral type

The documentation for this class was generated from the following file: