CARME-M4 BSP  V1.5

RNG driver modules. More...

+ Collaboration diagram for RNG:

Modules

 RNG_Exported_Constants
 
 RNG_Private_Functions
 

Functions

void RNG_DeInit (void)
 De-initializes the RNG peripheral registers to their default reset values. More...
 
void RNG_Cmd (FunctionalState NewState)
 Enables or disables the RNG peripheral. More...
 
uint32_t RNG_GetRandomNumber (void)
 Returns a 32-bit random number. More...
 
void RNG_ITConfig (FunctionalState NewState)
 Enables or disables the RNG interrupt. More...
 
FlagStatus RNG_GetFlagStatus (uint8_t RNG_FLAG)
 Checks whether the specified RNG flag is set or not. More...
 
void RNG_ClearFlag (uint8_t RNG_FLAG)
 Clears the RNG flags. More...
 
ITStatus RNG_GetITStatus (uint8_t RNG_IT)
 Checks whether the specified RNG interrupt has occurred or not. More...
 
void RNG_ClearITPendingBit (uint8_t RNG_IT)
 Clears the RNG interrupt pending bit(s). More...
 

Detailed Description

RNG driver modules.

Function Documentation

void RNG_ClearFlag ( uint8_t  RNG_FLAG)

Clears the RNG flags.

Parameters
RNG_FLAGspecifies the flag to clear. This parameter can be any combination of the following values:
  • RNG_FLAG_CECS: Clock Error Current flag.
  • RNG_FLAG_SECS: Seed Error Current flag.
Note
RNG_FLAG_DRDY can not be cleared by RNG_ClearFlag() function. This flag is cleared only by reading the Random number data (using RNG_GetRandomNumber() function).
Return values
None

Definition at line 326 of file stm32f4xx_rng.c.

void RNG_ClearITPendingBit ( uint8_t  RNG_IT)

Clears the RNG interrupt pending bit(s).

Parameters
RNG_ITspecifies the RNG interrupt pending bit(s) to clear. This parameter can be any combination of the following values:
  • RNG_IT_CEI: Clock Error Interrupt.
  • RNG_IT_SEI: Seed Error Interrupt.
Return values
None

Definition at line 372 of file stm32f4xx_rng.c.

void RNG_Cmd ( FunctionalState  NewState)

Enables or disables the RNG peripheral.

Parameters
NewStatenew state of the RNG peripheral. This parameter can be: ENABLE or DISABLE.
Return values
None

Definition at line 114 of file stm32f4xx_rng.c.

void RNG_DeInit ( void  )

De-initializes the RNG peripheral registers to their default reset values.

Parameters
None
Return values
None

Definition at line 99 of file stm32f4xx_rng.c.

+ Here is the call graph for this function:

FlagStatus RNG_GetFlagStatus ( uint8_t  RNG_FLAG)

Checks whether the specified RNG flag is set or not.

Parameters
RNG_FLAGspecifies the RNG flag to check. This parameter can be one of the following values:
  • RNG_FLAG_DRDY: Data Ready flag.
  • RNG_FLAG_CECS: Clock Error Current flag.
  • RNG_FLAG_SECS: Seed Error Current flag.
Return values
Thenew state of RNG_FLAG (SET or RESET).

Definition at line 293 of file stm32f4xx_rng.c.

ITStatus RNG_GetITStatus ( uint8_t  RNG_IT)

Checks whether the specified RNG interrupt has occurred or not.

Parameters
RNG_ITspecifies the RNG interrupt source to check. This parameter can be one of the following values:
  • RNG_IT_CEI: Clock Error Interrupt.
  • RNG_IT_SEI: Seed Error Interrupt.
Return values
Thenew state of RNG_IT (SET or RESET).

Definition at line 342 of file stm32f4xx_rng.c.

uint32_t RNG_GetRandomNumber ( void  )

Returns a 32-bit random number.

Note
Before to call this function you have to wait till DRDY (data ready) flag is set, using RNG_GetFlagStatus(RNG_FLAG_DRDY) function.
Each time the the Random number data is read (using RNG_GetRandomNumber() function), the RNG_FLAG_DRDY flag is automatically cleared.
In the case of a seed error, the generation of random numbers is interrupted for as long as the SECS bit is '1'. If a number is available in the RNG_DR register, it must not be used because it may not have enough entropy. In this case, it is recommended to clear the SEIS bit(using RNG_ClearFlag(RNG_FLAG_SECS) function), then disable and enable the RNG peripheral (using RNG_Cmd() function) to reinitialize and restart the RNG.
In the case of a clock error, the RNG is no more able to generate random numbers because the PLL48CLK clock is not correct. User have to check that the clock controller is correctly configured to provide the RNG clock and clear the CEIS bit (using RNG_ClearFlag(RNG_FLAG_CECS) function) . The clock error has no impact on the previously generated random numbers, and the RNG_DR register contents can be used.
Parameters
None
Return values
32-bitrandom number.

Definition at line 176 of file stm32f4xx_rng.c.

void RNG_ITConfig ( FunctionalState  NewState)

Enables or disables the RNG interrupt.

Note
The RNG provides 3 interrupt sources,
  • Computed data is ready event (DRDY), and
  • Seed error Interrupt (SEI) and
  • Clock error Interrupt (CEI), all these interrupts sources are enabled by setting the IE bit in CR register. However, each interrupt have its specific status bit (see RNG_GetITStatus() function) and clear bit except the DRDY event (see RNG_ClearITPendingBit() function).
Parameters
NewStatenew state of the RNG interrupt. This parameter can be: ENABLE or DISABLE.
Return values
None

Definition at line 267 of file stm32f4xx_rng.c.