1 /** 2 ****************************************************************************** 3 * @file stm32l4xx_hal_wwdg.h 4 * @author MCD Application Team 5 * @brief Header file of WWDG HAL module. 6 ****************************************************************************** 7 * @attention 8 * 9 * <h2><center>© COPYRIGHT(c) 2017 STMicroelectronics</center></h2> 10 * 11 * Redistribution and use in source and binary forms, with or without modification, 12 * are permitted provided that the following conditions are met: 13 * 1. Redistributions of source code must retain the above copyright notice, 14 * this list of conditions and the following disclaimer. 15 * 2. Redistributions in binary form must reproduce the above copyright notice, 16 * this list of conditions and the following disclaimer in the documentation 17 * and/or other materials provided with the distribution. 18 * 3. Neither the name of STMicroelectronics nor the names of its contributors 19 * may be used to endorse or promote products derived from this software 20 * without specific prior written permission. 21 * 22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 23 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 25 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 28 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 29 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 30 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 * 33 ****************************************************************************** 34 */ 35 36 /* Define to prevent recursive inclusion -------------------------------------*/ 37 #ifndef __STM32L4xx_HAL_WWDG_H 38 #define __STM32L4xx_HAL_WWDG_H 39 40 #ifdef __cplusplus 41 extern "C" { 42 #endif 43 44 /* Includes ------------------------------------------------------------------*/ 45 #include "stm32l4xx_hal_def.h" 46 47 /** @addtogroup STM32L4xx_HAL_Driver 48 * @{ 49 */ 50 51 /** @addtogroup WWDG 52 * @{ 53 */ 54 55 /* Exported types ------------------------------------------------------------*/ 56 57 /** @defgroup WWDG_Exported_Types WWDG Exported Types 58 * @{ 59 */ 60 61 /** 62 * @brief WWDG Init structure definition 63 */ 64 typedef struct 65 { 66 uint32_t Prescaler; /*!< Specifies the prescaler value of the WWDG. 67 This parameter can be a value of @ref WWDG_Prescaler */ 68 69 uint32_t Window; /*!< Specifies the WWDG window value to be compared to the downcounter. 70 This parameter must be a number Min_Data = 0x40 and Max_Data = 0x7F */ 71 72 uint32_t Counter; /*!< Specifies the WWDG free-running downcounter value. 73 This parameter must be a number between Min_Data = 0x40 and Max_Data = 0x7F */ 74 75 uint32_t EWIMode ; /*!< Specifies if WWDG Early Wakeup Interupt is enable or not. 76 This parameter can be a value of @ref WWDG_EWI_Mode */ 77 78 } WWDG_InitTypeDef; 79 80 /** 81 * @brief WWDG handle Structure definition 82 */ 83 typedef struct __WWDG_HandleTypeDef 84 { 85 WWDG_TypeDef *Instance; /*!< Register base address */ 86 87 WWDG_InitTypeDef Init; /*!< WWDG required parameters */ 88 89 #if (USE_HAL_WWDG_REGISTER_CALLBACKS == 1) 90 void (* EwiCallback)(struct __WWDG_HandleTypeDef *hwwdg); /*!< WWDG Early WakeUp Interrupt callback */ 91 92 void (* MspInitCallback)(struct __WWDG_HandleTypeDef *hwwdg); /*!< WWDG Msp Init callback */ 93 #endif 94 } WWDG_HandleTypeDef; 95 96 #if (USE_HAL_WWDG_REGISTER_CALLBACKS == 1) 97 /** 98 * @brief HAL WWDG common Callback ID enumeration definition 99 */ 100 typedef enum 101 { 102 HAL_WWDG_EWI_CB_ID = 0x00u, /*!< WWDG EWI callback ID */ 103 HAL_WWDG_MSPINIT_CB_ID = 0x01u, /*!< WWDG MspInit callback ID */ 104 }HAL_WWDG_CallbackIDTypeDef; 105 106 /** 107 * @brief HAL WWDG Callback pointer definition 108 */ 109 typedef void (*pWWDG_CallbackTypeDef)(WWDG_HandleTypeDef * hppp); /*!< pointer to a WWDG common callback functions */ 110 111 #endif 112 /** 113 * @} 114 */ 115 116 /* Exported constants --------------------------------------------------------*/ 117 118 /** @defgroup WWDG_Exported_Constants WWDG Exported Constants 119 * @{ 120 */ 121 122 /** @defgroup WWDG_Interrupt_definition WWDG Interrupt definition 123 * @{ 124 */ 125 #define WWDG_IT_EWI WWDG_CFR_EWI /*!< Early wakeup interrupt */ 126 /** 127 * @} 128 */ 129 130 /** @defgroup WWDG_Flag_definition WWDG Flag definition 131 * @brief WWDG Flag definition 132 * @{ 133 */ 134 #define WWDG_FLAG_EWIF WWDG_SR_EWIF /*!< Early wakeup interrupt flag */ 135 /** 136 * @} 137 */ 138 139 /** @defgroup WWDG_Prescaler WWDG Prescaler 140 * @{ 141 */ 142 #define WWDG_PRESCALER_1 0x00000000u /*!< WWDG counter clock = (PCLK1/4096)/1 */ 143 #define WWDG_PRESCALER_2 WWDG_CFR_WDGTB_0 /*!< WWDG counter clock = (PCLK1/4096)/2 */ 144 #define WWDG_PRESCALER_4 WWDG_CFR_WDGTB_1 /*!< WWDG counter clock = (PCLK1/4096)/4 */ 145 #define WWDG_PRESCALER_8 (WWDG_CFR_WDGTB_1 | WWDG_CFR_WDGTB_0) /*!< WWDG counter clock = (PCLK1/4096)/8 */ 146 /** 147 * @} 148 */ 149 150 /** @defgroup WWDG_EWI_Mode WWDG Early Wakeup Interrupt Mode 151 * @{ 152 */ 153 #define WWDG_EWI_DISABLE 0x00000000u /*!< EWI Disable */ 154 #define WWDG_EWI_ENABLE WWDG_CFR_EWI /*!< EWI Enable */ 155 /** 156 * @} 157 */ 158 159 /** 160 * @} 161 */ 162 163 /* Private macros ------------------------------------------------------------*/ 164 165 /** @defgroup WWDG_Private_Macros WWDG Private Macros 166 * @{ 167 */ 168 #define IS_WWDG_PRESCALER(__PRESCALER__) (((__PRESCALER__) == WWDG_PRESCALER_1) || \ 169 ((__PRESCALER__) == WWDG_PRESCALER_2) || \ 170 ((__PRESCALER__) == WWDG_PRESCALER_4) || \ 171 ((__PRESCALER__) == WWDG_PRESCALER_8)) 172 173 #define IS_WWDG_WINDOW(__WINDOW__) (((__WINDOW__) >= WWDG_CFR_W_6) && ((__WINDOW__) <= WWDG_CFR_W)) 174 175 #define IS_WWDG_COUNTER(__COUNTER__) (((__COUNTER__) >= WWDG_CR_T_6) && ((__COUNTER__) <= WWDG_CR_T)) 176 177 #define IS_WWDG_EWI_MODE(__MODE__) (((__MODE__) == WWDG_EWI_ENABLE) || \ 178 ((__MODE__) == WWDG_EWI_DISABLE)) 179 /** 180 * @} 181 */ 182 183 184 /* Exported macros ------------------------------------------------------------*/ 185 186 /** @defgroup WWDG_Exported_Macros WWDG Exported Macros 187 * @{ 188 */ 189 190 /** 191 * @brief Enable the WWDG peripheral. 192 * @param __HANDLE__ WWDG handle 193 * @retval None 194 */ 195 #define __HAL_WWDG_ENABLE(__HANDLE__) SET_BIT((__HANDLE__)->Instance->CR, WWDG_CR_WDGA) 196 197 /** 198 * @brief Enable 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. 204 * @retval None 205 */ 206 #define __HAL_WWDG_ENABLE_IT(__HANDLE__, __INTERRUPT__) SET_BIT((__HANDLE__)->Instance->CFR, (__INTERRUPT__)) 207 208 /** 209 * @brief Check whether the selected WWDG interrupt has occurred or not. 210 * @param __HANDLE__ WWDG handle 211 * @param __INTERRUPT__ specifies the it to check. 212 * This parameter can be one of the following values: 213 * @arg WWDG_FLAG_EWIF: Early wakeup interrupt IT 214 * @retval The new state of WWDG_FLAG (SET or RESET). 215 */ 216 #define __HAL_WWDG_GET_IT(__HANDLE__, __INTERRUPT__) __HAL_WWDG_GET_FLAG((__HANDLE__),(__INTERRUPT__)) 217 218 /** @brief Clear the WWDG interrupt pending bits. 219 * bits to clear the selected interrupt pending bits. 220 * @param __HANDLE__ WWDG handle 221 * @param __INTERRUPT__ specifies the interrupt pending bit to clear. 222 * This parameter can be one of the following values: 223 * @arg WWDG_FLAG_EWIF: Early wakeup interrupt flag 224 */ 225 #define __HAL_WWDG_CLEAR_IT(__HANDLE__, __INTERRUPT__) __HAL_WWDG_CLEAR_FLAG((__HANDLE__), (__INTERRUPT__)) 226 227 /** 228 * @brief Check whether the specified WWDG flag is set or not. 229 * @param __HANDLE__ WWDG handle 230 * @param __FLAG__ specifies the flag to check. 231 * This parameter can be one of the following values: 232 * @arg WWDG_FLAG_EWIF: Early wakeup interrupt flag 233 * @retval The new state of WWDG_FLAG (SET or RESET). 234 */ 235 #define __HAL_WWDG_GET_FLAG(__HANDLE__, __FLAG__) (((__HANDLE__)->Instance->SR & (__FLAG__)) == (__FLAG__)) 236 237 /** 238 * @brief Clear the WWDG's pending flags. 239 * @param __HANDLE__ WWDG handle 240 * @param __FLAG__ specifies the flag to clear. 241 * This parameter can be one of the following values: 242 * @arg WWDG_FLAG_EWIF: Early wakeup interrupt flag 243 * @retval None 244 */ 245 #define __HAL_WWDG_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->SR = ~(__FLAG__)) 246 247 /** @brief Check whether the specified WWDG interrupt source is enabled or not. 248 * @param __HANDLE__ WWDG Handle. 249 * @param __INTERRUPT__ specifies the WWDG interrupt source to check. 250 * This parameter can be one of the following values: 251 * @arg WWDG_IT_EWI: Early Wakeup Interrupt 252 * @retval state of __INTERRUPT__ (TRUE or FALSE). 253 */ 254 #define __HAL_WWDG_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) (((__HANDLE__)->Instance->CFR & (__INTERRUPT__)) == (__INTERRUPT__)) 255 256 /** 257 * @} 258 */ 259 260 /* Exported functions --------------------------------------------------------*/ 261 262 /** @addtogroup WWDG_Exported_Functions 263 * @{ 264 */ 265 266 /** @addtogroup WWDG_Exported_Functions_Group1 267 * @{ 268 */ 269 /* Initialization/de-initialization functions **********************************/ 270 HAL_StatusTypeDef HAL_WWDG_Init(WWDG_HandleTypeDef *hwwdg); 271 void HAL_WWDG_MspInit(WWDG_HandleTypeDef *hwwdg); 272 /* Callbacks Register/UnRegister functions ***********************************/ 273 #if (USE_HAL_WWDG_REGISTER_CALLBACKS == 1) 274 HAL_StatusTypeDef HAL_WWDG_RegisterCallback(WWDG_HandleTypeDef *hwwdg, HAL_WWDG_CallbackIDTypeDef CallbackID, pWWDG_CallbackTypeDef pCallback); 275 HAL_StatusTypeDef HAL_WWDG_UnRegisterCallback(WWDG_HandleTypeDef *hwwdg, HAL_WWDG_CallbackIDTypeDef CallbackID); 276 #endif 277 278 /** 279 * @} 280 */ 281 282 /** @addtogroup WWDG_Exported_Functions_Group2 283 * @{ 284 */ 285 /* I/O operation functions ******************************************************/ 286 HAL_StatusTypeDef HAL_WWDG_Refresh(WWDG_HandleTypeDef *hwwdg); 287 void HAL_WWDG_IRQHandler(WWDG_HandleTypeDef *hwwdg); 288 void HAL_WWDG_EarlyWakeupCallback(WWDG_HandleTypeDef *hwwdg); 289 /** 290 * @} 291 */ 292 293 /** 294 * @} 295 */ 296 297 /** 298 * @} 299 */ 300 301 /** 302 * @} 303 */ 304 305 #ifdef __cplusplus 306 } 307 #endif 308 309 #endif /* __STM32L4xx_HAL_WWDG_H */ 310 311 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 312