libDaisy
Hardware Library for Daisy
Loading...
Searching...
No Matches
daisy::Random Class Reference

True Random Number Generator access. More...

Detailed Description

True Random Number Generator access.

Author
shensley

Provides static access to the built-in True Random Number Generator

#include <rng.h>

Public Member Functions

 Random ()
 
 ~Random ()
 

Static Public Member Functions

static void Init ()
 
static void DeInit ()
 
static uint32_t GetValue ()
 
static float GetFloat (float min=0.f, float max=1.f)
 
static bool IsReady ()
 

Constructor & Destructor Documentation

◆ Random()

daisy::Random::Random ( )
inline

◆ ~Random()

daisy::Random::~Random ( )
inline

Member Function Documentation

◆ DeInit()

static void daisy::Random::DeInit ( )
static

Deinitializes the Peripheral

◆ GetFloat()

static float daisy::Random::GetFloat ( float  min = 0.f,
float  max = 1.f 
)
static

Returns a floating point value between the specified minimum and maximum. Calls GetValue() internally.

Parameters
minthe minimum value to return, defaults to 0.f
maxthe maximum value to return, defaults to 1.f

◆ GetValue()

static uint32_t daisy::Random::GetValue ( )
static

Returns a randomly generated 32-bit number This is done by polling the peripheral, and can block for up to 100ms.

To avoid blocking issues, the IsReady function can be used to check if a value is ready before calling this function.

If there is an issue with the peripheral, or a timeout occurs the return value will be 0.

Returns
a 32-bit random number

◆ Init()

static void daisy::Random::Init ( )
static

Initializes the Peripheral

This is called from System::Init, so the GetValue, and GetFloat functions can be used without the application needing to manually initialize the RNG.

◆ IsReady()

static bool daisy::Random::IsReady ( )
static

Checks the peripheral to see if a new value is ready

Returns
true if conditioning has finished and a new value can be read

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