comparison Common/Drivers/STM32F4xx_HAL_DRIVER_v120/Inc/stm32f4xx_hal_rng.h @ 38:5f11787b4f42

include in ostc4 repository
author heinrichsweikamp
date Sat, 28 Apr 2018 11:52:34 +0200
parents
children
comparison
equal deleted inserted replaced
37:ccc45c0e1ea2 38:5f11787b4f42
1 /**
2 ******************************************************************************
3 * @file stm32f4xx_hal_rng.h
4 * @author MCD Application Team
5 * @version V1.2.0
6 * @date 26-December-2014
7 * @brief Header file of RNG HAL module.
8 ******************************************************************************
9 * @attention
10 *
11 * <h2><center>&copy; COPYRIGHT(c) 2014 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 __STM32F4xx_HAL_RNG_H
40 #define __STM32F4xx_HAL_RNG_H
41
42 #ifdef __cplusplus
43 extern "C" {
44 #endif
45
46 #if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx) || defined(STM32F417xx) ||\
47 defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx)
48
49 /* Includes ------------------------------------------------------------------*/
50 #include "stm32f4xx_hal_def.h"
51
52 /** @addtogroup STM32F4xx_HAL_Driver
53 * @{
54 */
55
56 /** @defgroup RNG RNG
57 * @brief RNG HAL module driver
58 * @{
59 */
60
61 /* Exported types ------------------------------------------------------------*/
62
63 /** @defgroup RNG_Exported_Types RNG Exported Types
64 * @{
65 */
66
67 /** @defgroup RNG_Exported_Types_Group1 RNG State Structure definition
68 * @{
69 */
70 typedef enum
71 {
72 HAL_RNG_STATE_RESET = 0x00, /*!< RNG not yet initialized or disabled */
73 HAL_RNG_STATE_READY = 0x01, /*!< RNG initialized and ready for use */
74 HAL_RNG_STATE_BUSY = 0x02, /*!< RNG internal process is ongoing */
75 HAL_RNG_STATE_TIMEOUT = 0x03, /*!< RNG timeout state */
76 HAL_RNG_STATE_ERROR = 0x04 /*!< RNG error state */
77
78 }HAL_RNG_StateTypeDef;
79
80 /**
81 * @}
82 */
83
84 /** @defgroup RNG_Exported_Types_Group2 RNG Handle Structure definition
85 * @{
86 */
87 typedef struct
88 {
89 RNG_TypeDef *Instance; /*!< Register base address */
90
91 HAL_LockTypeDef Lock; /*!< RNG locking object */
92
93 __IO HAL_RNG_StateTypeDef State; /*!< RNG communication state */
94
95 uint32_t RandomNumber; /*!< Last Generated RNG Data */
96
97 }RNG_HandleTypeDef;
98
99 /**
100 * @}
101 */
102
103 /**
104 * @}
105 */
106
107 /* Exported constants --------------------------------------------------------*/
108
109 /** @defgroup RNG_Exported_Constants RNG Exported Constants
110 * @{
111 */
112
113 /** @defgroup RNG_Exported_Constants_Group1 RNG Interrupt definition
114 * @{
115 */
116 #define RNG_IT_DRDY RNG_SR_DRDY /*!< Data Ready interrupt */
117 #define RNG_IT_CEI RNG_SR_CEIS /*!< Clock error interrupt */
118 #define RNG_IT_SEI RNG_SR_SEIS /*!< Seed error interrupt */
119 /**
120 * @}
121 */
122
123 /** @defgroup RNG_Exported_Constants_Group2 RNG Flag definition
124 * @{
125 */
126 #define RNG_FLAG_DRDY RNG_SR_DRDY /*!< Data ready */
127 #define RNG_FLAG_CECS RNG_SR_CECS /*!< Clock error current status */
128 #define RNG_FLAG_SECS RNG_SR_SECS /*!< Seed error current status */
129
130 /**
131 * @}
132 */
133
134 /**
135 * @}
136 */
137
138 /* Exported macros -----------------------------------------------------------*/
139
140 /** @defgroup RNG_Exported_Macros RNG Exported Macros
141 * @{
142 */
143
144 /** @brief Reset RNG handle state
145 * @param __HANDLE__: RNG Handle
146 * @retval None
147 */
148 #define __HAL_RNG_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_RNG_STATE_RESET)
149
150 /**
151 * @brief Enables the RNG peripheral.
152 * @param __HANDLE__: RNG Handle
153 * @retval None
154 */
155 #define __HAL_RNG_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= RNG_CR_RNGEN)
156
157 /**
158 * @brief Disables the RNG peripheral.
159 * @param __HANDLE__: RNG Handle
160 * @retval None
161 */
162 #define __HAL_RNG_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~RNG_CR_RNGEN)
163
164 /**
165 * @brief Check the selected RNG flag status.
166 * @param __HANDLE__: RNG Handle
167 * @param __FLAG__: RNG flag
168 * This parameter can be one of the following values:
169 * @arg RNG_FLAG_DRDY: Data ready
170 * @arg RNG_FLAG_CECS: Clock error current status
171 * @arg RNG_FLAG_SECS: Seed error current status
172 * @retval The new state of __FLAG__ (SET or RESET).
173 */
174 #define __HAL_RNG_GET_FLAG(__HANDLE__, __FLAG__) (((__HANDLE__)->Instance->SR & (__FLAG__)) == (__FLAG__))
175
176 /**
177 * @brief Clears the selected RNG flag status.
178 * @param __HANDLE__: RNG handle
179 * @param __FLAG__: RNG flag to clear
180 * @note WARNING: This is a dummy macro for HAL code alignment,
181 * flags RNG_FLAG_DRDY, RNG_FLAG_CECS and RNG_FLAG_SECS are read-only.
182 * @retval None
183 */
184 #define __HAL_RNG_CLEAR_FLAG(__HANDLE__, __FLAG__) /* dummy macro */
185
186
187
188 /**
189 * @brief Enables the RNG interrupts.
190 * @param __HANDLE__: RNG Handle
191 * @retval None
192 */
193 #define __HAL_RNG_ENABLE_IT(__HANDLE__) ((__HANDLE__)->Instance->CR |= RNG_CR_IE)
194
195 /**
196 * @brief Disables the RNG interrupts.
197 * @param __HANDLE__: RNG Handle
198 * @retval None
199 */
200 #define __HAL_RNG_DISABLE_IT(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~RNG_CR_IE)
201
202 /**
203 * @brief Checks whether the specified RNG interrupt has occurred or not.
204 * @param __HANDLE__: RNG Handle
205 * @param __INTERRUPT__: specifies the RNG interrupt status flag to check.
206 * This parameter can be one of the following values:
207 * @arg RNG_IT_DRDY: Data ready interrupt
208 * @arg RNG_IT_CEI: Clock error interrupt
209 * @arg RNG_IT_SEI: Seed error interrupt
210 * @retval The new state of __INTERRUPT__ (SET or RESET).
211 */
212 #define __HAL_RNG_GET_IT(__HANDLE__, __INTERRUPT__) (((__HANDLE__)->Instance->SR & (__INTERRUPT__)) == (__INTERRUPT__))
213
214 /**
215 * @brief Clear the RNG interrupt status flags.
216 * @param __HANDLE__: RNG Handle
217 * @param __INTERRUPT__: specifies the RNG interrupt status flag to clear.
218 * This parameter can be one of the following values:
219 * @arg RNG_IT_CEI: Clock error interrupt
220 * @arg RNG_IT_SEI: Seed error interrupt
221 * @note RNG_IT_DRDY flag is read-only, reading RNG_DR register automatically clears RNG_IT_DRDY.
222 * @retval None
223 */
224 #define __HAL_RNG_CLEAR_IT(__HANDLE__, __INTERRUPT__) (((__HANDLE__)->Instance->SR) = ~(__INTERRUPT__))
225
226 /**
227 * @}
228 */
229
230 /* Exported functions --------------------------------------------------------*/
231 /** @defgroup RNG_Exported_Functions RNG Exported Functions
232 * @{
233 */
234
235 /** @defgroup RNG_Exported_Functions_Group1 Initialization and de-initialization functions
236 * @{
237 */
238 HAL_StatusTypeDef HAL_RNG_Init(RNG_HandleTypeDef *hrng);
239 HAL_StatusTypeDef HAL_RNG_DeInit (RNG_HandleTypeDef *hrng);
240 void HAL_RNG_MspInit(RNG_HandleTypeDef *hrng);
241 void HAL_RNG_MspDeInit(RNG_HandleTypeDef *hrng);
242
243 /**
244 * @}
245 */
246
247 /** @defgroup RNG_Exported_Functions_Group2 Peripheral Control functions
248 * @{
249 */
250 uint32_t HAL_RNG_GetRandomNumber(RNG_HandleTypeDef *hrng); /* Obsolete, use HAL_RNG_GenerateRandomNumber() instead */
251 uint32_t HAL_RNG_GetRandomNumber_IT(RNG_HandleTypeDef *hrng); /* Obsolete, use HAL_RNG_GenerateRandomNumber_IT() instead */
252
253 HAL_StatusTypeDef HAL_RNG_GenerateRandomNumber(RNG_HandleTypeDef *hrng, uint32_t *random32bit);
254 HAL_StatusTypeDef HAL_RNG_GenerateRandomNumber_IT(RNG_HandleTypeDef *hrng);
255 uint32_t HAL_RNG_ReadLastRandomNumber(RNG_HandleTypeDef *hrng);
256
257 void HAL_RNG_IRQHandler(RNG_HandleTypeDef *hrng);
258 void HAL_RNG_ErrorCallback(RNG_HandleTypeDef *hrng);
259 void HAL_RNG_ReadyDataCallback(RNG_HandleTypeDef* hrng, uint32_t random32bit);
260
261 /**
262 * @}
263 */
264
265 /** @defgroup RNG_Exported_Functions_Group3 Peripheral State functions
266 * @{
267 */
268 HAL_RNG_StateTypeDef HAL_RNG_GetState(RNG_HandleTypeDef *hrng);
269
270 /**
271 * @}
272 */
273
274 /**
275 * @}
276 */
277
278 /* Private types -------------------------------------------------------------*/
279 /** @defgroup RNG_Private_Types RNG Private Types
280 * @{
281 */
282
283 /**
284 * @}
285 */
286
287 /* Private defines -----------------------------------------------------------*/
288 /** @defgroup RNG_Private_Defines RNG Private Defines
289 * @{
290 */
291
292 /**
293 * @}
294 */
295
296 /* Private variables ---------------------------------------------------------*/
297 /** @defgroup RNG_Private_Variables RNG Private Variables
298 * @{
299 */
300
301 /**
302 * @}
303 */
304
305 /* Private constants ---------------------------------------------------------*/
306 /** @defgroup RNG_Private_Constants RNG Private Constants
307 * @{
308 */
309
310 /**
311 * @}
312 */
313
314 /* Private macros ------------------------------------------------------------*/
315 /** @defgroup RNG_Private_Macros RNG Private Macros
316 * @{
317 */
318 #define IS_RNG_IT(IT) (((IT) == RNG_IT_CEI) || \
319 ((IT) == RNG_IT_SEI))
320
321 #define IS_RNG_FLAG(FLAG) (((FLAG) == RNG_FLAG_DRDY) || \
322 ((FLAG) == RNG_FLAG_CECS) || \
323 ((FLAG) == RNG_FLAG_SECS))
324
325 /**
326 * @}
327 */
328
329 /* Private functions prototypes ----------------------------------------------*/
330 /** @defgroup RNG_Private_Functions_Prototypes RNG Private Functions Prototypes
331 * @{
332 */
333
334 /**
335 * @}
336 */
337
338 /* Private functions ---------------------------------------------------------*/
339 /** @defgroup RNG_Private_Functions RNG Private Functions
340 * @{
341 */
342
343 /**
344 * @}
345 */
346
347 /**
348 * @}
349 */
350
351 /**
352 * @}
353 */
354
355 #endif /* STM32F405xx || STM32F415xx || STM32F407xx || STM32F417xx || STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx */
356
357 #ifdef __cplusplus
358 }
359 #endif
360
361
362 #endif /* __STM32F4xx_HAL_RNG_H */
363
364 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/