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