The pseudo random bit generator (PRNG) provides random data with fast generation times. PRNG has to be initialized by the user software before use. The initialization consists of two basic phases: key-loading and warm-up.
The PRNG low level driver provides functions to configure and initialize the PRNG hardware peripheral.
◆ XMC_PRNG_RDBS_BYTE_READ_MASK
#define XMC_PRNG_RDBS_BYTE_READ_MASK (0x00FFU) |
Byte mask value for random data block size
◆ XMC_PRNG_DATA_BLOCK_SIZE_t
PRNG data block size
Enumerator |
---|
XMC_PRNG_RDBS_RESET | Reset state (no random data block size defined)
|
XMC_PRNG_RDBS_BYTE | BYTE (8-bit)
|
XMC_PRNG_RDBS_WORD | WORD (16-bit)
|
◆ XMC_PRNG_INIT_STATUS_t
PRNG driver initialization status
Enumerator |
---|
XMC_PRNG_NOT_INITIALIZED | Reset state or Non-initialized state (Same as XMC_PRNG_RDBS_RESET)
|
XMC_PRNG_INITIALIZED | Initialized state
|
◆ XMC_PRNG_KEY_LOAD_OP_MODE_t
PRNG key load operation modes
Enumerator |
---|
XMC_PRNG_STRM_MODE | Streaming mode (default)
|
XMC_PRNG_KLD_MODE | Loading mode
|
◆ XMC_PRNG_CheckValidStatus()
uint16_t XMC_PRNG_CheckValidStatus |
( |
void |
| ) |
|
- Returns
- None
- Description:
- Checks the validity (CHK.RDV bit) of the generated random data
- The function checks the validity (CHK.RDV bit) of the generated random data. In key loading mode, this value indicates if the next partial key word can be written to PRNG_WORD or not.
◆ XMC_PRNG_EnableKeyLoadingMode()
void XMC_PRNG_EnableKeyLoadingMode |
( |
void |
| ) |
|
- Returns
- None
- Description:
- Enables the PRNG key loading mode
- The function initializes the key loading by setting the bit CTRL.KLD. In this mode, Register WORD acts as always as a 16 bit destination register. After the complete key has been loaded, the CTRL.KLD must be set to '0' to prepare the following warmup phase.
- Related APIs:
- XMC_PRNG_EnableStreamingMode()
◆ XMC_PRNG_EnableStreamingMode()
void XMC_PRNG_EnableStreamingMode |
( |
void |
| ) |
|
- Returns
- None
- Description:
- Enables the Streaming mode
- The function enables the streaming mode and disables the PRNG key loading mode by resetting the CTRL.KLD bit.
- Related APIs:
- XMC_PRNG_EnableKeyLoadingMode()
◆ XMC_PRNG_GetPseudoRandomNumber()
uint16_t XMC_PRNG_GetPseudoRandomNumber |
( |
void |
| ) |
|
- Parameters
-
- Returns
- uint16_t Generated random number
- Description:
- Gets the generated random number
- The function gives the generated random number by returning the content of WORD register. Before reading the WORD register to get the generated random number it is required to check the bit CHK.RDV is set which indicates that the next random data block can be read from WORD register. After a word has been read the bit CHK.RDV is reset by the hardware and generation of new random bits starts.
- Related APIs:
- XMC_PRNG_CheckValidStatus()
◆ XMC_PRNG_Init()
- Parameters
-
prng | Pointer to a constant instance of XMC_PRNG_INIT_t, pointing to the initialization configuration. |
- Returns
- XMC_PRNG_INIT_STATUS_t XMC_PRNG_INITIALIZED if initialized, XMC_PRNG_NOT_INITIALIZED otherwise.
- Description:
- Initialize the PRNG peripheral with the configured key words and block size
- The function configures block size for key loading mode, enables key loading mode, loads key words (80 bits) and wait till RDV is set, enables the streaming mode and waits for warmup phase. This function programmes the CTRL and WORD registers.
◆ XMC_PRNG_LoadKeyWords()
void XMC_PRNG_LoadKeyWords |
( |
uint16_t |
key | ) |
|
- Parameters
-
key | Key word to load into PRNG WORD register |
- Returns
- None
- Description:
- Loads a partial key word to the PRNG WORD register
- The function loads partial key word to WORD registr. These partial words are sequentially written and loading a key word will take 16 clock cycles. The CHK.RDV bit is set to '0' while loading is in progress. '1' indicates that the next partial key word can be written to WORD register.
◆ XMC_PRNG_SetRandomDataBlockSize()
- Parameters
-
- Returns
- None
- Description:
- Programming Random Block Size
- The function sets the random data block size as byte or word by programming CTRL.RDBS bitfield. block_size = 0 for Reset state, block_size = 1 for 'byte' and block_size = 2 for 'word'.