2 ******************************************************************************
3 * @file stm32f0xx_hal_wwdg.h
4 * @author MCD Application Team
6 * @date 11-December-2014
7 * @brief Header file of WWDG HAL module.
8 ******************************************************************************
11 * <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
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.
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.
35 ******************************************************************************
38 /* Define to prevent recursive inclusion -------------------------------------*/
39 #ifndef __STM32F0xx_HAL_WWDG_H
40 #define __STM32F0xx_HAL_WWDG_H
46 /* Includes ------------------------------------------------------------------*/
47 #include "stm32f0xx_hal_def.h"
49 /** @addtogroup STM32F0xx_HAL_Driver
57 /* Exported types ------------------------------------------------------------*/
59 /** @defgroup WWDG_Exported_Types WWDG Exported Types
64 * @brief WWDG HAL State Structure definition
68 HAL_WWDG_STATE_RESET = 0x00, /*!< WWDG not yet initialized or disabled */
69 HAL_WWDG_STATE_READY = 0x01, /*!< WWDG initialized and ready for use */
70 HAL_WWDG_STATE_BUSY = 0x02, /*!< WWDG internal process is ongoing */
71 HAL_WWDG_STATE_TIMEOUT = 0x03, /*!< WWDG timeout state */
72 HAL_WWDG_STATE_ERROR = 0x04 /*!< WWDG error state */
73 }HAL_WWDG_StateTypeDef;
76 * @brief WWDG Init structure definition
80 uint32_t Prescaler; /*!< Specifies the prescaler value of the WWDG.
81 This parameter can be a value of @ref WWDG_Prescaler */
83 uint32_t Window; /*!< Specifies the WWDG window value to be compared to the downcounter.
84 This parameter must be a number lower than Max_Data = 0x80 */
86 uint32_t Counter; /*!< Specifies the WWDG free-running downcounter value.
87 This parameter must be a number between Min_Data = 0x40 and Max_Data = 0x7F */
92 * @brief WWDG handle Structure definition
96 WWDG_TypeDef *Instance; /*!< Register base address */
98 WWDG_InitTypeDef Init; /*!< WWDG required parameters */
100 HAL_LockTypeDef Lock; /*!< WWDG locking object */
102 __IO HAL_WWDG_StateTypeDef State; /*!< WWDG communication state */
104 } WWDG_HandleTypeDef;
110 /* Exported constants --------------------------------------------------------*/
112 /** @defgroup WWDG_Exported_Constants WWDG Exported Constants
116 /** @defgroup WWDG_Interrupt_definition WWDG Interrupt definition
119 #define WWDG_IT_EWI WWDG_CFR_EWI /*!< Early wakeup interrupt */
124 /** @defgroup WWDG_Flag_definition WWDG Flag definition
125 * @brief WWDG Flag definition
128 #define WWDG_FLAG_EWIF WWDG_SR_EWIF /*!< Early wakeup interrupt flag */
133 /** @defgroup WWDG_Prescaler WWDG Prescaler
136 #define WWDG_PRESCALER_1 ((uint32_t)0x00000000) /*!< WWDG counter clock = (PCLK1/4096)/1 */
137 #define WWDG_PRESCALER_2 WWDG_CFR_WDGTB0 /*!< WWDG counter clock = (PCLK1/4096)/2 */
138 #define WWDG_PRESCALER_4 WWDG_CFR_WDGTB1 /*!< WWDG counter clock = (PCLK1/4096)/4 */
139 #define WWDG_PRESCALER_8 WWDG_CFR_WDGTB /*!< WWDG counter clock = (PCLK1/4096)/8 */
141 #define IS_WWDG_PRESCALER(__PRESCALER__) (((__PRESCALER__) == WWDG_PRESCALER_1) || \
142 ((__PRESCALER__) == WWDG_PRESCALER_2) || \
143 ((__PRESCALER__) == WWDG_PRESCALER_4) || \
144 ((__PRESCALER__) == WWDG_PRESCALER_8))
149 /** @defgroup WWDG_Window WWDG Window
152 #define IS_WWDG_WINDOW(__WINDOW__) ((__WINDOW__) <= 0x7F)
157 /** @defgroup WWDG_Counter WWDG Counter
160 #define IS_WWDG_COUNTER(__COUNTER__) (((__COUNTER__) >= 0x40) && ((__COUNTER__) <= 0x7F))
169 /* Exported macro ------------------------------------------------------------*/
171 /** @defgroup WWDG_Exported_Macros WWDG Exported Macros
175 /** @brief Reset WWDG handle state
176 * @param __HANDLE__: WWDG handle
179 #define __HAL_WWDG_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_WWDG_STATE_RESET)
182 * @brief Enables the WWDG peripheral.
183 * @param __HANDLE__: WWDG handle
186 #define __HAL_WWDG_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= WWDG_CR_WDGA)
189 * @brief Disables the WWDG peripheral.
190 * @param __HANDLE__: WWDG handle
191 * @note WARNING: This is a dummy macro for HAL code alignment.
192 * Once enable, WWDG Peripheral cannot be disabled except by a system reset.
195 #define __HAL_WWDG_DISABLE(__HANDLE__) /* dummy macro */
198 * @brief Enables the WWDG early wakeup interrupt.
199 * @param __HANDLE__: WWDG handle
200 * @param __INTERRUPT__: specifies the interrupt to enable.
201 * This parameter can be one of the following values:
202 * @arg WWDG_IT_EWI: Early wakeup interrupt
203 * @note Once enabled this interrupt cannot be disabled except by a system reset.
206 #define __HAL_WWDG_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CFR |= (__INTERRUPT__))
209 * @brief Disables the WWDG early wakeup interrupt.
210 * @param __HANDLE__: WWDG handle
211 * @param __INTERRUPT__: specifies the interrupt to disable.
212 * This parameter can be one of the following values:
213 * @arg WWDG_IT_EWI: Early wakeup interrupt
214 * @note WARNING: This is a dummy macro for HAL code alignment.
215 * Once enabled this interrupt cannot be disabled except by a system reset.
218 #define __HAL_WWDG_DISABLE_IT(__HANDLE__, __INTERRUPT__) /* dummy macro */
221 * @brief Gets the selected WWDG's it status.
222 * @param __HANDLE__: WWDG handle
223 * @param __INTERRUPT__: specifies the it to check.
224 * This parameter can be one of the following values:
225 * @arg WWDG_FLAG_EWIF: Early wakeup interrupt IT
226 * @retval The new state of WWDG_FLAG (SET or RESET).
228 #define __HAL_WWDG_GET_IT(__HANDLE__, __INTERRUPT__) (((__HANDLE__)->Instance->SR & (__INTERRUPT__)) == (__INTERRUPT__))
230 /** @brief Clear the WWDG's interrupt pending bits
231 * bits to clear the selected interrupt pending bits.
232 * @param __HANDLE__: WWDG handle
233 * @param __INTERRUPT__: specifies the interrupt pending bit to clear.
234 * This parameter can be one of the following values:
235 * @arg WWDG_FLAG_EWIF: Early wakeup interrupt flag
237 #define __HAL_WWDG_CLEAR_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->SR = ~(__INTERRUPT__))
240 * @brief Gets the selected WWDG's flag status.
241 * @param __HANDLE__: WWDG handle
242 * @param __FLAG__: specifies the flag to check.
243 * This parameter can be one of the following values:
244 * @arg WWDG_FLAG_EWIF: Early wakeup interrupt flag
245 * @retval The new state of WWDG_FLAG (SET or RESET).
247 #define __HAL_WWDG_GET_FLAG(__HANDLE__, __FLAG__) (((__HANDLE__)->Instance->SR & (__FLAG__)) == (__FLAG__))
250 * @brief Clears the WWDG's pending flags.
251 * @param __HANDLE__: WWDG handle
252 * @param __FLAG__: specifies the flag to clear.
253 * This parameter can be one of the following values:
254 * @arg WWDG_FLAG_EWIF: Early wakeup interrupt flag
257 #define __HAL_WWDG_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->SR = ~(__FLAG__))
259 /** @brief Checks if the specified WWDG interrupt source is enabled or disabled.
260 * @param __HANDLE__: WWDG Handle.
261 * @param __INTERRUPT__: specifies the WWDG interrupt source to check.
262 * This parameter can be one of the following values:
263 * @arg WWDG_IT_EWI: Early Wakeup Interrupt
264 * @retval state of __INTERRUPT__ (TRUE or FALSE).
266 #define __HAL_WWDG_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) (((__HANDLE__)->Instance->CFR & (__INTERRUPT__)) == (__INTERRUPT__))
272 /* Exported functions --------------------------------------------------------*/
274 /** @addtogroup WWDG_Exported_Functions
278 /** @addtogroup WWDG_Exported_Functions_Group1
281 /* Initialization/de-initialization functions **********************************/
282 HAL_StatusTypeDef HAL_WWDG_Init(WWDG_HandleTypeDef *hwwdg);
283 HAL_StatusTypeDef HAL_WWDG_DeInit(WWDG_HandleTypeDef *hwwdg);
284 void HAL_WWDG_MspInit(WWDG_HandleTypeDef *hwwdg);
285 void HAL_WWDG_MspDeInit(WWDG_HandleTypeDef *hwwdg);
286 void HAL_WWDG_WakeupCallback(WWDG_HandleTypeDef* hwwdg);
292 /** @addtogroup WWDG_Exported_Functions_Group2
295 /* I/O operation functions ******************************************************/
296 HAL_StatusTypeDef HAL_WWDG_Start(WWDG_HandleTypeDef *hwwdg);
297 HAL_StatusTypeDef HAL_WWDG_Start_IT(WWDG_HandleTypeDef *hwwdg);
298 HAL_StatusTypeDef HAL_WWDG_Refresh(WWDG_HandleTypeDef *hwwdg, uint32_t Counter);
299 void HAL_WWDG_IRQHandler(WWDG_HandleTypeDef *hwwdg);
305 /** @addtogroup WWDG_Exported_Functions_Group3
308 /* Peripheral State functions **************************************************/
309 HAL_WWDG_StateTypeDef HAL_WWDG_GetState(WWDG_HandleTypeDef *hwwdg);
331 #endif /* __STM32F0xx_HAL_WWDG_H */
333 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/