|
trng 1.0
trng driver library
|
Header file with declarations and macros for the True Random Number Generator (TRNG) module. More...

Go to the source code of this file.
Macros | |
| #define | TRNG_BUFFER_SIZE 10UL |
| Size of the internal random data buffer in bytes. | |
Typedefs | |
| typedef enum TRNG_Buffer_t | TRNG_Buffer |
| Alias for enum TRNG_Buffer_t representing the TRNG buffer status type. | |
Enumerations | |
| enum | TRNG_Buffer_t { TRNG_Buffer_Empty = 0 , TRNG_Buffer_Filling , TRNG_Buffer_Full } |
| Represents the current fill status of the TRNG data buffer. More... | |
Functions | |
| void | trng_init (void) |
| Initializes the True Random Number Generator (TRNG) module. | |
| void | trng_next_bit (unsigned char bit) |
| Processes a single entropy bit and adds it to the TRNG buffer. | |
| TRNG_Buffer | trng_buffer_status (void) |
| Returns the current fill status of the TRNG buffer. | |
| volatile unsigned char * | trng_buffer (void) |
| Returns a pointer to the internal TRNG buffer. | |
| void | trng_reset (void) |
| Returns a pointer to the internal TRNG buffer. | |
Header file with declarations and macros for the True Random Number Generator (TRNG) module.
This file provides function prototypes, type definitions, and constants for managing a True Random Number Generator that collects entropy bits, applies Von Neumann correction, and stores the resulting random data in a configurable buffer.
The TRNG library is designed for use in embedded systems where nondeterministic randomness is required, such as for cryptographic operations, random initialization data, or simulation purposes.
| #define TRNG_BUFFER_SIZE 10UL |
Size of the internal random data buffer in bytes.
This macro defines the number of bytes the TRNG (True Random Number Generator) uses internally to store generated random bits temporarily. The buffer is filled until it reaches the specified size.
| typedef enum TRNG_Buffer_t TRNG_Buffer |
Alias for enum TRNG_Buffer_t representing the TRNG buffer status type.
| enum TRNG_Buffer_t |
Represents the current fill status of the TRNG data buffer.
This enumeration indicates the current state of the internal True Random Number Generator (TRNG) buffer used to store random bits. It helps determine whether the buffer is empty, currently being filled with new data, or already full.
| volatile unsigned char * trng_buffer | ( | void | ) |
Returns a pointer to the internal TRNG buffer.
This function provides direct access to the internal memory buffer that stores the corrected random bytes generated by the True Random Number Generator (TRNG). The buffer can be read once the buffer status, retrieved by trng_buffer_status(), indicates that it is full.
| TRNG_Buffer trng_buffer_status | ( | void | ) |
Returns the current fill status of the TRNG buffer.
This function checks the internal TRNG buffer and reports whether it is empty, partially filled, or completely full. It uses internal position counters to determine the current state of the random data storage.
The return value can be one of the following:
| void trng_init | ( | void | ) |
Initializes the True Random Number Generator (TRNG) module.
This function prepares the TRNG module for operation by resetting its internal state and buffer. It should be called once during system initialization before feeding entropy bits using trng_next_bit(). Internally, this function calls trng_reset() to clear all buffer data and reset counters.

| void trng_next_bit | ( | unsigned char | bit | ) |
Processes a single entropy bit and adds it to the TRNG buffer.
This function is called repeatedly with raw entropy bits obtained from a hardware or software noise source. It applies the Von Neumann correction algorithm to remove bias from the input bit sequence and produces unbiased random bits. The corrected bits are packed into the internal TRNG buffer until it reaches the configured size defined by TRNG_BUFFER_SIZE. Once the buffer is full, no further bits are stored until it is reset.
| bit | The next raw entropy bit to process (must be 0 or 1). |
| void trng_reset | ( | void | ) |
Returns a pointer to the internal TRNG buffer.
This function provides direct access to the internal memory buffer that stores the corrected random bytes generated by the True Random Number Generator (TRNG). The buffer can be read once the buffer status, retrieved by trng_buffer_status(), indicates that it is full.
