This section describes the programming interface of the RNGA Peripheral driver. The RNGA driver provides an easy way to initialize and configure the RNGA.
RNGA Initialization
-
To initialize the RNGA module, call the RNGA_DRV_Init() function and pass the user configuration structure. This function automatically enables the RNGA module and clock.
-
After calling the RNGA_DRV_Init() function, the RNGA is enabled and the counter starts working.
This example code shows how to initialize and configure the driver:
{
.highAssuranceEnable = true,
};
RNGA Set/Get Working Mode
The RNGA works either in sleep mode or normal mode
- RNGA_DRV_SetMode() function sets the RNGA mode.
- RNGA_DRV_GetMode() function gets the RNGA working mode.
Get random data from RNGA
- RNGA_DRV_GetRandomData() function gets random data from the RNGA module.
Seed RNGA
- RNGA_DRV_Seed() function inputs an entropy value that the RNGA can use to seed the pseudo random algorithm.
RNGA interrupt
If the RNGA interrupt is enabled, the RNGA asserts an interrupt when an underflow error happens.
- Enable the RNGA interrupt with the rnga_user_config_t.isIntMasked = false.
- Define the RNGA IRQ function.
void RNGA_IRQHandler()
{
}
|
RNG_Type *const | g_rngaBase [] |
| Table of base addresses for RNGA instances. More...
|
|
const IRQn_Type | g_rngaIrqId [RNG_INSTANCE_COUNT] |
| Table to save RNGA IRQ enumeration numbers defined in the CMSIS header file. More...
|
|
struct rnga_user_config_t |
This structure initializes the RNGA by calling the the rnga_init function. It contains all RNGA configurations.
#define RNGA_DRV_RTOS_MULTI_THREAD (USE_RTOS) |
It is achieved by mutex locking of critical sections. It is enabled by default for RTOS. It is optional and may be disabled if TRNG is used only by one RTOS task.
This function initializes the RNGA. When called, the RNGA runs immediately according to the specifications in the configuration.
- Parameters
-
instance,RNGA | instance ID |
config,pointer | to initialize configuration structure |
- Returns
- RNGA status
void RNGA_DRV_Deinit |
( |
uint32_t |
instance | ) |
|
This function shuts down the RNGA.
- Parameters
-
static void RNGA_DRV_SetMode |
( |
uint32_t |
instance, |
|
|
rnga_mode_t |
mode |
|
) |
| |
|
inlinestatic |
This function sets the RNGA in sleep mode or normal mode.
- Parameters
-
instance,RNGA | instance ID |
mode,normal | mode or sleep mode |
static rnga_mode_t RNGA_DRV_GetMode |
( |
uint32_t |
instance | ) |
|
|
inlinestatic |
This function gets the RNGA working mode.
- Parameters
-
- Returns
- normal mode or sleep mode
rnga_status_t RNGA_DRV_GetRandomData |
( |
uint32_t |
instance, |
|
|
void * |
data, |
|
|
uint32_t |
data_size |
|
) |
| |
This function gets random data from the RNGA.
- Parameters
-
instance,RNGA | instance ID |
data | pointer to user buffer to be filled by random data size of data in bytes |
- Returns
- RNGA status
static void RNGA_DRV_Seed |
( |
uint32_t |
instance, |
|
|
uint32_t |
seed |
|
) |
| |
|
inlinestatic |
This function inputs an entropy value that the RNGA uses to seed its pseudo-random algorithm.
- Parameters
-
instance,RNGA | instance ID |
seed,input | seed value |
void RNGA_DRV_IRQHandler |
( |
uint32_t |
instance | ) |
|
This function handles the error interrupt caused by the RNGA underflow.
- Parameters
-
RNG_Type* const g_rngaBase[] |
const IRQn_Type g_rngaIrqId[RNG_INSTANCE_COUNT] |