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