]> git.donarmstrong.com Git - qmk_firmware.git/blob - tmk_core/tool/mbed/mbed-sdk/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_STM32L0/stm32l0xx_hal_wwdg.h
allow overriding of TARGET
[qmk_firmware.git] / tmk_core / tool / mbed / mbed-sdk / libraries / mbed / targets / cmsis / TARGET_STM / TARGET_STM32L0 / stm32l0xx_hal_wwdg.h
1 /**
2   ******************************************************************************
3   * @file    stm32l0xx_hal_wwdg.h
4   * @author  MCD Application Team
5   * @version V1.2.0
6   * @date    06-February-2015
7   * @brief   Header file of WWDG HAL module.
8   ******************************************************************************
9   * @attention
10   *
11   * <h2><center>&copy; 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 __STM32L0xx_HAL_WWDG_H
40 #define __STM32L0xx_HAL_WWDG_H
41
42 #ifdef __cplusplus
43  extern "C" {
44 #endif
45
46 /* Includes ------------------------------------------------------------------*/
47 #include "stm32l0xx_hal_def.h"
48
49 /** @addtogroup STM32L0xx_HAL_Driver
50   * @{
51   */
52
53 /** @defgroup WWDG WWDG (Window watchdog)
54   * @{
55   */
56
57 /* Exported types ------------------------------------------------------------*/
58
59 /** @defgroup WWDG_Exported_Types WWDG Exported Types
60   * @{
61   */
62
63 /** @defgroup WWDG_State WWDG state definition
64   * @{
65   */
66 /**
67   * @brief  WWDG HAL State Structure definition
68   */
69 typedef enum
70 {
71   HAL_WWDG_STATE_RESET     = 0x00,  /*!< WWDG not yet initialized or disabled */
72   HAL_WWDG_STATE_READY     = 0x01,  /*!< WWDG initialized and ready for use   */
73   HAL_WWDG_STATE_BUSY      = 0x02,  /*!< WWDG internal process is ongoing     */
74   HAL_WWDG_STATE_TIMEOUT   = 0x03,  /*!< WWDG timeout state                   */
75   HAL_WWDG_STATE_ERROR     = 0x04   /*!< WWDG error state                     */
76 }HAL_WWDG_StateTypeDef;
77
78 /**
79   * @}
80   */
81
82 /** @defgroup WWDG_Init WWDG init configuration structure
83   * @{
84   */
85 /** 
86   * @brief  WWDG Init configuration structure
87   */
88 typedef struct
89 {
90   uint32_t Prescaler;  /*!< Specifies the prescaler value of the WWDG.
91                             This parameter can be a value of @ref WWDG_Prescaler */
92
93   uint32_t Window;     /*!< Specifies the WWDG window value to be compared to the downcounter.
94                             This parameter must be a number lower than Max_Data = 0x80 */
95
96   uint32_t Counter;    /*!< Specifies the WWDG free-running downcounter  value.
97                             This parameter must be a number between Min_Data = 0x40 and Max_Data = 0x7F */
98
99 }WWDG_InitTypeDef;
100 /**
101   * @}
102   */
103
104 /** @defgroup WWDG_handle WWDG handler
105   * @{
106   */
107 /**
108   * @brief  WWDG handle Structure definition
109   */
110 typedef struct
111 {
112   WWDG_TypeDef                 *Instance;  /*!< Register base address    */
113
114   WWDG_InitTypeDef             Init;       /*!< WWDG required parameters */
115
116   HAL_LockTypeDef              Lock;       /*!< WWDG locking object      */
117
118   __IO HAL_WWDG_StateTypeDef   State;      /*!< WWDG communication state */
119
120 }WWDG_HandleTypeDef;
121
122 /**
123   * @}
124   */
125
126 /**
127   * @}
128   */
129
130 /* Exported constants --------------------------------------------------------*/
131
132 /** @defgroup WWDG_Exported_Constants WWDG Exported Constants
133   * @{
134   */
135
136 /** @defgroup WWDG_BitAddress_AliasRegion WWDG BitAddress AliasRegion
137   * @brief WWDG registers bit address in the alias region
138   * @{
139   */
140
141 /* --- CFR Register ---*/
142 /* Alias word address of EWI bit */
143 #define WWDG_CFR_BASE   (uint32_t)(WWDG_BASE + 0x04)
144
145 /**
146   * @}
147   */
148
149 /** @defgroup WWDG_Interrupt_definition WWDG Interrupt definition
150   * @{
151   */
152 #define WWDG_IT_EWI   ((uint32_t)WWDG_CFR_EWI)
153 /**
154   * @}
155   */
156
157 /** @defgroup WWDG_Flag_definition WWDG Flag definition
158   * @brief WWDG Flag definition
159   * @{
160   */
161 #define WWDG_FLAG_EWIF   ((uint32_t)WWDG_SR_EWIF)  /*!< Early wakeup interrupt flag */
162 /**
163   * @}
164   */
165
166 /** @defgroup WWDG_Prescaler WWDG Prescaler
167   * @{
168   */
169 #define WWDG_PRESCALER_1   ((uint32_t)0x00000000)  /*!< WWDG counter clock = (PCLK1/4096)/1 */
170 #define WWDG_PRESCALER_2   ((uint32_t)WWDG_CFR_WDGTB0)  /*!< WWDG counter clock = (PCLK1/4096)/2 */
171 #define WWDG_PRESCALER_4   ((uint32_t)WWDG_CFR_WDGTB1)  /*!< WWDG counter clock = (PCLK1/4096)/4 */
172 #define WWDG_PRESCALER_8   ((uint32_t)WWDG_CFR_WDGTB)  /*!< WWDG counter clock = (PCLK1/4096)/8 */
173 /**
174   * @}
175   */
176 #define IS_WWDG_PRESCALER(__PRESCALER__) (((__PRESCALER__) == WWDG_PRESCALER_1) || \
177                                           ((__PRESCALER__) == WWDG_PRESCALER_2) || \
178                                           ((__PRESCALER__) == WWDG_PRESCALER_4) || \
179                                           ((__PRESCALER__) == WWDG_PRESCALER_8))
180
181
182
183 /* Check for window */
184 #define IS_WWDG_WINDOW(__WINDOW__) ((__WINDOW__) <= 0x7F)
185
186 /* Check for counter */
187 #define IS_WWDG_COUNTER(__COUNTER__) (((__COUNTER__) >= 0x40) && ((__COUNTER__) <= 0x7F))
188
189 /**
190   * @}
191   */
192
193 /* Exported macro ------------------------------------------------------------*/
194
195 /** @defgroup WWDG_Exported_Macros WWDG Exported Macros
196   * @{
197   */
198
199 /** @brief Reset WWDG handle state
200   * @param  __HANDLE__: WWDG handle
201   * @retval None
202   */
203 #define __HAL_WWDG_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_WWDG_STATE_RESET)
204
205 /**
206   * @brief  Enables the WWDG peripheral.
207   * @param  __HANDLE__: WWDG handle
208   * @retval None
209   */
210 #define __HAL_WWDG_ENABLE(__HANDLE__)               SET_BIT((__HANDLE__)->Instance->CR, WWDG_CR_WDGA)
211
212 /**
213   * @brief  Disables the WWDG peripheral.
214   * @param  __HANDLE__: WWDG handle
215   * @note   WARNING: This is a dummy macro for HAL code alignment.
216   *         Once enable, WWDG Peripheral cannot be disabled except by a system reset.
217   * @retval None
218   */
219 #define __HAL_WWDG_DISABLE(__HANDLE__)                      /* dummy  macro */
220
221 /**
222   * @brief  Enables the WWDG early wakeup interrupt.
223   * @param  __HANDLE__: WWDG handle
224   * @param  __INTERRUPT__: specifies the interrupt to enable.
225   *         This parameter can be one of the following values:
226   *            @arg WWDG_IT_EWI: Early wakeup interrupt
227   * @note   Once enabled this interrupt cannot be disabled except by a system reset.
228   * @retval None
229   */
230 #define __HAL_WWDG_ENABLE_IT(__HANDLE__, __INTERRUPT__)     ((__HANDLE__)->Instance->CFR |= (__INTERRUPT__))
231 /**
232   * @brief  Disables the WWDG early wakeup interrupt.
233   * @param  __HANDLE__: WWDG handle:
234   * @param  __INTERRUPT__: specifies the interrupt to disable.
235   *            @arg WWDG_IT_EWI: Early wakeup interrupt
236   * @note   WARNING: This is a dummy macro for HAL code alignment.
237   *         Once enabled this interrupt cannot be disabled except by a system reset.
238   * @retval None
239   */
240 #define __HAL_WWDG_DISABLE_IT(__HANDLE__, __INTERRUPT__)                   /* dummy  macro */
241
242 /**
243   * @brief  Gets the selected WWDG's it status.
244   * @param  __HANDLE__: WWDG handle
245   * @param  __INTERRUPT__: specifies the it to check.
246   *        This parameter can be one of the following values:
247   *            @arg WWDG_FLAG_EWIF: Early wakeup interrupt IT
248   * @retval The new state of WWDG_FLAG (SET or RESET).
249   */
250 #define __HAL_WWDG_GET_IT(__HANDLE__, __INTERRUPT__)        (((__HANDLE__)->Instance->SR & (__INTERRUPT__)) == (__INTERRUPT__))
251
252 /** @brief  Clear the WWDG's interrupt pending bits
253   *         bits to clear the selected interrupt pending bits.
254   * @param  __HANDLE__: WWDG handle
255   * @param  __INTERRUPT__: specifies the interrupt pending bit to clear.
256   *         This parameter can be one of the following values:
257   *            @arg WWDG_FLAG_EWIF: Early wakeup interrupt flag
258   */
259 #define __HAL_WWDG_CLEAR_IT(__HANDLE__, __INTERRUPT__) __HAL_WWDG_CLEAR_FLAG((__HANDLE__), (__INTERRUPT__))
260
261 /**
262   * @brief  Gets the selected WWDG's flag status.
263   * @param  __HANDLE__: WWDG handle
264   * @param  __FLAG__: specifies the flag to check.
265   *         This parameter can be one of the following values:
266   *            @arg WWDG_FLAG_EWIF: Early wakeup interrupt flag
267   * @retval The new state of WWDG_FLAG (SET or RESET).
268   */
269 #define __HAL_WWDG_GET_FLAG(__HANDLE__, __FLAG__) (((__HANDLE__)->Instance->SR & (__FLAG__)) == (__FLAG__))
270
271 /**
272   * @brief  Clears the WWDG's pending flags.
273   * @param  __HANDLE__: WWDG handle
274   * @param  __FLAG__: specifies the flag to clear.
275   *         This parameter can be one of the following values:
276   *            @arg WWDG_FLAG_EWIF: Early wakeup interrupt flag
277   * @retval None
278   */
279 #define __HAL_WWDG_CLEAR_FLAG(__HANDLE__, __FLAG__) (((__HANDLE__)->Instance->SR) = ~(__FLAG__))
280
281 /** @brief  Checks if the specified WWDG interrupt source is enabled or disabled.
282   * @param  __HANDLE__: WWDG Handle.
283   * @param  __INTERRUPT__: specifies the WWDG interrupt source to check.
284   *          This parameter can be one of the following values:
285   *            @arg WWDG_IT_EWI: Early Wakeup Interrupt
286   * @retval state of __INTERRUPT__ (TRUE or FALSE).
287   */
288 #define __HAL_WWDG_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) (((__HANDLE__)->Instance->CFR & (__INTERRUPT__)) == (__INTERRUPT__))
289
290 /**
291   * @}
292   */
293
294
295 /** @defgroup WWDG_Exported_Functions WWDG Exported Functions
296   * @{
297   */
298
299 /** @defgroup WWDG_Exported_Functions_Group1 Initialization and de-initialization functions 
300   * @{
301   */
302 HAL_StatusTypeDef HAL_WWDG_Init(WWDG_HandleTypeDef *hwwdg);
303 HAL_StatusTypeDef HAL_WWDG_DeInit(WWDG_HandleTypeDef *hwwdg);
304 void HAL_WWDG_MspInit(WWDG_HandleTypeDef *hwwdg);
305 void HAL_WWDG_MspDeInit(WWDG_HandleTypeDef *hwwdg);
306 void HAL_WWDG_WakeupCallback(WWDG_HandleTypeDef* hwwdg);
307 /**
308   * @}
309   */
310
311 /** @defgroup WWDG_Exported_Functions_Group2 IO operation functions 
312   * @{
313   */
314 HAL_StatusTypeDef HAL_WWDG_Start(WWDG_HandleTypeDef *hwwdg);
315 HAL_StatusTypeDef HAL_WWDG_Start_IT(WWDG_HandleTypeDef *hwwdg);
316 HAL_StatusTypeDef HAL_WWDG_Refresh(WWDG_HandleTypeDef *hwwdg, uint32_t Counter);
317 void HAL_WWDG_IRQHandler(WWDG_HandleTypeDef *hwwdg);
318 /**
319   * @}
320   */
321
322 /** @defgroup WWDG_Exported_Functions_Group3 Peripheral State functions 
323   * @{
324   */
325 HAL_WWDG_StateTypeDef HAL_WWDG_GetState(WWDG_HandleTypeDef *hwwdg);
326 /**
327   * @}
328   */
329
330 /**
331   * @}
332   */
333
334 /**
335   * @}
336   */
337
338 /**
339   * @}
340   */
341
342 #ifdef __cplusplus
343 }
344 #endif
345
346 #endif /* __STM32L0xx_HAL_WWDG_H */
347
348 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
349