You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

683 lines
21 KiB

  1. /**
  2. ******************************************************************************
  3. * @file stm32h7xx_ll_rng.h
  4. * @author MCD Application Team
  5. * @brief Header file of RNG LL module.
  6. ******************************************************************************
  7. * @attention
  8. *
  9. * <h2><center>&copy; Copyright (c) 2017 STMicroelectronics.
  10. * All rights reserved.</center></h2>
  11. *
  12. * This software component is licensed by ST under BSD 3-Clause license,
  13. * the "License"; You may not use this file except in compliance with the
  14. * License. You may obtain a copy of the License at:
  15. * opensource.org/licenses/BSD-3-Clause
  16. *
  17. ******************************************************************************
  18. */
  19. /* Define to prevent recursive inclusion -------------------------------------*/
  20. #ifndef STM32H7xx_LL_RNG_H
  21. #define STM32H7xx_LL_RNG_H
  22. #ifdef __cplusplus
  23. extern "C" {
  24. #endif
  25. /* Includes ------------------------------------------------------------------*/
  26. #include "stm32h7xx.h"
  27. /** @addtogroup STM32H7xx_LL_Driver
  28. * @{
  29. */
  30. #if defined (RNG)
  31. /** @defgroup RNG_LL RNG
  32. * @{
  33. */
  34. /* Private types -------------------------------------------------------------*/
  35. /* Private variables ---------------------------------------------------------*/
  36. /* Private constants ---------------------------------------------------------*/
  37. /* Private macros ------------------------------------------------------------*/
  38. /* Exported types ------------------------------------------------------------*/
  39. #if defined(USE_FULL_LL_DRIVER)
  40. /** @defgroup RNG_LL_ES_Init_Struct RNG Exported Init structures
  41. * @{
  42. */
  43. /**
  44. * @brief LL RNG Init Structure Definition
  45. */
  46. typedef struct
  47. {
  48. uint32_t ClockErrorDetection; /*!< Clock error detection.
  49. This parameter can be one value of @ref RNG_LL_CED.
  50. This parameter can be modified using unitary functions @ref LL_RNG_EnableClkErrorDetect(). */
  51. } LL_RNG_InitTypeDef;
  52. /**
  53. * @}
  54. */
  55. #endif /* USE_FULL_LL_DRIVER */
  56. /* Exported constants --------------------------------------------------------*/
  57. /** @defgroup RNG_LL_Exported_Constants RNG Exported Constants
  58. * @{
  59. */
  60. /** @defgroup RNG_LL_CED Clock Error Detection
  61. * @{
  62. */
  63. #define LL_RNG_CED_ENABLE 0x00000000U /*!< Clock error detection enabled */
  64. #define LL_RNG_CED_DISABLE RNG_CR_CED /*!< Clock error detection disabled */
  65. /**
  66. * @}
  67. */
  68. #if defined(RNG_CR_CONDRST)
  69. /** @defgroup RNG_LL_Clock_Divider_Factor Value used to configure an internal
  70. * programmable divider acting on the incoming RNG clock
  71. * @{
  72. */
  73. #define LL_RNG_CLKDIV_BY_1 (0x00000000UL) /*!< No clock division */
  74. #define LL_RNG_CLKDIV_BY_2 (RNG_CR_CLKDIV_0) /*!< 2 RNG clock cycles per internal RNG clock */
  75. #define LL_RNG_CLKDIV_BY_4 (RNG_CR_CLKDIV_1) /*!< 4 RNG clock cycles per internal RNG clock */
  76. #define LL_RNG_CLKDIV_BY_8 (RNG_CR_CLKDIV_1 | RNG_CR_CLKDIV_0) /*!< 8 RNG clock cycles per internal RNG clock */
  77. #define LL_RNG_CLKDIV_BY_16 (RNG_CR_CLKDIV_2) /*!< 16 RNG clock cycles per internal RNG clock */
  78. #define LL_RNG_CLKDIV_BY_32 (RNG_CR_CLKDIV_2 | RNG_CR_CLKDIV_0) /*!< 32 RNG clock cycles per internal RNG clock */
  79. #define LL_RNG_CLKDIV_BY_64 (RNG_CR_CLKDIV_2 | RNG_CR_CLKDIV_1) /*!< 64 RNG clock cycles per internal RNG clock */
  80. #define LL_RNG_CLKDIV_BY_128 (RNG_CR_CLKDIV_2 | RNG_CR_CLKDIV_1 | RNG_CR_CLKDIV_0) /*!< 128 RNG clock cycles per internal RNG clock */
  81. #define LL_RNG_CLKDIV_BY_256 (RNG_CR_CLKDIV_3) /*!< 256 RNG clock cycles per internal RNG clock */
  82. #define LL_RNG_CLKDIV_BY_512 (RNG_CR_CLKDIV_3 | RNG_CR_CLKDIV_0) /*!< 512 RNG clock cycles per internal RNG clock */
  83. #define LL_RNG_CLKDIV_BY_1024 (RNG_CR_CLKDIV_3 | RNG_CR_CLKDIV_1) /*!< 1024 RNG clock cycles per internal RNG clock */
  84. #define LL_RNG_CLKDIV_BY_2048 (RNG_CR_CLKDIV_3 | RNG_CR_CLKDIV_1 | RNG_CR_CLKDIV_0) /*!< 2048 RNG clock cycles per internal RNG clock */
  85. #define LL_RNG_CLKDIV_BY_4096 (RNG_CR_CLKDIV_3 | RNG_CR_CLKDIV_2) /*!< 4096 RNG clock cycles per internal RNG clock */
  86. #define LL_RNG_CLKDIV_BY_8192 (RNG_CR_CLKDIV_3 | RNG_CR_CLKDIV_2 | RNG_CR_CLKDIV_0) /*!< 8192 RNG clock cycles per internal RNG clock */
  87. #define LL_RNG_CLKDIV_BY_16384 (RNG_CR_CLKDIV_3 | RNG_CR_CLKDIV_2 | RNG_CR_CLKDIV_1) /*!< 16384 RNG clock cycles per internal RNG clock */
  88. #define LL_RNG_CLKDIV_BY_32768 (RNG_CR_CLKDIV_3 | RNG_CR_CLKDIV_2 | RNG_CR_CLKDIV_1 | RNG_CR_CLKDIV_0) /*!< 32768 RNG clock cycles per internal RNG clock */
  89. /**
  90. * @}
  91. */
  92. /** @defgroup RNG_LL_NIST_Compliance NIST Compliance configuration
  93. * @{
  94. */
  95. #define LL_RNG_NIST_COMPLIANT (0x00000000UL) /*!< Default NIST compliant configuration*/
  96. #define LL_RNG_CUSTOM_NIST (RNG_CR_NISTC) /*!< Custom NIST configuration */
  97. /**
  98. * @}
  99. */
  100. #endif/*RNG_CR_CONDRST*/
  101. /** @defgroup RNG_LL_EC_GET_FLAG Get Flags Defines
  102. * @brief Flags defines which can be used with LL_RNG_ReadReg function
  103. * @{
  104. */
  105. #define LL_RNG_SR_DRDY RNG_SR_DRDY /*!< Register contains valid random data */
  106. #define LL_RNG_SR_CECS RNG_SR_CECS /*!< Clock error current status */
  107. #define LL_RNG_SR_SECS RNG_SR_SECS /*!< Seed error current status */
  108. #define LL_RNG_SR_CEIS RNG_SR_CEIS /*!< Clock error interrupt status */
  109. #define LL_RNG_SR_SEIS RNG_SR_SEIS /*!< Seed error interrupt status */
  110. /**
  111. * @}
  112. */
  113. /** @defgroup RNG_LL_EC_IT IT Defines
  114. * @brief IT defines which can be used with LL_RNG_ReadReg and LL_RNG_WriteReg macros
  115. * @{
  116. */
  117. #define LL_RNG_CR_IE RNG_CR_IE /*!< RNG Interrupt enable */
  118. /**
  119. * @}
  120. */
  121. /**
  122. * @}
  123. */
  124. /* Exported macro ------------------------------------------------------------*/
  125. /** @defgroup RNG_LL_Exported_Macros RNG Exported Macros
  126. * @{
  127. */
  128. /** @defgroup RNG_LL_EM_WRITE_READ Common Write and read registers Macros
  129. * @{
  130. */
  131. /**
  132. * @brief Write a value in RNG register
  133. * @param __INSTANCE__ RNG Instance
  134. * @param __REG__ Register to be written
  135. * @param __VALUE__ Value to be written in the register
  136. * @retval None
  137. */
  138. #define LL_RNG_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG(__INSTANCE__->__REG__, (__VALUE__))
  139. /**
  140. * @brief Read a value in RNG register
  141. * @param __INSTANCE__ RNG Instance
  142. * @param __REG__ Register to be read
  143. * @retval Register value
  144. */
  145. #define LL_RNG_ReadReg(__INSTANCE__, __REG__) READ_REG(__INSTANCE__->__REG__)
  146. /**
  147. * @}
  148. */
  149. /**
  150. * @}
  151. */
  152. /* Exported functions --------------------------------------------------------*/
  153. /** @defgroup RNG_LL_Exported_Functions RNG Exported Functions
  154. * @{
  155. */
  156. /** @defgroup RNG_LL_EF_Configuration RNG Configuration functions
  157. * @{
  158. */
  159. /**
  160. * @brief Enable Random Number Generation
  161. * @rmtoll CR RNGEN LL_RNG_Enable
  162. * @param RNGx RNG Instance
  163. * @retval None
  164. */
  165. __STATIC_INLINE void LL_RNG_Enable(RNG_TypeDef *RNGx)
  166. {
  167. SET_BIT(RNGx->CR, RNG_CR_RNGEN);
  168. }
  169. /**
  170. * @brief Disable Random Number Generation
  171. * @rmtoll CR RNGEN LL_RNG_Disable
  172. * @param RNGx RNG Instance
  173. * @retval None
  174. */
  175. __STATIC_INLINE void LL_RNG_Disable(RNG_TypeDef *RNGx)
  176. {
  177. CLEAR_BIT(RNGx->CR, RNG_CR_RNGEN);
  178. }
  179. /**
  180. * @brief Check if Random Number Generator is enabled
  181. * @rmtoll CR RNGEN LL_RNG_IsEnabled
  182. * @param RNGx RNG Instance
  183. * @retval State of bit (1 or 0).
  184. */
  185. __STATIC_INLINE uint32_t LL_RNG_IsEnabled(RNG_TypeDef *RNGx)
  186. {
  187. return ((READ_BIT(RNGx->CR, RNG_CR_RNGEN) == (RNG_CR_RNGEN)) ? 1UL : 0UL);
  188. }
  189. /**
  190. * @brief Enable Clock Error Detection
  191. * @rmtoll CR CED LL_RNG_EnableClkErrorDetect
  192. * @param RNGx RNG Instance
  193. * @retval None
  194. */
  195. __STATIC_INLINE void LL_RNG_EnableClkErrorDetect(RNG_TypeDef *RNGx)
  196. {
  197. CLEAR_BIT(RNGx->CR, RNG_CR_CED);
  198. }
  199. /**
  200. * @brief Disable RNG Clock Error Detection
  201. * @rmtoll CR CED LL_RNG_DisableClkErrorDetect
  202. * @param RNGx RNG Instance
  203. * @retval None
  204. */
  205. __STATIC_INLINE void LL_RNG_DisableClkErrorDetect(RNG_TypeDef *RNGx)
  206. {
  207. SET_BIT(RNGx->CR, RNG_CR_CED);
  208. }
  209. /**
  210. * @brief Check if RNG Clock Error Detection is enabled
  211. * @rmtoll CR CED LL_RNG_IsEnabledClkErrorDetect
  212. * @param RNGx RNG Instance
  213. * @retval State of bit (1 or 0).
  214. */
  215. __STATIC_INLINE uint32_t LL_RNG_IsEnabledClkErrorDetect(RNG_TypeDef *RNGx)
  216. {
  217. return ((READ_BIT(RNGx->CR, RNG_CR_CED) != (RNG_CR_CED)) ? 1UL : 0UL);
  218. }
  219. #if defined(RNG_CR_CONDRST)
  220. /**
  221. * @brief Set RNG Conditioning Soft Reset bit
  222. * @rmtoll CR CONDRST LL_RNG_EnableCondReset
  223. * @param RNGx RNG Instance
  224. * @retval None
  225. */
  226. __STATIC_INLINE void LL_RNG_EnableCondReset(RNG_TypeDef *RNGx)
  227. {
  228. SET_BIT(RNGx->CR, RNG_CR_CONDRST);
  229. }
  230. /**
  231. * @brief Reset RNG Conditioning Soft Reset bit
  232. * @rmtoll CR CONDRST LL_RNG_DisableCondReset
  233. * @param RNGx RNG Instance
  234. * @retval None
  235. */
  236. __STATIC_INLINE void LL_RNG_DisableCondReset(RNG_TypeDef *RNGx)
  237. {
  238. CLEAR_BIT(RNGx->CR, RNG_CR_CONDRST);
  239. }
  240. /**
  241. * @brief Check if RNG Conditioning Soft Reset bit is set
  242. * @rmtoll CR CONDRST LL_RNG_IsEnabledCondReset
  243. * @param RNGx RNG Instance
  244. * @retval State of bit (1 or 0).
  245. */
  246. __STATIC_INLINE uint32_t LL_RNG_IsEnabledCondReset(RNG_TypeDef *RNGx)
  247. {
  248. return ((READ_BIT(RNGx->CR, RNG_CR_CONDRST) == (RNG_CR_CONDRST)) ? 1UL : 0UL);
  249. }
  250. /**
  251. * @brief Enable RNG Config Lock
  252. * @rmtoll CR CONFIGLOCK LL_RNG_ConfigLock
  253. * @param RNGx RNG Instance
  254. * @retval None
  255. */
  256. __STATIC_INLINE void LL_RNG_ConfigLock(RNG_TypeDef *RNGx)
  257. {
  258. SET_BIT(RNGx->CR, RNG_CR_CONFIGLOCK);
  259. }
  260. /**
  261. * @brief Check if RNG Config Lock is enabled
  262. * @rmtoll CR CONFIGLOCK LL_RNG_IsConfigLocked
  263. * @param RNGx RNG Instance
  264. * @retval State of bit (1 or 0).
  265. */
  266. __STATIC_INLINE uint32_t LL_RNG_IsConfigLocked(RNG_TypeDef *RNGx)
  267. {
  268. return ((READ_BIT(RNGx->CR, RNG_CR_CONFIGLOCK) == (RNG_CR_CONFIGLOCK)) ? 1UL : 0UL);
  269. }
  270. /**
  271. * @brief Enable NIST Compliance
  272. * @rmtoll CR NISTC LL_RNG_EnableNistCompliance
  273. * @param RNGx RNG Instance
  274. * @retval None
  275. */
  276. __STATIC_INLINE void LL_RNG_EnableNistCompliance(RNG_TypeDef *RNGx)
  277. {
  278. CLEAR_BIT(RNGx->CR, RNG_CR_NISTC);
  279. }
  280. /**
  281. * @brief Disable NIST Compliance
  282. * @rmtoll CR NISTC LL_RNG_DisableNistCompliance
  283. * @param RNGx RNG Instance
  284. * @retval None
  285. */
  286. __STATIC_INLINE void LL_RNG_DisableNistCompliance(RNG_TypeDef *RNGx)
  287. {
  288. SET_BIT(RNGx->CR, RNG_CR_NISTC);
  289. }
  290. /**
  291. * @brief Check if NIST Compliance is enabled
  292. * @rmtoll CR NISTC LL_RNG_IsEnabledNistCompliance
  293. * @param RNGx RNG Instance
  294. * @retval State of bit (1 or 0).
  295. */
  296. __STATIC_INLINE uint32_t LL_RNG_IsEnabledNistCompliance(RNG_TypeDef *RNGx)
  297. {
  298. return ((READ_BIT(RNGx->CR, RNG_CR_NISTC) != (RNG_CR_NISTC)) ? 1UL : 0UL);
  299. }
  300. /**
  301. * @brief Set RNG Config1 Configuration field value
  302. * @rmtoll CR RNG_CONFIG1 LL_RNG_SetConfig1
  303. * @param RNGx RNG Instance
  304. * @param Config1 Value between 0 and 0x3F
  305. * @retval None
  306. */
  307. __STATIC_INLINE void LL_RNG_SetConfig1(RNG_TypeDef *RNGx, uint32_t Config1)
  308. {
  309. MODIFY_REG(RNGx->CR, RNG_CR_RNG_CONFIG1, Config1 << RNG_CR_RNG_CONFIG1_Pos);
  310. }
  311. /**
  312. * @brief Get RNG Config1 Configuration field value
  313. * @rmtoll CR RNG_CONFIG1 LL_RNG_GetConfig1
  314. * @param RNGx RNG Instance
  315. * @retval Returned Value expressed on 6 bits : Value between 0 and 0x3F
  316. */
  317. __STATIC_INLINE uint32_t LL_RNG_GetConfig1(RNG_TypeDef *RNGx)
  318. {
  319. return (uint32_t)(READ_BIT(RNGx->CR, RNG_CR_RNG_CONFIG1) >> RNG_CR_RNG_CONFIG1_Pos);
  320. }
  321. /**
  322. * @brief Set RNG Config2 Configuration field value
  323. * @rmtoll CR RNG_CONFIG2 LL_RNG_SetConfig2
  324. * @param RNGx RNG Instance
  325. * @param Config2 Value between 0 and 0x7
  326. * @retval None
  327. */
  328. __STATIC_INLINE void LL_RNG_SetConfig2(RNG_TypeDef *RNGx, uint32_t Config2)
  329. {
  330. MODIFY_REG(RNGx->CR, RNG_CR_RNG_CONFIG2, Config2 << RNG_CR_RNG_CONFIG2_Pos);
  331. }
  332. /**
  333. * @brief Get RNG Config2 Configuration field value
  334. * @rmtoll CR RNG_CONFIG2 LL_RNG_GetConfig2
  335. * @param RNGx RNG Instance
  336. * @retval Returned Value expressed on 3 bits : Value between 0 and 0x7
  337. */
  338. __STATIC_INLINE uint32_t LL_RNG_GetConfig2(RNG_TypeDef *RNGx)
  339. {
  340. return (uint32_t)(READ_BIT(RNGx->CR, RNG_CR_RNG_CONFIG2) >> RNG_CR_RNG_CONFIG2_Pos);
  341. }
  342. /**
  343. * @brief Set RNG Config3 Configuration field value
  344. * @rmtoll CR RNG_CONFIG3 LL_RNG_SetConfig3
  345. * @param RNGx RNG Instance
  346. * @param Config3 Value between 0 and 0xF
  347. * @retval None
  348. */
  349. __STATIC_INLINE void LL_RNG_SetConfig3(RNG_TypeDef *RNGx, uint32_t Config3)
  350. {
  351. MODIFY_REG(RNGx->CR, RNG_CR_RNG_CONFIG3, Config3 << RNG_CR_RNG_CONFIG3_Pos);
  352. }
  353. /**
  354. * @brief Get RNG Config3 Configuration field value
  355. * @rmtoll CR RNG_CONFIG3 LL_RNG_GetConfig3
  356. * @param RNGx RNG Instance
  357. * @retval Returned Value expressed on 4 bits : Value between 0 and 0xF
  358. */
  359. __STATIC_INLINE uint32_t LL_RNG_GetConfig3(RNG_TypeDef *RNGx)
  360. {
  361. return (uint32_t)(READ_BIT(RNGx->CR, RNG_CR_RNG_CONFIG3) >> RNG_CR_RNG_CONFIG3_Pos);
  362. }
  363. /**
  364. * @brief Set RNG Clock divider factor
  365. * @rmtoll CR CLKDIV LL_RNG_SetClockDivider
  366. * @param RNGx RNG Instance
  367. * @param Divider can be one of the following values:
  368. * @arg @ref LL_RNG_CLKDIV_BY_1
  369. * @arg @ref LL_RNG_CLKDIV_BY_2
  370. * @arg @ref LL_RNG_CLKDIV_BY_4
  371. * @arg @ref LL_RNG_CLKDIV_BY_8
  372. * @arg @ref LL_RNG_CLKDIV_BY_16
  373. * @arg @ref LL_RNG_CLKDIV_BY_32
  374. * @arg @ref LL_RNG_CLKDIV_BY_64
  375. * @arg @ref LL_RNG_CLKDIV_BY_128
  376. * @arg @ref LL_RNG_CLKDIV_BY_256
  377. * @arg @ref LL_RNG_CLKDIV_BY_512
  378. * @arg @ref LL_RNG_CLKDIV_BY_1024
  379. * @arg @ref LL_RNG_CLKDIV_BY_2048
  380. * @arg @ref LL_RNG_CLKDIV_BY_4096
  381. * @arg @ref LL_RNG_CLKDIV_BY_8192
  382. * @arg @ref LL_RNG_CLKDIV_BY_16384
  383. * @arg @ref LL_RNG_CLKDIV_BY_32768
  384. * @retval None
  385. */
  386. __STATIC_INLINE void LL_RNG_SetClockDivider(RNG_TypeDef *RNGx, uint32_t Divider)
  387. {
  388. MODIFY_REG(RNGx->CR, RNG_CR_CLKDIV, Divider << RNG_CR_CLKDIV_Pos);
  389. }
  390. /**
  391. * @brief Get RNG Clock divider factor
  392. * @rmtoll CR CLKDIV LL_RNG_GetClockDivider
  393. * @param RNGx RNG Instance
  394. * @retval Returned value can be one of the following values:
  395. * @arg @ref LL_RNG_CLKDIV_BY_1
  396. * @arg @ref LL_RNG_CLKDIV_BY_2
  397. * @arg @ref LL_RNG_CLKDIV_BY_4
  398. * @arg @ref LL_RNG_CLKDIV_BY_8
  399. * @arg @ref LL_RNG_CLKDIV_BY_16
  400. * @arg @ref LL_RNG_CLKDIV_BY_32
  401. * @arg @ref LL_RNG_CLKDIV_BY_64
  402. * @arg @ref LL_RNG_CLKDIV_BY_128
  403. * @arg @ref LL_RNG_CLKDIV_BY_256
  404. * @arg @ref LL_RNG_CLKDIV_BY_512
  405. * @arg @ref LL_RNG_CLKDIV_BY_1024
  406. * @arg @ref LL_RNG_CLKDIV_BY_2048
  407. * @arg @ref LL_RNG_CLKDIV_BY_4096
  408. * @arg @ref LL_RNG_CLKDIV_BY_8192
  409. * @arg @ref LL_RNG_CLKDIV_BY_16384
  410. * @arg @ref LL_RNG_CLKDIV_BY_32768
  411. */
  412. __STATIC_INLINE uint32_t LL_RNG_GetClockDivider(RNG_TypeDef *RNGx)
  413. {
  414. return (uint32_t)READ_BIT(RNGx->CR, RNG_CR_CLKDIV);
  415. }
  416. #endif /* RNG_CR_CONDRST */
  417. /**
  418. * @}
  419. */
  420. /** @defgroup RNG_LL_EF_FLAG_Management FLAG Management
  421. * @{
  422. */
  423. /**
  424. * @brief Indicate if the RNG Data ready Flag is set or not
  425. * @rmtoll SR DRDY LL_RNG_IsActiveFlag_DRDY
  426. * @param RNGx RNG Instance
  427. * @retval State of bit (1 or 0).
  428. */
  429. __STATIC_INLINE uint32_t LL_RNG_IsActiveFlag_DRDY(RNG_TypeDef *RNGx)
  430. {
  431. return ((READ_BIT(RNGx->SR, RNG_SR_DRDY) == (RNG_SR_DRDY)) ? 1UL : 0UL);
  432. }
  433. /**
  434. * @brief Indicate if the Clock Error Current Status Flag is set or not
  435. * @rmtoll SR CECS LL_RNG_IsActiveFlag_CECS
  436. * @param RNGx RNG Instance
  437. * @retval State of bit (1 or 0).
  438. */
  439. __STATIC_INLINE uint32_t LL_RNG_IsActiveFlag_CECS(RNG_TypeDef *RNGx)
  440. {
  441. return ((READ_BIT(RNGx->SR, RNG_SR_CECS) == (RNG_SR_CECS)) ? 1UL : 0UL);
  442. }
  443. /**
  444. * @brief Indicate if the Seed Error Current Status Flag is set or not
  445. * @rmtoll SR SECS LL_RNG_IsActiveFlag_SECS
  446. * @param RNGx RNG Instance
  447. * @retval State of bit (1 or 0).
  448. */
  449. __STATIC_INLINE uint32_t LL_RNG_IsActiveFlag_SECS(RNG_TypeDef *RNGx)
  450. {
  451. return ((READ_BIT(RNGx->SR, RNG_SR_SECS) == (RNG_SR_SECS)) ? 1UL : 0UL);
  452. }
  453. /**
  454. * @brief Indicate if the Clock Error Interrupt Status Flag is set or not
  455. * @rmtoll SR CEIS LL_RNG_IsActiveFlag_CEIS
  456. * @param RNGx RNG Instance
  457. * @retval State of bit (1 or 0).
  458. */
  459. __STATIC_INLINE uint32_t LL_RNG_IsActiveFlag_CEIS(RNG_TypeDef *RNGx)
  460. {
  461. return ((READ_BIT(RNGx->SR, RNG_SR_CEIS) == (RNG_SR_CEIS)) ? 1UL : 0UL);
  462. }
  463. /**
  464. * @brief Indicate if the Seed Error Interrupt Status Flag is set or not
  465. * @rmtoll SR SEIS LL_RNG_IsActiveFlag_SEIS
  466. * @param RNGx RNG Instance
  467. * @retval State of bit (1 or 0).
  468. */
  469. __STATIC_INLINE uint32_t LL_RNG_IsActiveFlag_SEIS(RNG_TypeDef *RNGx)
  470. {
  471. return ((READ_BIT(RNGx->SR, RNG_SR_SEIS) == (RNG_SR_SEIS)) ? 1UL : 0UL);
  472. }
  473. /**
  474. * @brief Clear Clock Error interrupt Status (CEIS) Flag
  475. * @rmtoll SR CEIS LL_RNG_ClearFlag_CEIS
  476. * @param RNGx RNG Instance
  477. * @retval None
  478. */
  479. __STATIC_INLINE void LL_RNG_ClearFlag_CEIS(RNG_TypeDef *RNGx)
  480. {
  481. WRITE_REG(RNGx->SR, ~RNG_SR_CEIS);
  482. }
  483. /**
  484. * @brief Clear Seed Error interrupt Status (SEIS) Flag
  485. * @rmtoll SR SEIS LL_RNG_ClearFlag_SEIS
  486. * @param RNGx RNG Instance
  487. * @retval None
  488. */
  489. __STATIC_INLINE void LL_RNG_ClearFlag_SEIS(RNG_TypeDef *RNGx)
  490. {
  491. WRITE_REG(RNGx->SR, ~RNG_SR_SEIS);
  492. }
  493. /**
  494. * @}
  495. */
  496. /** @defgroup RNG_LL_EF_IT_Management IT Management
  497. * @{
  498. */
  499. /**
  500. * @brief Enable Random Number Generator Interrupt
  501. * (applies for either Seed error, Clock Error or Data ready interrupts)
  502. * @rmtoll CR IE LL_RNG_EnableIT
  503. * @param RNGx RNG Instance
  504. * @retval None
  505. */
  506. __STATIC_INLINE void LL_RNG_EnableIT(RNG_TypeDef *RNGx)
  507. {
  508. SET_BIT(RNGx->CR, RNG_CR_IE);
  509. }
  510. /**
  511. * @brief Disable Random Number Generator Interrupt
  512. * (applies for either Seed error, Clock Error or Data ready interrupts)
  513. * @rmtoll CR IE LL_RNG_DisableIT
  514. * @param RNGx RNG Instance
  515. * @retval None
  516. */
  517. __STATIC_INLINE void LL_RNG_DisableIT(RNG_TypeDef *RNGx)
  518. {
  519. CLEAR_BIT(RNGx->CR, RNG_CR_IE);
  520. }
  521. /**
  522. * @brief Check if Random Number Generator Interrupt is enabled
  523. * (applies for either Seed error, Clock Error or Data ready interrupts)
  524. * @rmtoll CR IE LL_RNG_IsEnabledIT
  525. * @param RNGx RNG Instance
  526. * @retval State of bit (1 or 0).
  527. */
  528. __STATIC_INLINE uint32_t LL_RNG_IsEnabledIT(RNG_TypeDef *RNGx)
  529. {
  530. return ((READ_BIT(RNGx->CR, RNG_CR_IE) == (RNG_CR_IE)) ? 1UL : 0UL);
  531. }
  532. /**
  533. * @}
  534. */
  535. /** @defgroup RNG_LL_EF_Data_Management Data Management
  536. * @{
  537. */
  538. /**
  539. * @brief Return32-bit Random Number value
  540. * @rmtoll DR RNDATA LL_RNG_ReadRandData32
  541. * @param RNGx RNG Instance
  542. * @retval Generated 32-bit random value
  543. */
  544. __STATIC_INLINE uint32_t LL_RNG_ReadRandData32(RNG_TypeDef *RNGx)
  545. {
  546. return (uint32_t)(READ_REG(RNGx->DR));
  547. }
  548. /**
  549. * @}
  550. */
  551. #if defined (RNG_VER_3_1)
  552. /** @defgroup RNG_LL_EF_Health_Test_Control Health Test Control
  553. * @{
  554. */
  555. /**
  556. * @brief Set RNG Health Test Control
  557. * @rmtoll HTCR HTCFG LL_RNG_SetHealthConfig
  558. * @param RNGx RNG Instance
  559. * @param HTCFG can be values of 32 bits
  560. * @retval None
  561. */
  562. __STATIC_INLINE void LL_RNG_SetHealthConfig(RNG_TypeDef *RNGx, uint32_t HTCFG)
  563. {
  564. WRITE_REG(RNGx->HTCR, HTCFG);
  565. }
  566. /**
  567. * @brief Get RNG Health Test Control
  568. * @rmtoll HTCR HTCFG LL_RNG_GetHealthConfig
  569. * @param RNGx RNG Instance
  570. * @retval Return 32-bit RNG Health Test configuration
  571. */
  572. __STATIC_INLINE uint32_t LL_RNG_GetHealthConfig(RNG_TypeDef *RNGx)
  573. {
  574. return (uint32_t)READ_REG(RNGx->HTCR);
  575. }
  576. /**
  577. * @}
  578. */
  579. #endif /*RNG_VER_3_1*/
  580. #if defined(USE_FULL_LL_DRIVER)
  581. /** @defgroup RNG_LL_EF_Init Initialization and de-initialization functions
  582. * @{
  583. */
  584. ErrorStatus LL_RNG_Init(RNG_TypeDef *RNGx, LL_RNG_InitTypeDef *RNG_InitStruct);
  585. void LL_RNG_StructInit(LL_RNG_InitTypeDef *RNG_InitStruct);
  586. ErrorStatus LL_RNG_DeInit(RNG_TypeDef *RNGx);
  587. /**
  588. * @}
  589. */
  590. #endif /* USE_FULL_LL_DRIVER */
  591. /**
  592. * @}
  593. */
  594. /**
  595. * @}
  596. */
  597. #endif /* RNG */
  598. /**
  599. * @}
  600. */
  601. #ifdef __cplusplus
  602. }
  603. #endif
  604. #endif /* __STM32H7xx_LL_RNG_H */
  605. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/