Interrupts and flags management functions.
More...
Interrupts and flags management functions.
===============================================================================
Interrupts and flags management functions
===============================================================================
This section provides functions allowing to configure the RNG Interrupts and
to get the status and clear flags and Interrupts pending bits.
The RNG provides 3 Interrupts sources and 3 Flags:
Flags :
----------
1. RNG_FLAG_DRDY : In the case of the RNG_DR register contains valid
random data. it is cleared by reading the valid data
(using RNG_GetRandomNumber() function).
2. RNG_FLAG_CECS : In the case of a seed error detection.
3. RNG_FLAG_SECS : In the case of a clock error detection.
Interrupts :
------------
if enabled, an RNG interrupt is pending :
1. In the case of the RNG_DR register contains valid random data.
This interrupt source is cleared once the RNG_DR register has been read
(using RNG_GetRandomNumber() function) until a new valid value is
computed.
or
2. In the case of a seed error : One of the following faulty sequences has
been detected:
- More than 64 consecutive bits at the same value (0 or 1)
- More than 32 consecutive alternance of 0 and 1 (0101010101...01)
This interrupt source is cleared using RNG_ClearITPendingBit(RNG_IT_SEI)
function.
or
3. In the case of a clock error : the PLL48CLK (RNG peripheral clock source)
was not correctly detected (fPLL48CLK< fHCLK/16).
This interrupt source is cleared using RNG_ClearITPendingBit(RNG_IT_CEI)
function.
@note In this case, User have to check that the clock controller is
correctly configured to provide the RNG clock.
Managing the RNG controller events :
------------------------------------
The user should identify which mode will be used in his application to manage
the RNG controller events: Polling mode or Interrupt mode.
1. In the Polling Mode it is advised to use the following functions:
- RNG_GetFlagStatus() : to check if flags events occur.
- RNG_ClearFlag() : to clear the flags events.
@note RNG_FLAG_DRDY can not be cleared by RNG_ClearFlag(). it is cleared only
by reading the Random number data.
2. In the Interrupt Mode it is advised to use the following functions:
- RNG_ITConfig() : to enable or disable the interrupt source.
- RNG_GetITStatus() : to check if Interrupt occurs.
- RNG_ClearITPendingBit() : to clear the Interrupt pending Bit
(corresponding Flag).
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
-
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
-
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
-
The | new 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
-
The | new state of RNG_IT (SET or RESET). |
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
-