Kinetis SDK v.1.3 API Reference Manual
Rev. 0
Freescale Semiconductor, Inc.
|
This section describes the programming interface of the TRNG HAL driver.
Data Structures | |
struct | trng_statistical_check_limit_t |
Data structure for definition of statistical check limits. More... | |
TRNG HAL. | |
void | TRNG_HAL_Init (TRNG_Type *base) |
Initializes the TRNG module. More... | |
void | TRNG_HAL_Enable (TRNG_Type *base) |
Enables the TRNG module. More... | |
static void | TRNG_HAL_SetWorkingMode (TRNG_Type *base, trng_work_mode_t mode) |
Sets the TRNG to Program Mode or Run mode. More... | |
static void | TRNG_HAL_Disable (TRNG_Type *base) |
Disables the TRNG module. More... | |
static bool | TRNG_HAL_GetEntropyValidCmd (TRNG_Type *base) |
Gets the TRNG status whether the generated entropy is valid. More... | |
static bool | TRNG_HAL_GetErrorCmd (TRNG_Type *base) |
Gets the TRNG status whether the error occurred. More... | |
static void | TRNG_HAL_ClearError (TRNG_Type *base) |
Clears the TRNG error flag. More... | |
static bool | TRNG_HAL_GetOKToStopCmd (TRNG_Type *base) |
Gets the TRNG status whether the TRNG ring oscillator is not running. More... | |
static void | TRNG_HAL_EnableLock (TRNG_Type *base) |
Disables the programmability of TRNG registers. More... | |
static bool | TRNG_HAL_GetLockCmd (TRNG_Type *base) |
Gets the status of the possibility to program the TRNG registers. More... | |
static void | TRNG_HAL_SetSampleMode (TRNG_Type *base, trng_sample_mode_t mode) |
Sets the sample mode of the TRNG ring oscillator. More... | |
static trng_sample_mode_t | TRNG_HAL_GetSampleMode (TRNG_Type *base) |
Gets the sample mode of the TRNG ring oscillator. More... | |
static void | TRNG_HAL_SetClockMode (TRNG_Type *base, trng_clock_mode_t mode) |
Sets the clock mode used to operate TRNG. More... | |
static trng_clock_mode_t | TRNG_HAL_GetClockMode (TRNG_Type *base) |
Gets the clock mode used to operate the TRNG. More... | |
static void | TRNG_HAL_SetRingOscDiv (TRNG_Type *base, trng_ring_osc_div_t osc_div) |
Sets the ring oscillator divide used by the TRNG. More... | |
static trng_ring_osc_div_t | TRNG_HAL_GetRingOscDiv (TRNG_Type *base) |
Gets the ring oscillator divide used by the TRNG. More... | |
static void | TRNG_HAL_SetSampleSize (TRNG_Type *base, uint16_t sample_size) |
Sets the TRNG sample size. More... | |
static uint16_t | TRNG_HAL_GetSampleSize (TRNG_Type *base) |
Gets the TRNG sample size. More... | |
static void | TRNG_HAL_SetEntropyDelay (TRNG_Type *base, uint16_t ent_delay) |
Sets the TRNG entropy delay. More... | |
static uint16_t | TRNG_HAL_GetEntropyDelay (TRNG_Type *base) |
Gets the TRNG entropy delay. More... | |
static void | TRNG_HAL_SetSparseBitLimit (TRNG_Type *base, uint16_t sparse_bit_limit) |
Sets the TRNG sparse bit limit. More... | |
static uint16_t | TRNG_HAL_GetSparseBitLimit (TRNG_Type *base) |
Gets the TRNG sparse bit limit. More... | |
trng_status_t | TRNG_HAL_SetRetryCount (TRNG_Type *base, uint8_t retry_count) |
Sets the TRNG retry count. More... | |
static uint8_t | TRNG_HAL_GetRetryCount (TRNG_Type *base) |
Gets the TRNG retry count. More... | |
static void | TRNG_HAL_SetLongRunMaxLimit (TRNG_Type *base, uint8_t long_run_max_limit) |
Sets the TRNG long run maximum limit. More... | |
static uint8_t | TRNG_HAL_GetLongRunMaxLimit (TRNG_Type *base) |
Gets the TRNG long run maximum limit. More... | |
void | TRNG_HAL_SetIntMode (TRNG_Type *base, trng_interrupt_t interrupt, bool enable) |
Enables or disables the related TRNG interrupt. More... | |
static bool | TRNG_HAL_GetIntMode (TRNG_Type *base, trng_interrupt_t interrupt) |
Gets whether the TRNG interrupt is enabled. More... | |
static bool | TRNG_HAL_GetIntStatusFlag (TRNG_Type *base, trng_interrupt_t interrupt) |
Gets the TRNG interrupt status. More... | |
static void | TRNG_HAL_ClearIntStatusFlag (TRNG_Type *base, trng_interrupt_t interrupt) |
Clears the interrupt status of the TRNG module. More... | |
trng_status_t | TRNG_HAL_SetStatisticalCheckLimit (TRNG_Type *base, trng_statistical_check_t statistical_check, const trng_statistical_check_limit_t *limit) |
Sets statistical check limits. More... | |
void | TRNG_HAL_GetStatisticalCheckLimit (TRNG_Type *base, trng_statistical_check_t statistical_check, trng_statistical_check_limit_t *limit) |
Gets statistical check limits. More... | |
uint32_t | TRNG_HAL_ReadEntropy (TRNG_Type *base, uint32_t index) |
Gets a entry data from the TRNG. More... | |
trng_status_t | TRNG_HAL_GetStatus (TRNG_Type *base) |
Gets the TRNG status. More... | |
struct trng_statistical_check_limit_t |
enum trng_work_mode_t |
enum trng_sample_mode_t |
enum trng_clock_mode_t |
enum trng_ring_osc_div_t |
enum trng_interrupt_t |
enum trng_status_t |
void TRNG_HAL_Init | ( | TRNG_Type * | base | ) |
This function initializes the TRNG to a default state.
base | TRNG base address |
void TRNG_HAL_Enable | ( | TRNG_Type * | base | ) |
This function enables the TRNG random data generation and loading.
base | TRNG base address |
|
inlinestatic |
This function specifies whether the TRNG is in Program Mode or Run mode.
base | TRNG base address |
mode | kTRNGWorkModeRun means set TRNG in Run Mode. kTRNGWorkModeProgram means set TRNG in Program Mode (default after init). |
|
inlinestatic |
This function disables the TRNG module and stops generation of Entropy value.
base | TRNG base address |
|
inlinestatic |
This function gets the TRNG status whether an entropy is valid.
base | TRNG base address |
|
inlinestatic |
This function gets the TRNG status whether an error is detected.
base | TRNG base address |
|
inlinestatic |
This function clears the TRNG error flag.
base | TRNG base address |
|
inlinestatic |
This function gets the TRNG status that indicates whether the TRNG ring oscillator is not running. Software should check this status before transitioning TRNG to low power mode (TRNG clock stopped). TRNG turns on the TRNG free-running ring oscillator whenever new entropy is being generated and turns off the ring oscillator when entropy generation is complete. If the TRNG clock is stopped while the TRNG ring oscillator is running, the oscillator continues running though the RNG clock. is stopped.
base | TRNG base address |
|
inlinestatic |
This function disables the possibility to program TRNG registers regardless of the TRNG working mode. After that, any attempt to modify a TRNG register causes a hard fault. Only the asynchronous reset returns the possibility to write to the TRNG registers.
base | TRNG base address |
|
inlinestatic |
This function gets current status of possibility to program TRNG registers.
base | TRNG base address |
|
inlinestatic |
This function specifies the method of sampling the ring oscillator while generating the entropy value.
base | TRNG base address |
mode | kTRNGSampleModeVonNeumann means use Von Neumann data into both Entropy shifter and Statistical Checker kTRNGSampleModeRaw means use raw data into both Entropy shifter and Statistical Checker (default value). kTRNGSampleModeVonNeumannRaw means use Von Neumann data into Entropy shifter. Use raw data into Statistical Checker. |
|
inlinestatic |
This function gets the method of sampling the ring oscillator while generating the entropy value.
base | TRNG base address |
|
inlinestatic |
This function specifies the clock mode used to operate TRNG. By default is used TRNG ring oscillator. Changing clock mode is for test use only, and indeterminate results may occur.
base | TRNG base address |
mode | kTRNGClockModeRingOscillator means use ring oscillator to operate the TRNG (default), kTRNGClockModeSystem means force system clock to operate the TRNG. |
|
inlinestatic |
This function gets the clock mode used to operate TRNG.
base | TRNG base address |
|
inlinestatic |
This function determines the amount of dividing done to the ring oscillator before it is used by the TRNG.
base | TRNG base address |
osc_div | kTRNGRingOscDiv0 means use ring oscillator with no divide (default), kTRNGRingOscDiv2 means use ring oscillator divided-by-2, kTRNGRingOscDiv4 means use ring oscillator divided-by-4, kTRNGRingOscDiv8 means use ring oscillator divided-by-8. |
|
inlinestatic |
This function gets the amount of dividing done to the ring oscillator before it is used by the TRNG.
base | TRNG base address |
|
inlinestatic |
This function sets the total number of Entropy samples that is taken during the entropy generation.
base | TRNG base address |
sample_size | Number of samples. |
|
inlinestatic |
This function gets the total number of entropy samples that are taken during the entropy generation.
base | TRNG base address |
|
inlinestatic |
This function sets the length (in system clocks) of each entropy sample taken.
base | TRNG base address |
ent_delay | Entropy delay. |
|
inlinestatic |
This function gets the length (in system clocks) of each entropy sample taken.
base | TRNG base address |
|
inlinestatic |
This function sets the Sparse Bit Limit which defines the maximum number of consecutive samples that may be discarded before an error is generated. This limit is used only for During Von Neumann sampling (enabled by TRNG_HAL_SetSampleMode()). Samples are discarded if two consecutive raw samples are both 0 or both 1. If this discarding occurs for a long period of time, it indicates that there is insufficient Entropy.
base | TRNG base address |
sparse_bit_limit | Sparse bit limit. |
|
inlinestatic |
This function gets the Sparse Bit Limit which defines the maximum number of consecutive samples that may be discarded before an error is generated. This limit is used only for During Von Neumann sampling (enabled by TRNG_HAL_SetSampleMode()). Samples are discarded if two consecutive raw samples are both 0 or both 1. If this discarding occurs for a long period of time, it indicates that there is insufficient Entropy.
base | TRNG base address |
trng_status_t TRNG_HAL_SetRetryCount | ( | TRNG_Type * | base, |
uint8_t | retry_count | ||
) |
This function sets the retry counter which defines the number of times a statistical check may fails during the TRNG entropy generation before generating an error.
base | TRNG base address |
retry_count | Retry count [1-15]. |
|
inlinestatic |
This function gets the retry counter which defines the number of times a statistical check may fails during the TRNG entropy generation before generating an error.
base | TRNG base address |
|
inlinestatic |
This function sets the largest allowable number of consecutive samples of all 1, or all 0, that is allowed during the Entropy generation.
base | TRNG base address |
long_run_max_limit | Maximum limit of consecutive samples of all 1, or all 0. |
|
inlinestatic |
This function gets value of largest allowable number of consecutive samples of all 1, or all 0, that is allowed during the Entropy generation.
base | TRNG base address |
void TRNG_HAL_SetIntMode | ( | TRNG_Type * | base, |
trng_interrupt_t | interrupt, | ||
bool | enable | ||
) |
This function enables or disables interrupts that are generated by the TRNG.
base | TRNG base address |
interrupt | The interrupt sources defined by trng_interrupt_t. |
enable | The interrupt enable switch. |
|
inlinestatic |
This function returns whether the TRNG interrupt is enabled or disabled.
base | TRNG base address |
interrupt | The interrupt sources defined by trng_interrupt_t. |
|
inlinestatic |
This function returns whether the TRNG interrupt is happened or not.
base | TRNG base address |
interrupt | The interrupt sources defined by trng_interrupt_t. |
|
inlinestatic |
This function clears the TRNG interrupt status.
base | TRNG base address |
interrupt | The interrupt source to be cleared, defined by trng_interrupt_t. |
trng_status_t TRNG_HAL_SetStatisticalCheckLimit | ( | TRNG_Type * | base, |
trng_statistical_check_t | statistical_check, | ||
const trng_statistical_check_limit_t * | limit | ||
) |
This function is used to set minimum and maximum limits of a statistical check.
base | TRNG base address |
statistical_check | type of statistical check defined by trng_statistical_check_t |
limit | Pointer to structure used to store maximum and minimum limits of statistic |
void TRNG_HAL_GetStatisticalCheckLimit | ( | TRNG_Type * | base, |
trng_statistical_check_t | statistical_check, | ||
trng_statistical_check_limit_t * | limit | ||
) |
This function is used to get current setting of minimum and maximum limits of a statistical check.
base | TRNG base address |
statistical_check | Type of statistical check defined by trng_statistical_check_t |
limit | Pointer to structure used to store maximum and minimum limits of statistic |
uint32_t TRNG_HAL_ReadEntropy | ( | TRNG_Type * | base, |
uint32_t | index | ||
) |
This function gets an entropy data from TRNG. Entropy data is spread over TRNG_ENT_COUNT registers. Read register number is defined by index parameter. Entropy data is valid only if TRNG_HAL_GetEntropyValidCmd() returns 1.
base | TRNG base address |
index | TRNG entropy register index. It is rounded by module TRNG_ENT_COUNT by the function, to be sure that register index is set to value from 0 till (TRNG_ENT_COUNT-1) and to allow incrementing of the index without the limit control from an application. |
trng_status_t TRNG_HAL_GetStatus | ( | TRNG_Type * | base | ) |
This function gets current status after the TRNG entropy generation.
base | TRNG base address |