Mercurial > public > ostc4
comparison Common/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_rng.h @ 160:e3ca52b8e7fa
Merge with FlipDisplay
author | heinrichsweikamp |
---|---|
date | Thu, 07 Mar 2019 15:06:43 +0100 |
parents | c78bcbd5deda |
children |
comparison
equal
deleted
inserted
replaced
80:cc2bb7bb8456 | 160:e3ca52b8e7fa |
---|---|
1 /** | |
2 ****************************************************************************** | |
3 * @file stm32f4xx_hal_rng.h | |
4 * @author MCD Application Team | |
5 * @brief Header file of RNG HAL module. | |
6 ****************************************************************************** | |
7 * @attention | |
8 * | |
9 * <h2><center>© COPYRIGHT(c) 2017 STMicroelectronics</center></h2> | |
10 * | |
11 * Redistribution and use in source and binary forms, with or without modification, | |
12 * are permitted provided that the following conditions are met: | |
13 * 1. Redistributions of source code must retain the above copyright notice, | |
14 * this list of conditions and the following disclaimer. | |
15 * 2. Redistributions in binary form must reproduce the above copyright notice, | |
16 * this list of conditions and the following disclaimer in the documentation | |
17 * and/or other materials provided with the distribution. | |
18 * 3. Neither the name of STMicroelectronics nor the names of its contributors | |
19 * may be used to endorse or promote products derived from this software | |
20 * without specific prior written permission. | |
21 * | |
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | |
23 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |
25 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | |
26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | |
28 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | |
29 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | |
30 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
32 * | |
33 ****************************************************************************** | |
34 */ | |
35 | |
36 /* Define to prevent recursive inclusion -------------------------------------*/ | |
37 #ifndef __STM32F4xx_HAL_RNG_H | |
38 #define __STM32F4xx_HAL_RNG_H | |
39 | |
40 #ifdef __cplusplus | |
41 extern "C" { | |
42 #endif | |
43 | |
44 #if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx) || defined(STM32F417xx) ||\ | |
45 defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) ||\ | |
46 defined(STM32F410Tx) || defined(STM32F410Cx) || defined(STM32F410Rx) || defined(STM32F469xx) ||\ | |
47 defined(STM32F479xx) || defined(STM32F412Zx) || defined(STM32F412Vx) || defined(STM32F412Rx) ||\ | |
48 defined(STM32F412Cx) || defined(STM32F413xx) || defined(STM32F423xx) | |
49 | |
50 /* Includes ------------------------------------------------------------------*/ | |
51 #include "stm32f4xx_hal_def.h" | |
52 | |
53 /** @addtogroup STM32F4xx_HAL_Driver | |
54 * @{ | |
55 */ | |
56 | |
57 /** @defgroup RNG RNG | |
58 * @brief RNG HAL module driver | |
59 * @{ | |
60 */ | |
61 | |
62 /* Exported types ------------------------------------------------------------*/ | |
63 | |
64 /** @defgroup RNG_Exported_Types RNG Exported Types | |
65 * @{ | |
66 */ | |
67 | |
68 /** @defgroup RNG_Exported_Types_Group1 RNG State Structure definition | |
69 * @{ | |
70 */ | |
71 typedef enum | |
72 { | |
73 HAL_RNG_STATE_RESET = 0x00U, /*!< RNG not yet initialized or disabled */ | |
74 HAL_RNG_STATE_READY = 0x01U, /*!< RNG initialized and ready for use */ | |
75 HAL_RNG_STATE_BUSY = 0x02U, /*!< RNG internal process is ongoing */ | |
76 HAL_RNG_STATE_TIMEOUT = 0x03U, /*!< RNG timeout state */ | |
77 HAL_RNG_STATE_ERROR = 0x04U /*!< RNG error state */ | |
78 | |
79 }HAL_RNG_StateTypeDef; | |
80 | |
81 /** | |
82 * @} | |
83 */ | |
84 | |
85 /** @defgroup RNG_Exported_Types_Group2 RNG Handle Structure definition | |
86 * @{ | |
87 */ | |
88 typedef struct | |
89 { | |
90 RNG_TypeDef *Instance; /*!< Register base address */ | |
91 | |
92 HAL_LockTypeDef Lock; /*!< RNG locking object */ | |
93 | |
94 __IO HAL_RNG_StateTypeDef State; /*!< RNG communication state */ | |
95 | |
96 uint32_t RandomNumber; /*!< Last Generated RNG Data */ | |
97 | |
98 }RNG_HandleTypeDef; | |
99 | |
100 /** | |
101 * @} | |
102 */ | |
103 | |
104 /** | |
105 * @} | |
106 */ | |
107 | |
108 /* Exported constants --------------------------------------------------------*/ | |
109 | |
110 /** @defgroup RNG_Exported_Constants RNG Exported Constants | |
111 * @{ | |
112 */ | |
113 | |
114 /** @defgroup RNG_Exported_Constants_Group1 RNG Interrupt definition | |
115 * @{ | |
116 */ | |
117 #define RNG_IT_DRDY RNG_SR_DRDY /*!< Data Ready interrupt */ | |
118 #define RNG_IT_CEI RNG_SR_CEIS /*!< Clock error interrupt */ | |
119 #define RNG_IT_SEI RNG_SR_SEIS /*!< Seed error interrupt */ | |
120 /** | |
121 * @} | |
122 */ | |
123 | |
124 /** @defgroup RNG_Exported_Constants_Group2 RNG Flag definition | |
125 * @{ | |
126 */ | |
127 #define RNG_FLAG_DRDY RNG_SR_DRDY /*!< Data ready */ | |
128 #define RNG_FLAG_CECS RNG_SR_CECS /*!< Clock error current status */ | |
129 #define RNG_FLAG_SECS RNG_SR_SECS /*!< Seed error current status */ | |
130 | |
131 /** | |
132 * @} | |
133 */ | |
134 | |
135 /** | |
136 * @} | |
137 */ | |
138 | |
139 /* Exported macros -----------------------------------------------------------*/ | |
140 | |
141 /** @defgroup RNG_Exported_Macros RNG Exported Macros | |
142 * @{ | |
143 */ | |
144 | |
145 /** @brief Reset RNG handle state | |
146 * @param __HANDLE__ RNG Handle | |
147 * @retval None | |
148 */ | |
149 #define __HAL_RNG_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_RNG_STATE_RESET) | |
150 | |
151 /** | |
152 * @brief Enables the RNG peripheral. | |
153 * @param __HANDLE__ RNG Handle | |
154 * @retval None | |
155 */ | |
156 #define __HAL_RNG_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= RNG_CR_RNGEN) | |
157 | |
158 /** | |
159 * @brief Disables the RNG peripheral. | |
160 * @param __HANDLE__ RNG Handle | |
161 * @retval None | |
162 */ | |
163 #define __HAL_RNG_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~RNG_CR_RNGEN) | |
164 | |
165 /** | |
166 * @brief Check the selected RNG flag status. | |
167 * @param __HANDLE__ RNG Handle | |
168 * @param __FLAG__ RNG flag | |
169 * This parameter can be one of the following values: | |
170 * @arg RNG_FLAG_DRDY: Data ready | |
171 * @arg RNG_FLAG_CECS: Clock error current status | |
172 * @arg RNG_FLAG_SECS: Seed error current status | |
173 * @retval The new state of __FLAG__ (SET or RESET). | |
174 */ | |
175 #define __HAL_RNG_GET_FLAG(__HANDLE__, __FLAG__) (((__HANDLE__)->Instance->SR & (__FLAG__)) == (__FLAG__)) | |
176 | |
177 /** | |
178 * @brief Clears the selected RNG flag status. | |
179 * @param __HANDLE__ RNG handle | |
180 * @param __FLAG__ RNG flag to clear | |
181 * @note WARNING: This is a dummy macro for HAL code alignment, | |
182 * flags RNG_FLAG_DRDY, RNG_FLAG_CECS and RNG_FLAG_SECS are read-only. | |
183 * @retval None | |
184 */ | |
185 #define __HAL_RNG_CLEAR_FLAG(__HANDLE__, __FLAG__) /* dummy macro */ | |
186 | |
187 | |
188 | |
189 /** | |
190 * @brief Enables the RNG interrupts. | |
191 * @param __HANDLE__ RNG Handle | |
192 * @retval None | |
193 */ | |
194 #define __HAL_RNG_ENABLE_IT(__HANDLE__) ((__HANDLE__)->Instance->CR |= RNG_CR_IE) | |
195 | |
196 /** | |
197 * @brief Disables the RNG interrupts. | |
198 * @param __HANDLE__ RNG Handle | |
199 * @retval None | |
200 */ | |
201 #define __HAL_RNG_DISABLE_IT(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~RNG_CR_IE) | |
202 | |
203 /** | |
204 * @brief Checks whether the specified RNG interrupt has occurred or not. | |
205 * @param __HANDLE__ RNG Handle | |
206 * @param __INTERRUPT__ specifies the RNG interrupt status flag to check. | |
207 * This parameter can be one of the following values: | |
208 * @arg RNG_IT_DRDY: Data ready interrupt | |
209 * @arg RNG_IT_CEI: Clock error interrupt | |
210 * @arg RNG_IT_SEI: Seed error interrupt | |
211 * @retval The new state of __INTERRUPT__ (SET or RESET). | |
212 */ | |
213 #define __HAL_RNG_GET_IT(__HANDLE__, __INTERRUPT__) (((__HANDLE__)->Instance->SR & (__INTERRUPT__)) == (__INTERRUPT__)) | |
214 | |
215 /** | |
216 * @brief Clear the RNG interrupt status flags. | |
217 * @param __HANDLE__ RNG Handle | |
218 * @param __INTERRUPT__ specifies the RNG interrupt status flag to clear. | |
219 * This parameter can be one of the following values: | |
220 * @arg RNG_IT_CEI: Clock error interrupt | |
221 * @arg RNG_IT_SEI: Seed error interrupt | |
222 * @note RNG_IT_DRDY flag is read-only, reading RNG_DR register automatically clears RNG_IT_DRDY. | |
223 * @retval None | |
224 */ | |
225 #define __HAL_RNG_CLEAR_IT(__HANDLE__, __INTERRUPT__) (((__HANDLE__)->Instance->SR) = ~(__INTERRUPT__)) | |
226 | |
227 /** | |
228 * @} | |
229 */ | |
230 | |
231 /* Exported functions --------------------------------------------------------*/ | |
232 /** @defgroup RNG_Exported_Functions RNG Exported Functions | |
233 * @{ | |
234 */ | |
235 | |
236 /** @defgroup RNG_Exported_Functions_Group1 Initialization and de-initialization functions | |
237 * @{ | |
238 */ | |
239 HAL_StatusTypeDef HAL_RNG_Init(RNG_HandleTypeDef *hrng); | |
240 HAL_StatusTypeDef HAL_RNG_DeInit (RNG_HandleTypeDef *hrng); | |
241 void HAL_RNG_MspInit(RNG_HandleTypeDef *hrng); | |
242 void HAL_RNG_MspDeInit(RNG_HandleTypeDef *hrng); | |
243 | |
244 /** | |
245 * @} | |
246 */ | |
247 | |
248 /** @defgroup RNG_Exported_Functions_Group2 Peripheral Control functions | |
249 * @{ | |
250 */ | |
251 uint32_t HAL_RNG_GetRandomNumber(RNG_HandleTypeDef *hrng); /* Obsolete, use HAL_RNG_GenerateRandomNumber() instead */ | |
252 uint32_t HAL_RNG_GetRandomNumber_IT(RNG_HandleTypeDef *hrng); /* Obsolete, use HAL_RNG_GenerateRandomNumber_IT() instead */ | |
253 | |
254 HAL_StatusTypeDef HAL_RNG_GenerateRandomNumber(RNG_HandleTypeDef *hrng, uint32_t *random32bit); | |
255 HAL_StatusTypeDef HAL_RNG_GenerateRandomNumber_IT(RNG_HandleTypeDef *hrng); | |
256 uint32_t HAL_RNG_ReadLastRandomNumber(RNG_HandleTypeDef *hrng); | |
257 | |
258 void HAL_RNG_IRQHandler(RNG_HandleTypeDef *hrng); | |
259 void HAL_RNG_ErrorCallback(RNG_HandleTypeDef *hrng); | |
260 void HAL_RNG_ReadyDataCallback(RNG_HandleTypeDef* hrng, uint32_t random32bit); | |
261 | |
262 /** | |
263 * @} | |
264 */ | |
265 | |
266 /** @defgroup RNG_Exported_Functions_Group3 Peripheral State functions | |
267 * @{ | |
268 */ | |
269 HAL_RNG_StateTypeDef HAL_RNG_GetState(RNG_HandleTypeDef *hrng); | |
270 | |
271 /** | |
272 * @} | |
273 */ | |
274 | |
275 /** | |
276 * @} | |
277 */ | |
278 | |
279 /* Private types -------------------------------------------------------------*/ | |
280 /** @defgroup RNG_Private_Types RNG Private Types | |
281 * @{ | |
282 */ | |
283 | |
284 /** | |
285 * @} | |
286 */ | |
287 | |
288 /* Private defines -----------------------------------------------------------*/ | |
289 /** @defgroup RNG_Private_Defines RNG Private Defines | |
290 * @{ | |
291 */ | |
292 | |
293 /** | |
294 * @} | |
295 */ | |
296 | |
297 /* Private variables ---------------------------------------------------------*/ | |
298 /** @defgroup RNG_Private_Variables RNG Private Variables | |
299 * @{ | |
300 */ | |
301 | |
302 /** | |
303 * @} | |
304 */ | |
305 | |
306 /* Private constants ---------------------------------------------------------*/ | |
307 /** @defgroup RNG_Private_Constants RNG Private Constants | |
308 * @{ | |
309 */ | |
310 | |
311 /** | |
312 * @} | |
313 */ | |
314 | |
315 /* Private macros ------------------------------------------------------------*/ | |
316 /** @defgroup RNG_Private_Macros RNG Private Macros | |
317 * @{ | |
318 */ | |
319 #define IS_RNG_IT(IT) (((IT) == RNG_IT_CEI) || \ | |
320 ((IT) == RNG_IT_SEI)) | |
321 | |
322 #define IS_RNG_FLAG(FLAG) (((FLAG) == RNG_FLAG_DRDY) || \ | |
323 ((FLAG) == RNG_FLAG_CECS) || \ | |
324 ((FLAG) == RNG_FLAG_SECS)) | |
325 | |
326 /** | |
327 * @} | |
328 */ | |
329 | |
330 /* Private functions prototypes ----------------------------------------------*/ | |
331 /** @defgroup RNG_Private_Functions_Prototypes RNG Private Functions Prototypes | |
332 * @{ | |
333 */ | |
334 | |
335 /** | |
336 * @} | |
337 */ | |
338 | |
339 /* Private functions ---------------------------------------------------------*/ | |
340 /** @defgroup RNG_Private_Functions RNG Private Functions | |
341 * @{ | |
342 */ | |
343 | |
344 /** | |
345 * @} | |
346 */ | |
347 | |
348 /** | |
349 * @} | |
350 */ | |
351 | |
352 /** | |
353 * @} | |
354 */ | |
355 | |
356 #endif /* STM32F405xx || STM32F415xx || STM32F407xx || STM32F417xx || STM32F427xx || STM32F437xx ||\ | |
357 STM32F429xx || STM32F439xx || STM32F410xx || STM32F469xx || STM32F479xx || STM32F412Zx ||\ | |
358 STM32F412Vx || STM32F412Rx || STM32F412Cx || STM32F413xx || STM32F423xx */ | |
359 | |
360 #ifdef __cplusplus | |
361 } | |
362 #endif | |
363 | |
364 | |
365 #endif /* __STM32F4xx_HAL_RNG_H */ | |
366 | |
367 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |