STM32F4 Standard Peripheral bibliotheek  1.0
ST Microelectronics bibliotheek documentatie voor de STM32F4 Standard Peripheral Library
 All Data Structures Files Functions Variables Enumerations Enumerator Groups

RNG driver modules. More...

Modules

 RNG_Exported_Constants
 
 RNG_Private_Functions
 

Functions

void RNG_DeInit (void)
 Deinitializes 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_FLAG,:specifies 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
void RNG_ClearITPendingBit ( uint8_t  RNG_IT)

Clears the RNG interrupt pending bit(s).

Parameters
RNG_IT,:specifies 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
void RNG_Cmd ( FunctionalState  NewState)

Enables or disables the RNG peripheral.

Parameters
NewState,:new state of the RNG peripheral. This parameter can be: ENABLE or DISABLE.
Return values
None
void RNG_DeInit ( void  )

Deinitializes the RNG peripheral registers to their default reset values.

Parameters
None
Return values
None
FlagStatus RNG_GetFlagStatus ( uint8_t  RNG_FLAG)

Checks whether the specified RNG flag is set or not.

Parameters
RNG_FLAG,:specifies 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).
ITStatus RNG_GetITStatus ( uint8_t  RNG_IT)

Checks whether the specified RNG interrupt has occurred or not.

Parameters
RNG_IT,:specifies 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).
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.
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
NewState,:new state of the RNG interrupt. This parameter can be: ENABLE or DISABLE.
Return values
None