MG32F157 Standard Peripherals Firmware Library
mg32f157_trng.h
Go to the documentation of this file.
1 
10 /* Define to prevent recursive inclusion -------------------------------------*/
11 #ifndef __MG32F157_TRNG_H
12 #define __MG32F157_TRNG_H
13 
14 #ifdef __cplusplus
15  extern "C" {
16 #endif
17 
18 /* Includes ------------------------------------------------------------------*/
19 #include "mg32f157.h"
20 
30 /* Exported types ------------------------------------------------------------*/
31 /* Exported constants --------------------------------------------------------*/
32 
41 #define TRNG_IT_SEIS ((uint16_t)0x4008)
42 #define TRNG_IT_CEIS ((uint16_t)0x2008)
43 #define TRNG_IT_DRDY ((uint16_t)0x0108)
44 
45 #define IS_TRNG_CLEAR_IT(IT) (((IT) == TRNG_IT_SEIS) || ((IT) == TRNG_IT_CEIS) ||\
46  ((IT) == (TRNG_IT_CEIS | TRNG_IT_SEIS)))
47 
48 #define IS_TRNG_GET_IT(IT) (((IT) == TRNG_IT_SEIS) || ((IT) == TRNG_IT_CEIS) || \
49  ((IT) == TRNG_IT_DRDY))
50 
58 #define TRNG_FLAG_SECS ((uint8_t)0x04)
59 #define TRNG_FLAG_CECS ((uint8_t)0x02)
60 #define TRNG_FLAG_DRDY ((uint8_t)0x01)
61 
62 #define IS_TRNG_GET_FLAG(FLAG) (((FLAG) == TRNG_FLAG_SECS) || ((FLAG) == TRNG_FLAG_CECS) || \
63  ((FLAG) == TRNG_FLAG_DRDY))
64 
65 #define IS_TRNG_CLEAR_FLAG(FLAG) (((FLAG) == TRNG_FLAG_SECS) || ((FLAG) == TRNG_FLAG_CECS) || \
66  ((FLAG) == (TRNG_FLAG_SECS | TRNG_FLAG_CECS)))
67 
75 /* Exported macro ------------------------------------------------------------*/
76 /* Exported functions --------------------------------------------------------*/
77 
78 void TRNG_DeInit(void);
79 void TRNG_Cmd(FunctionalState NewState);
80 void TRNG_Clock_CheckCmd(FunctionalState NewState);
81 void TRNG_ClearFlag(uint8_t TRNG_FLAG);
82 void TRNG_ClearITPendingBit(uint16_t TRNG_IT);
83 uint32_t TRNG_GetData(void);
84 FlagStatus TRNG_GetFlagStatus(uint8_t TRNG_FLAG);
85 ITStatus TRNG_GetITStatus(uint16_t TRNG_IT);
86 void TRNG_ITCmd(FunctionalState NewState);
87 
96 #ifdef __cplusplus
97 }
98 #endif
99 
100 #endif /* __MG32F157_TRNG_H */
void TRNG_DeInit(void)
Deinitializes the TRNG peripheral registers to their default reset values.
Definition: mg32f157_trng.c:51
void TRNG_ClearFlag(uint8_t TRNG_FLAG)
Clears the TRNG's pending flags.
Definition: mg32f157_trng.c:157
ITStatus TRNG_GetITStatus(uint16_t TRNG_IT)
Checks whether the specified TRNG interrupt has occurred or not.
Definition: mg32f157_trng.c:197
void TRNG_ITCmd(FunctionalState NewState)
Enable or Disable the TRNG interrupt.
Definition: mg32f157_trng.c:171
void TRNG_ClearITPendingBit(uint16_t TRNG_IT)
Clears the TRNG's pending interrupt pending bits.
Definition: mg32f157_trng.c:235
uint32_t TRNG_GetData(void)
Returns true random number value.
Definition: mg32f157_trng.c:110
void TRNG_Cmd(FunctionalState NewState)
Enables or disables the TRNG peripheral generate true random number.
Definition: mg32f157_trng.c:89
FlagStatus TRNG_GetFlagStatus(uint8_t TRNG_FLAG)
Checks whether the specified TRNG flag is set or not.
Definition: mg32f157_trng.c:124
void TRNG_Clock_CheckCmd(FunctionalState NewState)
Enables or disables the TRNG clock error detection.
Definition: mg32f157_trng.c:66