1.7.2.2 DRV_CRYPTO_TRNG_ReadData()

TRNG_ERROR DRV_CRYPTO_TRNG_ReadData (uint8_t * data, uint32_t size)

This function reads the specified number of 4-bit words from the TRNG and stores them in the provided buffer. It enables the random number generation and waits for the FIFO to fill with the data. If the FIFO is full, it reads the data and splits it into 8-bit values to store in the output buffer.

Parameters:
data

Buffer to store the TRNG data. The buffer size should be at least size * 4 bits to accommodate the generated random numbers.

size

Number of 4-bit words to read and store.

Return values:
TRNG_NO_ERROR

Success.

TRNG_FAILED_TO_GENERATE

Failed to generate random data.

TRNG_EXEC_FIFO

FIFO execution error.

TRNG_EXEC_STARTUP

Start-up execution error.

TRNG_EXEC_PROP

Propagation test error.

TRNG_EXEC_REP

Repetition test error.

Note:

The function will time-out if the requested random numbers cannot be generated within the specified time-out period. If the time-out occurs, the function will return an error indicating that the generation failed. After reading, the TRNG module is reset to ensure that it is ready for the next operation.