ChibiOS/HAL
7.0.3
|
Generic True Random Numbers Generator Driver. More...
![]() |
Generic True Random Numbers Generator Driver.
This module implements a generic TRNG driver.
HAL_USE_TRNG
option must be enabled in halconf.h
. Macros | |
#define | trng_lld_driver_fields |
Low level fields of the TRNG driver structure. More... | |
#define | trng_lld_config_fields |
Low level fields of the TRNG configuration structure. More... | |
PLATFORM configuration options | |
#define | PLATFORM_TRNG_USE_TRNG1 FALSE |
TRNGD1 driver enable switch. More... | |
Typedefs | |
typedef struct hal_trng_driver | TRNGDriver |
Type of a structure representing a TRNG driver. More... | |
typedef struct hal_trng_config | TRNGConfig |
Driver configuration structure. More... | |
Data Structures | |
struct | hal_trng_config |
Driver configuration structure. More... | |
struct | hal_trng_driver |
Structure representing a TRNG driver. More... | |
Functions | |
void | trngInit (void) |
TRNG Driver initialization. More... | |
void | trngObjectInit (TRNGDriver *trngp) |
Initializes the standard part of a TRNGDriver structure. More... | |
void | trngStart (TRNGDriver *trngp, const TRNGConfig *config) |
Configures and activates the TRNG peripheral. More... | |
void | trngStop (TRNGDriver *trngp) |
Deactivates the TRNG peripheral. More... | |
bool | trngGenerate (TRNGDriver *trngp, size_t size, uint8_t *out) |
True random numbers generator. More... | |
void | trng_lld_init (void) |
Low level TRNG driver initialization. More... | |
void | trng_lld_start (TRNGDriver *trngp) |
Configures and activates the TRNG peripheral. More... | |
void | trng_lld_stop (TRNGDriver *trngp) |
Deactivates the TRNG peripheral. More... | |
bool | trng_lld_generate (TRNGDriver *trngp, size_t size, uint8_t *out) |
True random numbers generator. More... | |
Enumerations |
Variables | |
TRNGDriver | TRNGD1 |
TRNGD1 driver identifier. More... | |
#define PLATFORM_TRNG_USE_TRNG1 FALSE |
TRNGD1 driver enable switch.
If set to TRUE
the support for TRNGD1 is included.
FALSE
. Definition at line 48 of file hal_trng_lld.h.
#define trng_lld_driver_fields |
Low level fields of the TRNG driver structure.
Definition at line 67 of file hal_trng_lld.h.
#define trng_lld_config_fields |
Low level fields of the TRNG configuration structure.
Definition at line 74 of file hal_trng_lld.h.
typedef struct hal_trng_driver TRNGDriver |
Type of a structure representing a TRNG driver.
Definition at line 59 of file hal_trng.h.
typedef struct hal_trng_config TRNGConfig |
Driver configuration structure.
Definition at line 65 of file hal_trng.h.
enum trngstate_t |
Driver state machine possible states.
Enumerator | |
---|---|
TRNG_UNINIT |
Not initialized. |
TRNG_STOP |
Stopped. |
TRNG_READY |
Ready. |
TRNG_RUNNING |
Generating random number. |
Definition at line 49 of file hal_trng.h.
void trngInit | ( | void | ) |
TRNG Driver initialization.
halInit()
, there is no need to explicitly initialize the driver.Definition at line 56 of file hal_trng.c.
References trng_lld_init().
Referenced by halInit().
void trngObjectInit | ( | TRNGDriver * | trngp | ) |
Initializes the standard part of a TRNGDriver
structure.
[out] | trngp | pointer to the TRNGDriver object |
Definition at line 68 of file hal_trng.c.
References hal_trng_driver::config, hal_trng_driver::state, and TRNG_STOP.
Referenced by trng_lld_init().
void trngStart | ( | TRNGDriver * | trngp, |
const TRNGConfig * | config | ||
) |
Configures and activates the TRNG peripheral.
[in] | trngp | pointer to the TRNGDriver object |
[in] | config | pointer to the TRNGConfig object or NULL for default configuration |
Definition at line 83 of file hal_trng.c.
References hal_trng_driver::config, osalDbgAssert, osalDbgCheck, osalSysLock(), osalSysUnlock(), hal_trng_driver::state, trng_lld_start(), TRNG_READY, and TRNG_STOP.
void trngStop | ( | TRNGDriver * | trngp | ) |
Deactivates the TRNG peripheral.
[in] | trngp | pointer to the TRNGDriver object |
Definition at line 103 of file hal_trng.c.
References hal_trng_driver::config, osalDbgAssert, osalDbgCheck, osalSysLock(), osalSysUnlock(), hal_trng_driver::state, trng_lld_stop(), TRNG_READY, and TRNG_STOP.
bool trngGenerate | ( | TRNGDriver * | trngp, |
size_t | size, | ||
uint8_t * | out | ||
) |
True random numbers generator.
[in] | trngp | pointer to the TRNGDriver object |
[in] | size | size of output buffer |
[out] | out | output buffer |
false | if a random number has been generated. |
true | if an HW error occurred. |
Definition at line 133 of file hal_trng.c.
References osalDbgAssert, osalDbgCheck, hal_trng_driver::state, trng_lld_generate(), TRNG_READY, and TRNG_RUNNING.
void trng_lld_init | ( | void | ) |
Low level TRNG driver initialization.
Definition at line 65 of file hal_trng_lld.c.
References trngObjectInit().
Referenced by trngInit().
void trng_lld_start | ( | TRNGDriver * | trngp | ) |
Configures and activates the TRNG peripheral.
[in] | trngp | pointer to the TRNGDriver object |
Definition at line 80 of file hal_trng_lld.c.
References hal_trng_driver::state, and TRNG_STOP.
Referenced by trngStart().
void trng_lld_stop | ( | TRNGDriver * | trngp | ) |
Deactivates the TRNG peripheral.
[in] | trngp | pointer to the TRNGDriver object |
Definition at line 101 of file hal_trng_lld.c.
References hal_trng_driver::state, and TRNG_READY.
Referenced by trngStop().
bool trng_lld_generate | ( | TRNGDriver * | trngp, |
size_t | size, | ||
uint8_t * | out | ||
) |
True random numbers generator.
[in] | trngp | pointer to the TRNGDriver object |
[in] | size | size of output buffer |
[out] | out | output buffer |
false | if a random number has been generated. |
true | if an HW error occurred. |
Definition at line 129 of file hal_trng_lld.c.
Referenced by trngGenerate().
TRNGDriver TRNGD1 |
TRNGD1 driver identifier.
Definition at line 41 of file hal_trng_lld.c.