STM32F479xx HAL User Manual
|
00001 /** 00002 ****************************************************************************** 00003 * @file stm32f4xx_hal_wwdg.h 00004 * @author MCD Application Team 00005 * @brief Header file of WWDG HAL module. 00006 ****************************************************************************** 00007 * @attention 00008 * 00009 * <h2><center>© Copyright (c) 2016 STMicroelectronics. 00010 * All rights reserved.</center></h2> 00011 * 00012 * This software component is licensed by ST under BSD 3-Clause license, 00013 * the "License"; You may not use this file except in compliance with the 00014 * License. You may obtain a copy of the License at: 00015 * opensource.org/licenses/BSD-3-Clause 00016 * 00017 ****************************************************************************** 00018 */ 00019 00020 /* Define to prevent recursive inclusion -------------------------------------*/ 00021 #ifndef STM32F4xx_HAL_WWDG_H 00022 #define STM32F4xx_HAL_WWDG_H 00023 00024 #ifdef __cplusplus 00025 extern "C" { 00026 #endif 00027 00028 /* Includes ------------------------------------------------------------------*/ 00029 #include "stm32f4xx_hal_def.h" 00030 00031 /** @addtogroup STM32F4xx_HAL_Driver 00032 * @{ 00033 */ 00034 00035 /** @addtogroup WWDG 00036 * @{ 00037 */ 00038 00039 /* Exported types ------------------------------------------------------------*/ 00040 00041 /** @defgroup WWDG_Exported_Types WWDG Exported Types 00042 * @{ 00043 */ 00044 00045 /** 00046 * @brief WWDG Init structure definition 00047 */ 00048 typedef struct 00049 { 00050 uint32_t Prescaler; /*!< Specifies the prescaler value of the WWDG. 00051 This parameter can be a value of @ref WWDG_Prescaler */ 00052 00053 uint32_t Window; /*!< Specifies the WWDG window value to be compared to the downcounter. 00054 This parameter must be a number Min_Data = 0x40 and Max_Data = 0x7F */ 00055 00056 uint32_t Counter; /*!< Specifies the WWDG free-running downcounter value. 00057 This parameter must be a number between Min_Data = 0x40 and Max_Data = 0x7F */ 00058 00059 uint32_t EWIMode ; /*!< Specifies if WWDG Early Wakeup Interrupt is enable or not. 00060 This parameter can be a value of @ref WWDG_EWI_Mode */ 00061 00062 } WWDG_InitTypeDef; 00063 00064 /** 00065 * @brief WWDG handle Structure definition 00066 */ 00067 #if (USE_HAL_WWDG_REGISTER_CALLBACKS == 1) 00068 typedef struct __WWDG_HandleTypeDef 00069 #else 00070 typedef struct 00071 #endif /* USE_HAL_WWDG_REGISTER_CALLBACKS */ 00072 { 00073 WWDG_TypeDef *Instance; /*!< Register base address */ 00074 00075 WWDG_InitTypeDef Init; /*!< WWDG required parameters */ 00076 00077 #if (USE_HAL_WWDG_REGISTER_CALLBACKS == 1) 00078 void (* EwiCallback)(struct __WWDG_HandleTypeDef *hwwdg); /*!< WWDG Early WakeUp Interrupt callback */ 00079 00080 void (* MspInitCallback)(struct __WWDG_HandleTypeDef *hwwdg); /*!< WWDG Msp Init callback */ 00081 #endif /* USE_HAL_WWDG_REGISTER_CALLBACKS */ 00082 } WWDG_HandleTypeDef; 00083 00084 #if (USE_HAL_WWDG_REGISTER_CALLBACKS == 1) 00085 /** 00086 * @brief HAL WWDG common Callback ID enumeration definition 00087 */ 00088 typedef enum 00089 { 00090 HAL_WWDG_EWI_CB_ID = 0x00U, /*!< WWDG EWI callback ID */ 00091 HAL_WWDG_MSPINIT_CB_ID = 0x01U, /*!< WWDG MspInit callback ID */ 00092 } HAL_WWDG_CallbackIDTypeDef; 00093 00094 /** 00095 * @brief HAL WWDG Callback pointer definition 00096 */ 00097 typedef void (*pWWDG_CallbackTypeDef)(WWDG_HandleTypeDef *hppp); /*!< pointer to a WWDG common callback functions */ 00098 00099 #endif /* USE_HAL_WWDG_REGISTER_CALLBACKS */ 00100 /** 00101 * @} 00102 */ 00103 00104 /* Exported constants --------------------------------------------------------*/ 00105 00106 /** @defgroup WWDG_Exported_Constants WWDG Exported Constants 00107 * @{ 00108 */ 00109 00110 /** @defgroup WWDG_Interrupt_definition WWDG Interrupt definition 00111 * @{ 00112 */ 00113 #define WWDG_IT_EWI WWDG_CFR_EWI /*!< Early wakeup interrupt */ 00114 /** 00115 * @} 00116 */ 00117 00118 /** @defgroup WWDG_Flag_definition WWDG Flag definition 00119 * @brief WWDG Flag definition 00120 * @{ 00121 */ 00122 #define WWDG_FLAG_EWIF WWDG_SR_EWIF /*!< Early wakeup interrupt flag */ 00123 /** 00124 * @} 00125 */ 00126 00127 /** @defgroup WWDG_Prescaler WWDG Prescaler 00128 * @{ 00129 */ 00130 #define WWDG_PRESCALER_1 0x00000000u /*!< WWDG counter clock = (PCLK1/4096)/1 */ 00131 #define WWDG_PRESCALER_2 WWDG_CFR_WDGTB_0 /*!< WWDG counter clock = (PCLK1/4096)/2 */ 00132 #define WWDG_PRESCALER_4 WWDG_CFR_WDGTB_1 /*!< WWDG counter clock = (PCLK1/4096)/4 */ 00133 #define WWDG_PRESCALER_8 (WWDG_CFR_WDGTB_1 | WWDG_CFR_WDGTB_0) /*!< WWDG counter clock = (PCLK1/4096)/8 */ 00134 /** 00135 * @} 00136 */ 00137 00138 /** @defgroup WWDG_EWI_Mode WWDG Early Wakeup Interrupt Mode 00139 * @{ 00140 */ 00141 #define WWDG_EWI_DISABLE 0x00000000u /*!< EWI Disable */ 00142 #define WWDG_EWI_ENABLE WWDG_CFR_EWI /*!< EWI Enable */ 00143 /** 00144 * @} 00145 */ 00146 00147 /** 00148 * @} 00149 */ 00150 00151 /* Private macros ------------------------------------------------------------*/ 00152 00153 /** @defgroup WWDG_Private_Macros WWDG Private Macros 00154 * @{ 00155 */ 00156 #define IS_WWDG_PRESCALER(__PRESCALER__) (((__PRESCALER__) == WWDG_PRESCALER_1) || \ 00157 ((__PRESCALER__) == WWDG_PRESCALER_2) || \ 00158 ((__PRESCALER__) == WWDG_PRESCALER_4) || \ 00159 ((__PRESCALER__) == WWDG_PRESCALER_8)) 00160 00161 #define IS_WWDG_WINDOW(__WINDOW__) (((__WINDOW__) >= WWDG_CFR_W_6) && ((__WINDOW__) <= WWDG_CFR_W)) 00162 00163 #define IS_WWDG_COUNTER(__COUNTER__) (((__COUNTER__) >= WWDG_CR_T_6) && ((__COUNTER__) <= WWDG_CR_T)) 00164 00165 #define IS_WWDG_EWI_MODE(__MODE__) (((__MODE__) == WWDG_EWI_ENABLE) || \ 00166 ((__MODE__) == WWDG_EWI_DISABLE)) 00167 /** 00168 * @} 00169 */ 00170 00171 00172 /* Exported macros ------------------------------------------------------------*/ 00173 00174 /** @defgroup WWDG_Exported_Macros WWDG Exported Macros 00175 * @{ 00176 */ 00177 00178 /** 00179 * @brief Enable the WWDG peripheral. 00180 * @param __HANDLE__ WWDG handle 00181 * @retval None 00182 */ 00183 #define __HAL_WWDG_ENABLE(__HANDLE__) SET_BIT((__HANDLE__)->Instance->CR, WWDG_CR_WDGA) 00184 00185 /** 00186 * @brief Enable the WWDG early wakeup interrupt. 00187 * @param __HANDLE__: WWDG handle 00188 * @param __INTERRUPT__ specifies the interrupt to enable. 00189 * This parameter can be one of the following values: 00190 * @arg WWDG_IT_EWI: Early wakeup interrupt 00191 * @note Once enabled this interrupt cannot be disabled except by a system reset. 00192 * @retval None 00193 */ 00194 #define __HAL_WWDG_ENABLE_IT(__HANDLE__, __INTERRUPT__) SET_BIT((__HANDLE__)->Instance->CFR, (__INTERRUPT__)) 00195 00196 /** 00197 * @brief Check whether the selected WWDG interrupt has occurred or not. 00198 * @param __HANDLE__ WWDG handle 00199 * @param __INTERRUPT__ specifies the it to check. 00200 * This parameter can be one of the following values: 00201 * @arg WWDG_FLAG_EWIF: Early wakeup interrupt IT 00202 * @retval The new state of WWDG_FLAG (SET or RESET). 00203 */ 00204 #define __HAL_WWDG_GET_IT(__HANDLE__, __INTERRUPT__) __HAL_WWDG_GET_FLAG((__HANDLE__),(__INTERRUPT__)) 00205 00206 /** @brief Clear the WWDG interrupt pending bits. 00207 * bits to clear the selected interrupt pending bits. 00208 * @param __HANDLE__ WWDG handle 00209 * @param __INTERRUPT__ specifies the interrupt pending bit to clear. 00210 * This parameter can be one of the following values: 00211 * @arg WWDG_FLAG_EWIF: Early wakeup interrupt flag 00212 */ 00213 #define __HAL_WWDG_CLEAR_IT(__HANDLE__, __INTERRUPT__) __HAL_WWDG_CLEAR_FLAG((__HANDLE__), (__INTERRUPT__)) 00214 00215 /** 00216 * @brief Check whether the specified WWDG flag is set or not. 00217 * @param __HANDLE__ WWDG handle 00218 * @param __FLAG__ specifies the flag to check. 00219 * This parameter can be one of the following values: 00220 * @arg WWDG_FLAG_EWIF: Early wakeup interrupt flag 00221 * @retval The new state of WWDG_FLAG (SET or RESET). 00222 */ 00223 #define __HAL_WWDG_GET_FLAG(__HANDLE__, __FLAG__) (((__HANDLE__)->Instance->SR & (__FLAG__)) == (__FLAG__)) 00224 00225 /** 00226 * @brief Clear the WWDG's pending flags. 00227 * @param __HANDLE__ WWDG handle 00228 * @param __FLAG__ specifies the flag to clear. 00229 * This parameter can be one of the following values: 00230 * @arg WWDG_FLAG_EWIF: Early wakeup interrupt flag 00231 * @retval None 00232 */ 00233 #define __HAL_WWDG_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->SR = ~(__FLAG__)) 00234 00235 /** @brief Check whether the specified WWDG interrupt source is enabled or not. 00236 * @param __HANDLE__ WWDG Handle. 00237 * @param __INTERRUPT__ specifies the WWDG interrupt source to check. 00238 * This parameter can be one of the following values: 00239 * @arg WWDG_IT_EWI: Early Wakeup Interrupt 00240 * @retval state of __INTERRUPT__ (TRUE or FALSE). 00241 */ 00242 #define __HAL_WWDG_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) (((__HANDLE__)->Instance->CFR\ 00243 & (__INTERRUPT__)) == (__INTERRUPT__)) 00244 00245 /** 00246 * @} 00247 */ 00248 00249 /* Exported functions --------------------------------------------------------*/ 00250 00251 /** @addtogroup WWDG_Exported_Functions 00252 * @{ 00253 */ 00254 00255 /** @addtogroup WWDG_Exported_Functions_Group1 00256 * @{ 00257 */ 00258 /* Initialization/de-initialization functions **********************************/ 00259 HAL_StatusTypeDef HAL_WWDG_Init(WWDG_HandleTypeDef *hwwdg); 00260 void HAL_WWDG_MspInit(WWDG_HandleTypeDef *hwwdg); 00261 /* Callbacks Register/UnRegister functions ***********************************/ 00262 #if (USE_HAL_WWDG_REGISTER_CALLBACKS == 1) 00263 HAL_StatusTypeDef HAL_WWDG_RegisterCallback(WWDG_HandleTypeDef *hwwdg, HAL_WWDG_CallbackIDTypeDef CallbackID, 00264 pWWDG_CallbackTypeDef pCallback); 00265 HAL_StatusTypeDef HAL_WWDG_UnRegisterCallback(WWDG_HandleTypeDef *hwwdg, HAL_WWDG_CallbackIDTypeDef CallbackID); 00266 #endif /* USE_HAL_WWDG_REGISTER_CALLBACKS */ 00267 00268 /** 00269 * @} 00270 */ 00271 00272 /** @addtogroup WWDG_Exported_Functions_Group2 00273 * @{ 00274 */ 00275 /* I/O operation functions ******************************************************/ 00276 HAL_StatusTypeDef HAL_WWDG_Refresh(WWDG_HandleTypeDef *hwwdg); 00277 void HAL_WWDG_IRQHandler(WWDG_HandleTypeDef *hwwdg); 00278 void HAL_WWDG_EarlyWakeupCallback(WWDG_HandleTypeDef *hwwdg); 00279 /** 00280 * @} 00281 */ 00282 00283 /** 00284 * @} 00285 */ 00286 00287 /** 00288 * @} 00289 */ 00290 00291 /** 00292 * @} 00293 */ 00294 00295 #ifdef __cplusplus 00296 } 00297 #endif 00298 00299 #endif /* STM32F4xx_HAL_WWDG_H */ 00300 00301 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/