]> git.donarmstrong.com Git - qmk_firmware.git/blob - tool/mbed/mbed-sdk/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_STM32F4/stm32f4xx_hal_rng.h
Squashed 'tmk_core/' changes from 7967731..b9e0ea0
[qmk_firmware.git] / tool / mbed / mbed-sdk / libraries / mbed / targets / cmsis / TARGET_STM / TARGET_STM32F4 / stm32f4xx_hal_rng.h
1 /**
2   ******************************************************************************
3   * @file    stm32f4xx_hal_rng.h
4   * @author  MCD Application Team
5   * @version V1.1.0
6   * @date    19-June-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 /* Includes ------------------------------------------------------------------*/
49 #include "stm32f4xx_hal_def.h"
50
51 /** @addtogroup STM32F4xx_HAL_Driver
52   * @{
53   */
54
55 /** @addtogroup RNG
56   * @{
57   */ 
58
59 /* Exported types ------------------------------------------------------------*/ 
60
61 /** 
62   * @brief  RNG HAL State Structure definition  
63   */ 
64 typedef enum
65 {
66   HAL_RNG_STATE_RESET     = 0x00,  /*!< RNG not yet initialized or disabled */
67   HAL_RNG_STATE_READY     = 0x01,  /*!< RNG initialized and ready for use   */
68   HAL_RNG_STATE_BUSY      = 0x02,  /*!< RNG internal process is ongoing     */ 
69   HAL_RNG_STATE_TIMEOUT   = 0x03,  /*!< RNG timeout state                   */
70   HAL_RNG_STATE_ERROR     = 0x04   /*!< RNG error state                     */
71     
72 }HAL_RNG_StateTypeDef;
73
74 /** 
75   * @brief  RNG Handle Structure definition  
76   */ 
77 typedef struct
78 {
79   RNG_TypeDef                 *Instance;  /*!< Register base address   */ 
80   
81   HAL_LockTypeDef             Lock;       /*!< RNG locking object      */
82   
83   __IO HAL_RNG_StateTypeDef   State;      /*!< RNG communication state */
84   
85 }RNG_HandleTypeDef;
86
87 /* Exported constants --------------------------------------------------------*/
88
89 /** @defgroup RNG_Exported_Constants
90   * @{
91   */
92
93 /** @defgroup RNG_Interrupt_definition 
94   * @{
95   */ 
96 #define RNG_IT_CEI   ((uint32_t)0x20)  /*!< Clock error interrupt */
97 #define RNG_IT_SEI   ((uint32_t)0x40)  /*!< Seed error interrupt  */
98
99 #define IS_RNG_IT(IT) (((IT) == RNG_IT_CEI) || \
100                        ((IT) == RNG_IT_SEI))
101 /**
102   * @}
103   */
104
105
106 /** @defgroup RNG_Flag_definition 
107   * @{
108   */ 
109 #define RNG_FLAG_DRDY   ((uint32_t)0x0001)  /*!< Data ready                 */
110 #define RNG_FLAG_CECS   ((uint32_t)0x0002)  /*!< Clock error current status */
111 #define RNG_FLAG_SECS   ((uint32_t)0x0004)  /*!< Seed error current status  */
112
113 #define IS_RNG_FLAG(FLAG) (((FLAG) == RNG_FLAG_DRDY) || \
114                            ((FLAG) == RNG_FLAG_CECS) || \
115                            ((FLAG) == RNG_FLAG_SECS))
116 /**
117   * @}
118   */
119
120 /**
121   * @}
122   */ 
123   
124 /* Exported macro ------------------------------------------------------------*/
125
126 /** @brief Reset RNG handle state
127   * @param  __HANDLE__: RNG Handle
128   * @retval None
129   */
130 #define __HAL_RNG_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_RNG_STATE_RESET)
131
132 /**
133   * @brief  Enables the RNG peripheral.
134   * @param  __HANDLE__: RNG Handle
135   * @retval None
136   */
137 #define __HAL_RNG_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |=  RNG_CR_RNGEN)
138
139 /**
140   * @brief  Disables the RNG peripheral.
141   * @param  __HANDLE__: RNG Handle
142   * @retval None
143   */
144 #define __HAL_RNG_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~RNG_CR_RNGEN)
145
146 /**
147   * @brief  Gets the selected RNG's flag status.
148   * @param  __HANDLE__: RNG Handle
149   * @param  __FLAG__: RNG flag
150   * @retval The new state of RNG_FLAG (SET or RESET).
151   */
152 #define __HAL_RNG_GET_FLAG(__HANDLE__, __FLAG__) (((__HANDLE__)->Instance->SR & (__FLAG__)) == (__FLAG__))
153
154 /**
155   * @brief  Clears the RNG's pending flags.
156   * @param  __HANDLE__: RNG Handle
157   * @param  __FLAG__: RNG flag
158   * @retval None
159   */
160 #define __HAL_RNG_CLEAR_FLAG(__HANDLE__, __FLAG__) (((__HANDLE__)->Instance->SR) = ~(__FLAG__))
161     
162 /**
163   * @brief  Enables the RNG interrupts.
164   * @param  __HANDLE__: RNG Handle
165   * @retval None
166   */
167 #define __HAL_RNG_ENABLE_IT(__HANDLE__) ((__HANDLE__)->Instance->CR |=  RNG_CR_IE)
168     
169 /**
170   * @brief  Disables the RNG interrupts.
171   * @param  __HANDLE__: RNG Handle
172   * @retval None
173   */
174 #define __HAL_RNG_DISABLE_IT(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~RNG_CR_IE)
175
176 /**
177   * @brief  Checks whether the specified RNG interrupt has occurred or not.
178   * @param  __HANDLE__: RNG Handle
179   * @param  __INTERRUPT__: specifies the RNG interrupt source to check.
180   *         This parameter can be one of the following values:
181   *            @arg RNG_FLAG_DRDY: Data ready interrupt
182   *            @arg RNG_FLAG_CECS: Clock error interrupt
183   *            @arg RNG_FLAG_SECS: Seed error interrupt
184   * @retval The new state of RNG_FLAG (SET or RESET).
185   */
186 #define __HAL_RNG_GET_IT(__HANDLE__, __INTERRUPT__) (((__HANDLE__)->Instance->SR & (__INTERRUPT__)) == (__INTERRUPT__))   
187
188 /* Exported functions --------------------------------------------------------*/
189
190 /* Initialization/de-initialization functions  **********************************/
191 HAL_StatusTypeDef HAL_RNG_Init(RNG_HandleTypeDef *hrng);
192 HAL_StatusTypeDef HAL_RNG_DeInit (RNG_HandleTypeDef *hrng);
193 void HAL_RNG_MspInit(RNG_HandleTypeDef *hrng);
194 void HAL_RNG_MspDeInit(RNG_HandleTypeDef *hrng);
195
196 /* Peripheral Control functions  ************************************************/
197 uint32_t HAL_RNG_GetRandomNumber(RNG_HandleTypeDef *hrng);
198 uint32_t HAL_RNG_GetRandomNumber_IT(RNG_HandleTypeDef *hrng);
199 void HAL_RNG_IRQHandler(RNG_HandleTypeDef *hrng);
200 void HAL_RNG_ReadyCallback(RNG_HandleTypeDef* hrng);
201 void HAL_RNG_ErrorCallback(RNG_HandleTypeDef *hrng);
202
203 /* Peripheral State functions  **************************************************/
204 HAL_RNG_StateTypeDef HAL_RNG_GetState(RNG_HandleTypeDef *hrng);
205
206 #endif /* STM32F405xx || STM32F415xx || STM32F407xx || STM32F417xx || STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx */
207
208 /**
209   * @}
210   */ 
211
212 /**
213   * @}
214   */ 
215
216 #ifdef __cplusplus
217 }
218 #endif
219
220 #endif /* __STM32F4xx_HAL_RNG_H */
221
222 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/