训练营PLSR题目
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
 
 
 
 
 
 

336 wiersze
8.4 KiB

  1. /**
  2. ******************************************************************************
  3. * @file stm32f4xx_ll_rng.h
  4. * @author MCD Application Team
  5. * @brief Header file of RNG LL module.
  6. ******************************************************************************
  7. * @attention
  8. *
  9. * Copyright (c) 2016 STMicroelectronics.
  10. * All rights reserved.
  11. *
  12. * This software is licensed under terms that can be found in the LICENSE file
  13. * in the root directory of this software component.
  14. * If no LICENSE file comes with this software, it is provided AS-IS.
  15. *
  16. ******************************************************************************
  17. */
  18. /* Define to prevent recursive inclusion -------------------------------------*/
  19. #ifndef STM32F4xx_LL_RNG_H
  20. #define STM32F4xx_LL_RNG_H
  21. #ifdef __cplusplus
  22. extern "C" {
  23. #endif
  24. /* Includes ------------------------------------------------------------------*/
  25. #include "stm32f4xx.h"
  26. /** @addtogroup STM32F4xx_LL_Driver
  27. * @{
  28. */
  29. #if defined (RNG)
  30. /** @defgroup RNG_LL RNG
  31. * @{
  32. */
  33. /* Private types -------------------------------------------------------------*/
  34. /* Private variables ---------------------------------------------------------*/
  35. /* Private constants ---------------------------------------------------------*/
  36. /* Private macros ------------------------------------------------------------*/
  37. /* Exported types ------------------------------------------------------------*/
  38. /* Exported constants --------------------------------------------------------*/
  39. /** @defgroup RNG_LL_Exported_Constants RNG Exported Constants
  40. * @{
  41. */
  42. /** @defgroup RNG_LL_EC_GET_FLAG Get Flags Defines
  43. * @brief Flags defines which can be used with LL_RNG_ReadReg function
  44. * @{
  45. */
  46. #define LL_RNG_SR_DRDY RNG_SR_DRDY /*!< Register contains valid random data */
  47. #define LL_RNG_SR_CECS RNG_SR_CECS /*!< Clock error current status */
  48. #define LL_RNG_SR_SECS RNG_SR_SECS /*!< Seed error current status */
  49. #define LL_RNG_SR_CEIS RNG_SR_CEIS /*!< Clock error interrupt status */
  50. #define LL_RNG_SR_SEIS RNG_SR_SEIS /*!< Seed error interrupt status */
  51. /**
  52. * @}
  53. */
  54. /** @defgroup RNG_LL_EC_IT IT Defines
  55. * @brief IT defines which can be used with LL_RNG_ReadReg and LL_RNG_WriteReg macros
  56. * @{
  57. */
  58. #define LL_RNG_CR_IE RNG_CR_IE /*!< RNG Interrupt enable */
  59. /**
  60. * @}
  61. */
  62. /**
  63. * @}
  64. */
  65. /* Exported macro ------------------------------------------------------------*/
  66. /** @defgroup RNG_LL_Exported_Macros RNG Exported Macros
  67. * @{
  68. */
  69. /** @defgroup RNG_LL_EM_WRITE_READ Common Write and read registers Macros
  70. * @{
  71. */
  72. /**
  73. * @brief Write a value in RNG register
  74. * @param __INSTANCE__ RNG Instance
  75. * @param __REG__ Register to be written
  76. * @param __VALUE__ Value to be written in the register
  77. * @retval None
  78. */
  79. #define LL_RNG_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG(__INSTANCE__->__REG__, (__VALUE__))
  80. /**
  81. * @brief Read a value in RNG register
  82. * @param __INSTANCE__ RNG Instance
  83. * @param __REG__ Register to be read
  84. * @retval Register value
  85. */
  86. #define LL_RNG_ReadReg(__INSTANCE__, __REG__) READ_REG(__INSTANCE__->__REG__)
  87. /**
  88. * @}
  89. */
  90. /**
  91. * @}
  92. */
  93. /* Exported functions --------------------------------------------------------*/
  94. /** @defgroup RNG_LL_Exported_Functions RNG Exported Functions
  95. * @{
  96. */
  97. /** @defgroup RNG_LL_EF_Configuration RNG Configuration functions
  98. * @{
  99. */
  100. /**
  101. * @brief Enable Random Number Generation
  102. * @rmtoll CR RNGEN LL_RNG_Enable
  103. * @param RNGx RNG Instance
  104. * @retval None
  105. */
  106. __STATIC_INLINE void LL_RNG_Enable(RNG_TypeDef *RNGx)
  107. {
  108. SET_BIT(RNGx->CR, RNG_CR_RNGEN);
  109. }
  110. /**
  111. * @brief Disable Random Number Generation
  112. * @rmtoll CR RNGEN LL_RNG_Disable
  113. * @param RNGx RNG Instance
  114. * @retval None
  115. */
  116. __STATIC_INLINE void LL_RNG_Disable(RNG_TypeDef *RNGx)
  117. {
  118. CLEAR_BIT(RNGx->CR, RNG_CR_RNGEN);
  119. }
  120. /**
  121. * @brief Check if Random Number Generator is enabled
  122. * @rmtoll CR RNGEN LL_RNG_IsEnabled
  123. * @param RNGx RNG Instance
  124. * @retval State of bit (1 or 0).
  125. */
  126. __STATIC_INLINE uint32_t LL_RNG_IsEnabled(RNG_TypeDef *RNGx)
  127. {
  128. return ((READ_BIT(RNGx->CR, RNG_CR_RNGEN) == (RNG_CR_RNGEN)) ? 1UL : 0UL);
  129. }
  130. /**
  131. * @}
  132. */
  133. /** @defgroup RNG_LL_EF_FLAG_Management FLAG Management
  134. * @{
  135. */
  136. /**
  137. * @brief Indicate if the RNG Data ready Flag is set or not
  138. * @rmtoll SR DRDY LL_RNG_IsActiveFlag_DRDY
  139. * @param RNGx RNG Instance
  140. * @retval State of bit (1 or 0).
  141. */
  142. __STATIC_INLINE uint32_t LL_RNG_IsActiveFlag_DRDY(RNG_TypeDef *RNGx)
  143. {
  144. return ((READ_BIT(RNGx->SR, RNG_SR_DRDY) == (RNG_SR_DRDY)) ? 1UL : 0UL);
  145. }
  146. /**
  147. * @brief Indicate if the Clock Error Current Status Flag is set or not
  148. * @rmtoll SR CECS LL_RNG_IsActiveFlag_CECS
  149. * @param RNGx RNG Instance
  150. * @retval State of bit (1 or 0).
  151. */
  152. __STATIC_INLINE uint32_t LL_RNG_IsActiveFlag_CECS(RNG_TypeDef *RNGx)
  153. {
  154. return ((READ_BIT(RNGx->SR, RNG_SR_CECS) == (RNG_SR_CECS)) ? 1UL : 0UL);
  155. }
  156. /**
  157. * @brief Indicate if the Seed Error Current Status Flag is set or not
  158. * @rmtoll SR SECS LL_RNG_IsActiveFlag_SECS
  159. * @param RNGx RNG Instance
  160. * @retval State of bit (1 or 0).
  161. */
  162. __STATIC_INLINE uint32_t LL_RNG_IsActiveFlag_SECS(RNG_TypeDef *RNGx)
  163. {
  164. return ((READ_BIT(RNGx->SR, RNG_SR_SECS) == (RNG_SR_SECS)) ? 1UL : 0UL);
  165. }
  166. /**
  167. * @brief Indicate if the Clock Error Interrupt Status Flag is set or not
  168. * @rmtoll SR CEIS LL_RNG_IsActiveFlag_CEIS
  169. * @param RNGx RNG Instance
  170. * @retval State of bit (1 or 0).
  171. */
  172. __STATIC_INLINE uint32_t LL_RNG_IsActiveFlag_CEIS(RNG_TypeDef *RNGx)
  173. {
  174. return ((READ_BIT(RNGx->SR, RNG_SR_CEIS) == (RNG_SR_CEIS)) ? 1UL : 0UL);
  175. }
  176. /**
  177. * @brief Indicate if the Seed Error Interrupt Status Flag is set or not
  178. * @rmtoll SR SEIS LL_RNG_IsActiveFlag_SEIS
  179. * @param RNGx RNG Instance
  180. * @retval State of bit (1 or 0).
  181. */
  182. __STATIC_INLINE uint32_t LL_RNG_IsActiveFlag_SEIS(RNG_TypeDef *RNGx)
  183. {
  184. return ((READ_BIT(RNGx->SR, RNG_SR_SEIS) == (RNG_SR_SEIS)) ? 1UL : 0UL);
  185. }
  186. /**
  187. * @brief Clear Clock Error interrupt Status (CEIS) Flag
  188. * @rmtoll SR CEIS LL_RNG_ClearFlag_CEIS
  189. * @param RNGx RNG Instance
  190. * @retval None
  191. */
  192. __STATIC_INLINE void LL_RNG_ClearFlag_CEIS(RNG_TypeDef *RNGx)
  193. {
  194. WRITE_REG(RNGx->SR, ~RNG_SR_CEIS);
  195. }
  196. /**
  197. * @brief Clear Seed Error interrupt Status (SEIS) Flag
  198. * @rmtoll SR SEIS LL_RNG_ClearFlag_SEIS
  199. * @param RNGx RNG Instance
  200. * @retval None
  201. */
  202. __STATIC_INLINE void LL_RNG_ClearFlag_SEIS(RNG_TypeDef *RNGx)
  203. {
  204. WRITE_REG(RNGx->SR, ~RNG_SR_SEIS);
  205. }
  206. /**
  207. * @}
  208. */
  209. /** @defgroup RNG_LL_EF_IT_Management IT Management
  210. * @{
  211. */
  212. /**
  213. * @brief Enable Random Number Generator Interrupt
  214. * (applies for either Seed error, Clock Error or Data ready interrupts)
  215. * @rmtoll CR IE LL_RNG_EnableIT
  216. * @param RNGx RNG Instance
  217. * @retval None
  218. */
  219. __STATIC_INLINE void LL_RNG_EnableIT(RNG_TypeDef *RNGx)
  220. {
  221. SET_BIT(RNGx->CR, RNG_CR_IE);
  222. }
  223. /**
  224. * @brief Disable Random Number Generator Interrupt
  225. * (applies for either Seed error, Clock Error or Data ready interrupts)
  226. * @rmtoll CR IE LL_RNG_DisableIT
  227. * @param RNGx RNG Instance
  228. * @retval None
  229. */
  230. __STATIC_INLINE void LL_RNG_DisableIT(RNG_TypeDef *RNGx)
  231. {
  232. CLEAR_BIT(RNGx->CR, RNG_CR_IE);
  233. }
  234. /**
  235. * @brief Check if Random Number Generator Interrupt is enabled
  236. * (applies for either Seed error, Clock Error or Data ready interrupts)
  237. * @rmtoll CR IE LL_RNG_IsEnabledIT
  238. * @param RNGx RNG Instance
  239. * @retval State of bit (1 or 0).
  240. */
  241. __STATIC_INLINE uint32_t LL_RNG_IsEnabledIT(RNG_TypeDef *RNGx)
  242. {
  243. return ((READ_BIT(RNGx->CR, RNG_CR_IE) == (RNG_CR_IE)) ? 1UL : 0UL);
  244. }
  245. /**
  246. * @}
  247. */
  248. /** @defgroup RNG_LL_EF_Data_Management Data Management
  249. * @{
  250. */
  251. /**
  252. * @brief Return32-bit Random Number value
  253. * @rmtoll DR RNDATA LL_RNG_ReadRandData32
  254. * @param RNGx RNG Instance
  255. * @retval Generated 32-bit random value
  256. */
  257. __STATIC_INLINE uint32_t LL_RNG_ReadRandData32(RNG_TypeDef *RNGx)
  258. {
  259. return (uint32_t)(READ_REG(RNGx->DR));
  260. }
  261. /**
  262. * @}
  263. */
  264. #if defined(USE_FULL_LL_DRIVER)
  265. /** @defgroup RNG_LL_EF_Init Initialization and de-initialization functions
  266. * @{
  267. */
  268. ErrorStatus LL_RNG_DeInit(RNG_TypeDef *RNGx);
  269. /**
  270. * @}
  271. */
  272. #endif /* USE_FULL_LL_DRIVER */
  273. /**
  274. * @}
  275. */
  276. /**
  277. * @}
  278. */
  279. #endif /* RNG */
  280. /**
  281. * @}
  282. */
  283. #ifdef __cplusplus
  284. }
  285. #endif
  286. #endif /* __STM32F4xx_LL_RNG_H */