MSPM0L111X Driver Library  2.05.01.00
Modules | Data Structures | Enumerations | Functions
True Random Number Generator (TRNG)
Collaboration diagram for True Random Number Generator (TRNG):

Modules

 DL_TRNG_INTERRUPT
 
 DL_TRNG_HEALTH_TEST_SUCCESS
 

Data Structures

struct  DL_TRNG_backupConfig
 Configuration structure to backup TRNG peripheral state before going to STOP/STANDBY mode. Used by DL_TRNG_saveConfiguration. More...
 

Enumerations

enum  DL_TRNG_IIDX {
  DL_TRNG_IIDX_HEALTH_FAIL = TRNG_IIDX_STAT_IRQ_HEALTH_FAIL,
  DL_TRNG_IIDX_CMD_DONE = TRNG_IIDX_STAT_IRQ_CMD_DONE,
  DL_TRNG_IIDX_CMD_FAIL = TRNG_IIDX_STAT_IRQ_CMD_FAIL,
  DL_TRNG_IIDX_CAPTURED_READY = TRNG_IIDX_STAT_IRQ_CAPTURED_RDY
}
 
enum  DL_TRNG_DECIMATION_RATE {
  DL_TRNG_DECIMATION_RATE_1 = 0x0,
  DL_TRNG_DECIMATION_RATE_2 = 0x1,
  DL_TRNG_DECIMATION_RATE_3 = 0x2,
  DL_TRNG_DECIMATION_RATE_4 = 0x3,
  DL_TRNG_DECIMATION_RATE_5 = 0x4,
  DL_TRNG_DECIMATION_RATE_6 = 0x5,
  DL_TRNG_DECIMATION_RATE_7 = 0x6,
  DL_TRNG_DECIMATION_RATE_8 = 0x7
}
 
enum  DL_TRNG_CMD {
  DL_TRNG_CMD_PWROFF = TRNG_CTL_CMD_PWR_OFF,
  DL_TRNG_CMD_TEST_DIG = TRNG_CTL_CMD_PWRUP_DIG,
  DL_TRNG_CMD_TEST_ANA = TRNG_CTL_CMD_PWRUP_ANA,
  DL_TRNG_CMD_NORM_FUNC = TRNG_CTL_CMD_NORM_FUNC
}
 
enum  DL_TRNG_CLOCK_DIVIDE {
  DL_TRNG_CLOCK_DIVIDE_1 = TRNG_CLKDIVIDE_RATIO_DIV_BY_1,
  DL_TRNG_CLOCK_DIVIDE_2 = TRNG_CLKDIVIDE_RATIO_DIV_BY_2,
  DL_TRNG_CLOCK_DIVIDE_4 = TRNG_CLKDIVIDE_RATIO_DIV_BY_4,
  DL_TRNG_CLOCK_DIVIDE_6 = TRNG_CLKDIVIDE_RATIO_DIV_BY_6,
  DL_TRNG_CLOCK_DIVIDE_8 = TRNG_CLKDIVIDE_RATIO_DIV_BY_8
}
 
enum  DL_TRNG_STATE {
  DL_TRNG_STATE_OFF = 0x0,
  DL_TRNG_STATE_PWRUP_ES = 0x1,
  DL_TRNG_STATE_NORM_FUNC = 0x3,
  DL_TRNG_STATE_TEST_DIG = 0x7,
  DL_TRNG_STATE_TEST_ANA = 0xB,
  DL_TRNG_STATE_ERROR = 0xA,
  DL_TRNG_STATE_PWRDOWN = 0x2
}
 

Functions

__STATIC_INLINE void DL_TRNG_enablePower (TRNG_Regs *trng)
 Enables the Peripheral Write Enable (PWREN) register for the TRNG. More...
 
__STATIC_INLINE void DL_TRNG_disablePower (TRNG_Regs *trng)
 Disables the Peripheral Write Enable (PWREN) register for the TRNG. More...
 
__STATIC_INLINE bool DL_TRNG_isPowerEnabled (TRNG_Regs *trng)
 Returns if the Peripheral Write Enable (PWREN) register for the TRNG is enabled. More...
 
__STATIC_INLINE DL_TRNG_CLOCK_DIVIDE DL_TRNG_getClockDivider (const TRNG_Regs *trng)
 Get the clock divider on the TRNG module. More...
 
__STATIC_INLINE void DL_TRNG_setClockDivider (TRNG_Regs *trng, DL_TRNG_CLOCK_DIVIDE clockDivider)
 Set the clock divider on the TRNG module. More...
 
__STATIC_INLINE void DL_TRNG_reset (TRNG_Regs *trng)
 Resets the TRNG module. More...
 
__STATIC_INLINE bool DL_TRNG_isReset (const TRNG_Regs *trng)
 Returns if TRNG peripheral was reset. More...
 
__STATIC_INLINE bool DL_TRNG_isCaptureReady (const TRNG_Regs *trng)
 Returns if the data capture is ready. More...
 
__STATIC_INLINE bool DL_TRNG_isCommandDone (const TRNG_Regs *trng)
 Returns if the issued TRNG command is done. More...
 
__STATIC_INLINE bool DL_TRNG_isCommandFail (const TRNG_Regs *trng)
 Returns if the issued TRNG command failed. More...
 
__STATIC_INLINE bool DL_TRNG_isHealthTestFail (const TRNG_Regs *trng)
 Returns if a health test failed. More...
 
__STATIC_INLINE void DL_TRNG_setDecimationRate (TRNG_Regs *trng, DL_TRNG_DECIMATION_RATE decimationRate)
 Set the decimation rate. More...
 
__STATIC_INLINE DL_TRNG_DECIMATION_RATE DL_TRNG_getDecimationRate (const TRNG_Regs *trng)
 Get the decimation rate. More...
 
__STATIC_INLINE uint8_t DL_TRNG_getDigitalHealthTestResults (const TRNG_Regs *trng)
 Get the digital health test results. More...
 
__STATIC_INLINE uint8_t DL_TRNG_getAnalogHealthTestResults (const TRNG_Regs *trng)
 Get the analog health test results. More...
 
__STATIC_INLINE uint32_t DL_TRNG_getCurrentState (const TRNG_Regs *trng)
 Get the current state of the TRNG front end FSM. More...
 
__STATIC_INLINE uint32_t DL_TRNG_getIssuedCommand (const TRNG_Regs *trng)
 Get the last accepted command that was issued to the TRNG. More...
 
__STATIC_INLINE bool DL_TRNG_isRepetitionTestFail (const TRNG_Regs *trng)
 Indicates if the repetition counter test caused the most recent failure. More...
 
__STATIC_INLINE bool DL_TRNG_isAdaptiveTestFail (const TRNG_Regs *trng)
 Indicates if the Adaptive Proportion Test (1,2,3, or 4-bit counters) caused the most recent failure. More...
 
__STATIC_INLINE void DL_TRNG_enableInterrupt (TRNG_Regs *trng, uint32_t interruptMask)
 Enable TRNG interrupt. More...
 
__STATIC_INLINE void DL_TRNG_disableInterrupt (TRNG_Regs *trng, uint32_t interruptMask)
 Disable TRNG interrupt. More...
 
__STATIC_INLINE uint32_t DL_TRNG_getEnabledInterrupts (const TRNG_Regs *trng, uint32_t interruptMask)
 Check which TRNG interrupts are enabled. More...
 
__STATIC_INLINE uint32_t DL_TRNG_getEnabledInterruptStatus (const TRNG_Regs *trng, uint32_t interruptMask)
 Check interrupt flag of enabled TRNG interrupt. More...
 
__STATIC_INLINE uint32_t DL_TRNG_getRawInterruptStatus (const TRNG_Regs *trng, uint32_t interruptMask)
 Check interrupt flag of any TRNG interrupt. More...
 
__STATIC_INLINE DL_TRNG_IIDX DL_TRNG_getPendingInterrupt (const TRNG_Regs *trng)
 Get highest priority pending TRNG interrupt. More...
 
__STATIC_INLINE void DL_TRNG_clearInterruptStatus (TRNG_Regs *trng, uint32_t interruptMask)
 Clear pending TRNG interrupt. More...
 
__STATIC_INLINE void DL_TRNG_sendCommand (TRNG_Regs *trng, DL_TRNG_CMD cmd)
 Update control register's command bits to send a TRNG command. More...
 
__STATIC_INLINE uint32_t DL_TRNG_getCapture (const TRNG_Regs *trng)
 Get word capture from TRNG. More...
 
bool DL_TRNG_saveConfiguration (const TRNG_Regs *trng, DL_TRNG_backupConfig *ptr)
 Save TRNG configuration before entering a power loss state. More...
 
bool DL_TRNG_restoreConfiguration (TRNG_Regs *trng, DL_TRNG_backupConfig *ptr)
 Restore TRNG configuration after leaving a power loss state. Upon restoration, if the TRNG was not originally in OFF state, then the TRNG will be set to the normal operating mode. More...
 

Detailed Description

Overview

The True Random Number Generator Driver Library allows full configuration of the MSPM0 TRNG module. The true random number generator (TRNG) block is an entropy source which can be used to generate random bit sequences.


Enumeration Type Documentation

§ DL_TRNG_IIDX

Enumerator
DL_TRNG_IIDX_HEALTH_FAIL 

TRNG interrupt index for health fail

DL_TRNG_IIDX_CMD_DONE 

TRNG interrupt index for command done

DL_TRNG_IIDX_CMD_FAIL 

TRNG interrupt index for command fail

DL_TRNG_IIDX_CAPTURED_READY 

TRNG interrupt index indicating the capture buffer is ready

§ DL_TRNG_DECIMATION_RATE

Enumerator
DL_TRNG_DECIMATION_RATE_1 

Decimation by 1 (no decimation)

DL_TRNG_DECIMATION_RATE_2 

Decimation rate 2 – take every other sample

DL_TRNG_DECIMATION_RATE_3 

Decimation rate 3 – take every third sample

DL_TRNG_DECIMATION_RATE_4 

Decimation rate 4 – take every fourth sample

DL_TRNG_DECIMATION_RATE_5 

Decimation rate 5 – take every fifth sample

DL_TRNG_DECIMATION_RATE_6 

Decimation rate 6 – take every sixth sample

DL_TRNG_DECIMATION_RATE_7 

Decimation rate 7 – take every seventh sample

DL_TRNG_DECIMATION_RATE_8 

Decimation rate 8 – take every eighth sample

§ DL_TRNG_CMD

Enumerator
DL_TRNG_CMD_PWROFF 

TRNG command to power off analog blocks and digital blocks are gated

DL_TRNG_CMD_TEST_DIG 

TRNG command to execute digital power-on self-tests

DL_TRNG_CMD_TEST_ANA 

TRNG command to execute digital power-on self-tests

DL_TRNG_CMD_NORM_FUNC 

TRNG command to go into normal operating mode

§ DL_TRNG_CLOCK_DIVIDE

Enumerator
DL_TRNG_CLOCK_DIVIDE_1 

Clock divide by 1

DL_TRNG_CLOCK_DIVIDE_2 

Clock divide by 2

DL_TRNG_CLOCK_DIVIDE_4 

Clock divide by 4

DL_TRNG_CLOCK_DIVIDE_6 

Clock divide by 6

DL_TRNG_CLOCK_DIVIDE_8 

Clock divide by 8

§ DL_TRNG_STATE

Enumerator
DL_TRNG_STATE_OFF 

Current state of the TRNG is OFF

DL_TRNG_STATE_PWRUP_ES 

Current state of the TRNG is PWRUP_ES

DL_TRNG_STATE_NORM_FUNC 

Current state of the TRNG is NORM_FUNC

DL_TRNG_STATE_TEST_DIG 

Current state of the TRNG is TEST_DIG

DL_TRNG_STATE_TEST_ANA 

Current state of the TRNG is TEST_ANA

DL_TRNG_STATE_ERROR 

Current state of the TRNG is ERROR

DL_TRNG_STATE_PWRDOWN 

Current state of the TRNG is PWRDOWN_ES

Function Documentation

§ DL_TRNG_enablePower()

__STATIC_INLINE void DL_TRNG_enablePower ( TRNG_Regs *  trng)

Enables the Peripheral Write Enable (PWREN) register for the TRNG.

Before any peripheral registers can be configured by software, the peripheral itself must be enabled by writing the ENABLE bit together with the appropriate KEY value to the peripheral's PWREN register.

Parameters
trngPointer to the register overlay for the peripheral

§ DL_TRNG_disablePower()

__STATIC_INLINE void DL_TRNG_disablePower ( TRNG_Regs *  trng)

Disables the Peripheral Write Enable (PWREN) register for the TRNG.

When the PWREN.ENABLE bit is cleared, the peripheral's registers are not accessible for read/write operations.

Note
This API does not provide large power savings.
Parameters
trngPointer to the register overlay for the peripheral

§ DL_TRNG_isPowerEnabled()

__STATIC_INLINE bool DL_TRNG_isPowerEnabled ( TRNG_Regs *  trng)

Returns if the Peripheral Write Enable (PWREN) register for the TRNG is enabled.

Before any peripheral registers can be configured by software, the peripheral itself must be enabled by writing the ENABLE bit together with the appropriate KEY value to the peripheral's PWREN register.

When the PWREN.ENABLE bit is cleared, the peripheral's registers are not accessible for read/write operations.

Parameters
trngPointer to the register overlay for the peripheral
Returns
true if peripheral register access is enabled
false if peripheral register access is disabled

§ DL_TRNG_getClockDivider()

__STATIC_INLINE DL_TRNG_CLOCK_DIVIDE DL_TRNG_getClockDivider ( const TRNG_Regs *  trng)

Get the clock divider on the TRNG module.

Parameters
trngPointer to the register overlay for the peripheral
Returns
Clock divider value for the TRNG module

§ DL_TRNG_setClockDivider()

__STATIC_INLINE void DL_TRNG_setClockDivider ( TRNG_Regs *  trng,
DL_TRNG_CLOCK_DIVIDE  clockDivider 
)

Set the clock divider on the TRNG module.

Parameters
trngPointer to the register overlay for the peripheral
clockDividerClock divider value for the TRNG module. One of DL_TRNG_CLOCK_DIVIDE

§ DL_TRNG_reset()

__STATIC_INLINE void DL_TRNG_reset ( TRNG_Regs *  trng)

Resets the TRNG module.

Parameters
trngPointer to the register overlay for the peripheral

§ DL_TRNG_isReset()

__STATIC_INLINE bool DL_TRNG_isReset ( const TRNG_Regs *  trng)

Returns if TRNG peripheral was reset.

Parameters
trngPointer to the register overlay for the peripheral
Returns
true if peripheral was reset
false if peripheral wasn't reset

§ DL_TRNG_isCaptureReady()

__STATIC_INLINE bool DL_TRNG_isCaptureReady ( const TRNG_Regs *  trng)

Returns if the data capture is ready.

Parameters
trngPointer to the register overlay for the peripheral
Returns
true if the data capture is ready
false if the data capture is not ready

§ DL_TRNG_isCommandDone()

__STATIC_INLINE bool DL_TRNG_isCommandDone ( const TRNG_Regs *  trng)

Returns if the issued TRNG command is done.

Parameters
trngPointer to the register overlay for the peripheral
Returns
true if the issued command is done
false if the issued command is not done

§ DL_TRNG_isCommandFail()

__STATIC_INLINE bool DL_TRNG_isCommandFail ( const TRNG_Regs *  trng)

Returns if the issued TRNG command failed.

Parameters
trngPointer to the register overlay for the peripheral
Returns
true if the issued command failed
false if the issued command failed

§ DL_TRNG_isHealthTestFail()

__STATIC_INLINE bool DL_TRNG_isHealthTestFail ( const TRNG_Regs *  trng)

Returns if a health test failed.

Parameters
trngPointer to the register overlay for the peripheral
Returns
true if a health test is failed
false if a health test did not fail

§ DL_TRNG_setDecimationRate()

__STATIC_INLINE void DL_TRNG_setDecimationRate ( TRNG_Regs *  trng,
DL_TRNG_DECIMATION_RATE  decimationRate 
)

Set the decimation rate.

Parameters
trngPointer to the register overlay for the peripheral
decimationRateDecimation rate to set. One of DL_TRNG_DECIMATION_RATE

References DL_Common_updateReg().

§ DL_TRNG_getDecimationRate()

__STATIC_INLINE DL_TRNG_DECIMATION_RATE DL_TRNG_getDecimationRate ( const TRNG_Regs *  trng)

Get the decimation rate.

Parameters
[in]trngPointer to the register overlay for the peripheral
Returns
The decimation rate of the TRNG module
Return values
Oneof DL_TRNG_DECIMATION_RATE

§ DL_TRNG_getDigitalHealthTestResults()

__STATIC_INLINE uint8_t DL_TRNG_getDigitalHealthTestResults ( const TRNG_Regs *  trng)

Get the digital health test results.

The test sequence includes eight tests, and each test reports its status in an individual result bit. As each test passes, the corresponding bit is set.

Parameters
trngPointer to the register overlay for the peripheral
Returns
The results of the digital health tests
Return values
DL_TRNG_DIGITAL_HEALTH_TEST_SUCCESSif all tests passed, otherwise a bitmask of which tests passed

§ DL_TRNG_getAnalogHealthTestResults()

__STATIC_INLINE uint8_t DL_TRNG_getAnalogHealthTestResults ( const TRNG_Regs *  trng)

Get the analog health test results.

Parameters
trngPointer to the register overlay for the peripheral
Returns
The results of the analog health test
Return values
DL_TRNG_ANALOG_HEALTH_TEST_SUCCESSif success
0if test failed

§ DL_TRNG_getCurrentState()

__STATIC_INLINE uint32_t DL_TRNG_getCurrentState ( const TRNG_Regs *  trng)

Get the current state of the TRNG front end FSM.

This API should be called twice since two reads of the state are required as there is a chance of metastability when reading this register.

Parameters
trngPointer to the register overlay for the peripheral
Returns
The current state of the TRNG
Return values
Oneof DL_TRNG_STATE

§ DL_TRNG_getIssuedCommand()

__STATIC_INLINE uint32_t DL_TRNG_getIssuedCommand ( const TRNG_Regs *  trng)

Get the last accepted command that was issued to the TRNG.

Parameters
trngPointer to the register overlay for the peripheral
Returns
The last issued accepted command
Return values
Oneof DL_TRNG_CMD

§ DL_TRNG_isRepetitionTestFail()

__STATIC_INLINE bool DL_TRNG_isRepetitionTestFail ( const TRNG_Regs *  trng)

Indicates if the repetition counter test caused the most recent failure.

Parameters
trngPointer to the register overlay for the peripheral
Returns
The status of the repetition test
Return values
trueif the repetition test failed
falseif the repetition test did not fail

§ DL_TRNG_isAdaptiveTestFail()

__STATIC_INLINE bool DL_TRNG_isAdaptiveTestFail ( const TRNG_Regs *  trng)

Indicates if the Adaptive Proportion Test (1,2,3, or 4-bit counters) caused the most recent failure.

Parameters
trngPointer to the register overlay for the peripheral
Returns
The status of the Adaptive Proportion Test
Return values
trueif the repetition test failed
falseif the repetition test did not fail

§ DL_TRNG_enableInterrupt()

__STATIC_INLINE void DL_TRNG_enableInterrupt ( TRNG_Regs *  trng,
uint32_t  interruptMask 
)

Enable TRNG interrupt.

Parameters
[in]trngPointer to the register overlay for the peripheral
[in]interruptMaskBit mask of interrupts to check. Bitwise OR of DL_TRNG_INTERRUPT.

§ DL_TRNG_disableInterrupt()

__STATIC_INLINE void DL_TRNG_disableInterrupt ( TRNG_Regs *  trng,
uint32_t  interruptMask 
)

Disable TRNG interrupt.

Parameters
[in]trngPointer to the register overlay for the peripheral
[in]interruptMaskBit mask of interrupts to check. Bitwise OR of DL_TRNG_INTERRUPT.

§ DL_TRNG_getEnabledInterrupts()

__STATIC_INLINE uint32_t DL_TRNG_getEnabledInterrupts ( const TRNG_Regs *  trng,
uint32_t  interruptMask 
)

Check which TRNG interrupts are enabled.

Parameters
[in]trngPointer to the register overlay for the peripheral
[in]interruptMaskBit mask of interrupts to check. Bitwise OR of DL_TRNG_IIDX.
Returns
Which of the requested TRNG interrupts are enabled
Return values
BitwiseOR of DL_TRNG_INTERRUPT values

§ DL_TRNG_getEnabledInterruptStatus()

__STATIC_INLINE uint32_t DL_TRNG_getEnabledInterruptStatus ( const TRNG_Regs *  trng,
uint32_t  interruptMask 
)

Check interrupt flag of enabled TRNG interrupt.

Checks if the TRNG interrupt that was previously enabled is pending.

Parameters
[in]trngPointer to the register overlay for the peripheral
[in]interruptMaskBit mask of interrupts to check. Bitwise OR of DL_TRNG_INTERRUPT.
Returns
If the enabled TRNG interrupt is pending
See also
DL_TRNG_enableInterrupt

§ DL_TRNG_getRawInterruptStatus()

__STATIC_INLINE uint32_t DL_TRNG_getRawInterruptStatus ( const TRNG_Regs *  trng,
uint32_t  interruptMask 
)

Check interrupt flag of any TRNG interrupt.

Checks if the TRNG interrupt is pending. Interrupt does not have to be previously enabled.

Parameters
[in]trngPointer to the register overlay for the peripheral
[in]interruptMaskBit mask of interrupts to check. Bitwise OR of DL_TRNG_INTERRUPT.
Returns
If the trng interrupt is pending

§ DL_TRNG_getPendingInterrupt()

__STATIC_INLINE DL_TRNG_IIDX DL_TRNG_getPendingInterrupt ( const TRNG_Regs *  trng)

Get highest priority pending TRNG interrupt.

Checks if any of the TRNG interrupts are pending. Interrupts do not have to be previously enabled.

Parameters
[in]trngPointer to the register overlay for the peripheral
Returns
The highest priority pending TRNG interrupt
Return values
Oneof DL_TRNG_IIDX

§ DL_TRNG_clearInterruptStatus()

__STATIC_INLINE void DL_TRNG_clearInterruptStatus ( TRNG_Regs *  trng,
uint32_t  interruptMask 
)

Clear pending TRNG interrupt.

Parameters
[in]trngPointer to the register overlay for the peripheral
[in]interruptMaskBit mask of interrupts to check. Bitwise OR of DL_TRNG_INTERRUPT.

§ DL_TRNG_sendCommand()

__STATIC_INLINE void DL_TRNG_sendCommand ( TRNG_Regs *  trng,
DL_TRNG_CMD  cmd 
)

Update control register's command bits to send a TRNG command.

Parameters
[in]trngPointer to the register overlay for the peripheral
[in]cmdCommand to update the control register with

References DL_Common_updateReg().

§ DL_TRNG_getCapture()

__STATIC_INLINE uint32_t DL_TRNG_getCapture ( const TRNG_Regs *  trng)

Get word capture from TRNG.

Gets the captured data from the decimation block.

Parameters
[in]trngPointer to the register overlay for the peripheral
Return values
TRNGcapture value
Precondition
The IRQ_CAPTURED_RDY IRQ should be asserted first, indicating that random bits are available for read-out.
See also
DL_TRNG_isCaptureReady

References DL_TRNG_restoreConfiguration(), and DL_TRNG_saveConfiguration().

§ DL_TRNG_saveConfiguration()

bool DL_TRNG_saveConfiguration ( const TRNG_Regs *  trng,
DL_TRNG_backupConfig ptr 
)

Save TRNG configuration before entering a power loss state.

Parameters
[in]trngPointer to the register overlay for the peripheral
[in]ptrConfiguration backup setup structure. See DL_TRNG_backupConfig.
Return values
FALSEif a configuration already exists in ptr (will not be overwritten). TRUE if a configuration was successfully saved

Referenced by DL_TRNG_getCapture().

§ DL_TRNG_restoreConfiguration()

bool DL_TRNG_restoreConfiguration ( TRNG_Regs *  trng,
DL_TRNG_backupConfig ptr 
)

Restore TRNG configuration after leaving a power loss state. Upon restoration, if the TRNG was not originally in OFF state, then the TRNG will be set to the normal operating mode.

Parameters
[in]trngPointer to the register overlay for the peripheral
[in]ptrConfiguration backup setup structure. See DL_TRNG_backupConfig.
Return values
FALSEif a configuration does not exist in ptr (will not be loaded). TRUE if a configuration successfully loaded

Referenced by DL_TRNG_getCapture().

© Copyright 1995-2025, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale