Random Number Generator Library
This Library provides a set of routines for easier handling of the Random Number Generator module available on CEC1x02.
Library Routines
- rng_power
- rng_reset
- rng_mode
- rng_is_on
- rng_start
- rng_stop
- rng_get_fifo_level
- rng_get_bytes
- rng_get_words
rng_power
Prototype |
// for CEC1302 MCU :
void rng_power(uint16_t pwr_on); // for CEC1702 MCU :void rng_power(uint8_t pwr_on); |
||||||
---|---|---|---|---|---|---|---|
Description |
This routine is used for power control of the RNG block. |
||||||
Parameters |
pwr_on: power parameter. Valid values :
|
||||||
Returns |
Nothing. |
||||||
Requires |
Nothing. |
||||||
Notes |
None. |
rng_reset
Prototype |
void rng_reset(); |
---|---|
Description |
This routine resets the RNG block. |
Parameters |
None. |
Returns |
Nothing. |
Requires |
Nothing. |
Notes |
None. |
rng_mode
Prototype |
void rng_mode(uint8_t mode); |
||||||
---|---|---|---|---|---|---|---|
Description |
The function controls the mode of RNG. |
||||||
Parameters |
|
||||||
Returns |
Nothing. |
||||||
Requires |
Nothing. |
||||||
Notes |
None. |
rng_is_on
Prototype |
// for CEC1302 MCU :
uint16_t rng_is_on(); // for CEC1702 MCU :uint8_t rng_is_on(); |
---|---|
Description |
This function is used to check if the NDRNG block is powered on. |
Parameters | tmode_pseudo |
Returns |
|
Requires |
Nothing. |
Notes |
None. |
rng_start
Prototype |
void rng_start(); |
---|---|
Description |
This routine is used to start the NDRNG engine. Once started, the NDRNG will fill its internal 1Kbit internal FIFO with random bits.
|
Parameters | tmode_pseudo |
Returns |
Nothing. |
Requires |
Nothing. |
Notes |
None. |
rng_stop
Prototype |
void rng_stop(); |
---|---|
Description |
This routine stops the NDRNG engine. When the engine is stopped, the NDRNG will not re-fill its FIFO when data is removed. |
Parameters |
None. |
Returns |
Nothing. |
Requires |
Nothing. |
Notes |
None. |
rng_get_fifo_level
Prototype |
uint32_t rng_get_fifo_level(); |
---|---|
Description |
This routine reads the NDRNG FIFO level register and returns the number of 32-bit words of random data currently in FIFO.
|
Parameters |
None. |
Returns |
Returns the number of 32-bit words in the NDRNG FIFO. Maximum value is 32 (32x32 = 1024 bits). |
Requires |
Nothing. |
Notes |
None. |
rng_get_bytes
Prototype |
uint32_t rng_get_bytes(uint8_t * pbuff, uint32_t nbytes); |
---|---|
Description |
This routine fills a buffer with random bytes. |
Parameters |
|
Returns |
The number of bytes retrieved is returned. |
Requires |
Nothing. |
Notes |
The API reads 32 bits at a time from FIFO. If bytes are requested, a 32 bit word is read and 4 bytes are retrieved. However, only the number of bytes requested is returned. |
rng_get_words
Prototype |
uint32_t rng_get_words(uint32_t *pwords, uint32_t nwords); |
---|---|
Description |
This function reads a specified number of words (32-bit data) into the buffer specified by the caller. This function is an all-in-one routine.
|
Parameters |
|
Returns |
Returns the actual number of bytes read. |
Requires |
Nothing. |
Notes |
No time out is implemented, if the NDRNG FIFO hardware stops filling the FIFO, this routine will loop forever. |
What do you think about this topic ? Send us feedback!