STM32L486xx HAL User Manual
|
00001 /** 00002 ****************************************************************************** 00003 * @file stm32l4xx_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) 2017 STMicroelectronics</center></h2> 00010 * 00011 * Redistribution and use in source and binary forms, with or without modification, 00012 * are permitted provided that the following conditions are met: 00013 * 1. Redistributions of source code must retain the above copyright notice, 00014 * this list of conditions and the following disclaimer. 00015 * 2. Redistributions in binary form must reproduce the above copyright notice, 00016 * this list of conditions and the following disclaimer in the documentation 00017 * and/or other materials provided with the distribution. 00018 * 3. Neither the name of STMicroelectronics nor the names of its contributors 00019 * may be used to endorse or promote products derived from this software 00020 * without specific prior written permission. 00021 * 00022 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00023 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00024 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 00025 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 00026 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 00027 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 00028 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 00029 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 00030 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 00031 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00032 * 00033 ****************************************************************************** 00034 */ 00035 00036 /* Define to prevent recursive inclusion -------------------------------------*/ 00037 #ifndef __STM32L4xx_HAL_WWDG_H 00038 #define __STM32L4xx_HAL_WWDG_H 00039 00040 #ifdef __cplusplus 00041 extern "C" { 00042 #endif 00043 00044 /* Includes ------------------------------------------------------------------*/ 00045 #include "stm32l4xx_hal_def.h" 00046 00047 /** @addtogroup STM32L4xx_HAL_Driver 00048 * @{ 00049 */ 00050 00051 /** @addtogroup WWDG 00052 * @{ 00053 */ 00054 00055 /* Exported types ------------------------------------------------------------*/ 00056 00057 /** @defgroup WWDG_Exported_Types WWDG Exported Types 00058 * @{ 00059 */ 00060 00061 /** 00062 * @brief WWDG Init structure definition 00063 */ 00064 typedef struct 00065 { 00066 uint32_t Prescaler; /*!< Specifies the prescaler value of the WWDG. 00067 This parameter can be a value of @ref WWDG_Prescaler */ 00068 00069 uint32_t Window; /*!< Specifies the WWDG window value to be compared to the downcounter. 00070 This parameter must be a number Min_Data = 0x40 and Max_Data = 0x7F */ 00071 00072 uint32_t Counter; /*!< Specifies the WWDG free-running downcounter value. 00073 This parameter must be a number between Min_Data = 0x40 and Max_Data = 0x7F */ 00074 00075 uint32_t EWIMode ; /*!< Specifies if WWDG Early Wakeup Interupt is enable or not. 00076 This parameter can be a value of @ref WWDG_EWI_Mode */ 00077 00078 } WWDG_InitTypeDef; 00079 00080 /** 00081 * @brief WWDG handle Structure definition 00082 */ 00083 typedef struct __WWDG_HandleTypeDef 00084 { 00085 WWDG_TypeDef *Instance; /*!< Register base address */ 00086 00087 WWDG_InitTypeDef Init; /*!< WWDG required parameters */ 00088 00089 #if (USE_HAL_WWDG_REGISTER_CALLBACKS == 1) 00090 void (* EwiCallback)(struct __WWDG_HandleTypeDef *hwwdg); /*!< WWDG Early WakeUp Interrupt callback */ 00091 00092 void (* MspInitCallback)(struct __WWDG_HandleTypeDef *hwwdg); /*!< WWDG Msp Init callback */ 00093 #endif 00094 } WWDG_HandleTypeDef; 00095 00096 #if (USE_HAL_WWDG_REGISTER_CALLBACKS == 1) 00097 /** 00098 * @brief HAL WWDG common Callback ID enumeration definition 00099 */ 00100 typedef enum 00101 { 00102 HAL_WWDG_EWI_CB_ID = 0x00u, /*!< WWDG EWI callback ID */ 00103 HAL_WWDG_MSPINIT_CB_ID = 0x01u, /*!< WWDG MspInit callback ID */ 00104 }HAL_WWDG_CallbackIDTypeDef; 00105 00106 /** 00107 * @brief HAL WWDG Callback pointer definition 00108 */ 00109 typedef void (*pWWDG_CallbackTypeDef)(WWDG_HandleTypeDef * hppp); /*!< pointer to a WWDG common callback functions */ 00110 00111 #endif 00112 /** 00113 * @} 00114 */ 00115 00116 /* Exported constants --------------------------------------------------------*/ 00117 00118 /** @defgroup WWDG_Exported_Constants WWDG Exported Constants 00119 * @{ 00120 */ 00121 00122 /** @defgroup WWDG_Interrupt_definition WWDG Interrupt definition 00123 * @{ 00124 */ 00125 #define WWDG_IT_EWI WWDG_CFR_EWI /*!< Early wakeup interrupt */ 00126 /** 00127 * @} 00128 */ 00129 00130 /** @defgroup WWDG_Flag_definition WWDG Flag definition 00131 * @brief WWDG Flag definition 00132 * @{ 00133 */ 00134 #define WWDG_FLAG_EWIF WWDG_SR_EWIF /*!< Early wakeup interrupt flag */ 00135 /** 00136 * @} 00137 */ 00138 00139 /** @defgroup WWDG_Prescaler WWDG Prescaler 00140 * @{ 00141 */ 00142 #define WWDG_PRESCALER_1 0x00000000u /*!< WWDG counter clock = (PCLK1/4096)/1 */ 00143 #define WWDG_PRESCALER_2 WWDG_CFR_WDGTB_0 /*!< WWDG counter clock = (PCLK1/4096)/2 */ 00144 #define WWDG_PRESCALER_4 WWDG_CFR_WDGTB_1 /*!< WWDG counter clock = (PCLK1/4096)/4 */ 00145 #define WWDG_PRESCALER_8 (WWDG_CFR_WDGTB_1 | WWDG_CFR_WDGTB_0) /*!< WWDG counter clock = (PCLK1/4096)/8 */ 00146 /** 00147 * @} 00148 */ 00149 00150 /** @defgroup WWDG_EWI_Mode WWDG Early Wakeup Interrupt Mode 00151 * @{ 00152 */ 00153 #define WWDG_EWI_DISABLE 0x00000000u /*!< EWI Disable */ 00154 #define WWDG_EWI_ENABLE WWDG_CFR_EWI /*!< EWI Enable */ 00155 /** 00156 * @} 00157 */ 00158 00159 /** 00160 * @} 00161 */ 00162 00163 /* Private macros ------------------------------------------------------------*/ 00164 00165 /** @defgroup WWDG_Private_Macros WWDG Private Macros 00166 * @{ 00167 */ 00168 #define IS_WWDG_PRESCALER(__PRESCALER__) (((__PRESCALER__) == WWDG_PRESCALER_1) || \ 00169 ((__PRESCALER__) == WWDG_PRESCALER_2) || \ 00170 ((__PRESCALER__) == WWDG_PRESCALER_4) || \ 00171 ((__PRESCALER__) == WWDG_PRESCALER_8)) 00172 00173 #define IS_WWDG_WINDOW(__WINDOW__) (((__WINDOW__) >= WWDG_CFR_W_6) && ((__WINDOW__) <= WWDG_CFR_W)) 00174 00175 #define IS_WWDG_COUNTER(__COUNTER__) (((__COUNTER__) >= WWDG_CR_T_6) && ((__COUNTER__) <= WWDG_CR_T)) 00176 00177 #define IS_WWDG_EWI_MODE(__MODE__) (((__MODE__) == WWDG_EWI_ENABLE) || \ 00178 ((__MODE__) == WWDG_EWI_DISABLE)) 00179 /** 00180 * @} 00181 */ 00182 00183 00184 /* Exported macros ------------------------------------------------------------*/ 00185 00186 /** @defgroup WWDG_Exported_Macros WWDG Exported Macros 00187 * @{ 00188 */ 00189 00190 /** 00191 * @brief Enable the WWDG peripheral. 00192 * @param __HANDLE__ WWDG handle 00193 * @retval None 00194 */ 00195 #define __HAL_WWDG_ENABLE(__HANDLE__) SET_BIT((__HANDLE__)->Instance->CR, WWDG_CR_WDGA) 00196 00197 /** 00198 * @brief Enable the WWDG early wakeup interrupt. 00199 * @param __HANDLE__: WWDG handle 00200 * @param __INTERRUPT__ specifies the interrupt to enable. 00201 * This parameter can be one of the following values: 00202 * @arg WWDG_IT_EWI: Early wakeup interrupt 00203 * @note Once enabled this interrupt cannot be disabled except by a system reset. 00204 * @retval None 00205 */ 00206 #define __HAL_WWDG_ENABLE_IT(__HANDLE__, __INTERRUPT__) SET_BIT((__HANDLE__)->Instance->CFR, (__INTERRUPT__)) 00207 00208 /** 00209 * @brief Check whether the selected WWDG interrupt has occurred or not. 00210 * @param __HANDLE__ WWDG handle 00211 * @param __INTERRUPT__ specifies the it to check. 00212 * This parameter can be one of the following values: 00213 * @arg WWDG_FLAG_EWIF: Early wakeup interrupt IT 00214 * @retval The new state of WWDG_FLAG (SET or RESET). 00215 */ 00216 #define __HAL_WWDG_GET_IT(__HANDLE__, __INTERRUPT__) __HAL_WWDG_GET_FLAG((__HANDLE__),(__INTERRUPT__)) 00217 00218 /** @brief Clear the WWDG interrupt pending bits. 00219 * bits to clear the selected interrupt pending bits. 00220 * @param __HANDLE__ WWDG handle 00221 * @param __INTERRUPT__ specifies the interrupt pending bit to clear. 00222 * This parameter can be one of the following values: 00223 * @arg WWDG_FLAG_EWIF: Early wakeup interrupt flag 00224 */ 00225 #define __HAL_WWDG_CLEAR_IT(__HANDLE__, __INTERRUPT__) __HAL_WWDG_CLEAR_FLAG((__HANDLE__), (__INTERRUPT__)) 00226 00227 /** 00228 * @brief Check whether the specified WWDG flag is set or not. 00229 * @param __HANDLE__ WWDG handle 00230 * @param __FLAG__ specifies the flag to check. 00231 * This parameter can be one of the following values: 00232 * @arg WWDG_FLAG_EWIF: Early wakeup interrupt flag 00233 * @retval The new state of WWDG_FLAG (SET or RESET). 00234 */ 00235 #define __HAL_WWDG_GET_FLAG(__HANDLE__, __FLAG__) (((__HANDLE__)->Instance->SR & (__FLAG__)) == (__FLAG__)) 00236 00237 /** 00238 * @brief Clear the WWDG's pending flags. 00239 * @param __HANDLE__ WWDG handle 00240 * @param __FLAG__ specifies the flag to clear. 00241 * This parameter can be one of the following values: 00242 * @arg WWDG_FLAG_EWIF: Early wakeup interrupt flag 00243 * @retval None 00244 */ 00245 #define __HAL_WWDG_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->SR = ~(__FLAG__)) 00246 00247 /** @brief Check whether the specified WWDG interrupt source is enabled or not. 00248 * @param __HANDLE__ WWDG Handle. 00249 * @param __INTERRUPT__ specifies the WWDG interrupt source to check. 00250 * This parameter can be one of the following values: 00251 * @arg WWDG_IT_EWI: Early Wakeup Interrupt 00252 * @retval state of __INTERRUPT__ (TRUE or FALSE). 00253 */ 00254 #define __HAL_WWDG_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) (((__HANDLE__)->Instance->CFR & (__INTERRUPT__)) == (__INTERRUPT__)) 00255 00256 /** 00257 * @} 00258 */ 00259 00260 /* Exported functions --------------------------------------------------------*/ 00261 00262 /** @addtogroup WWDG_Exported_Functions 00263 * @{ 00264 */ 00265 00266 /** @addtogroup WWDG_Exported_Functions_Group1 00267 * @{ 00268 */ 00269 /* Initialization/de-initialization functions **********************************/ 00270 HAL_StatusTypeDef HAL_WWDG_Init(WWDG_HandleTypeDef *hwwdg); 00271 void HAL_WWDG_MspInit(WWDG_HandleTypeDef *hwwdg); 00272 /* Callbacks Register/UnRegister functions ***********************************/ 00273 #if (USE_HAL_WWDG_REGISTER_CALLBACKS == 1) 00274 HAL_StatusTypeDef HAL_WWDG_RegisterCallback(WWDG_HandleTypeDef *hwwdg, HAL_WWDG_CallbackIDTypeDef CallbackID, pWWDG_CallbackTypeDef pCallback); 00275 HAL_StatusTypeDef HAL_WWDG_UnRegisterCallback(WWDG_HandleTypeDef *hwwdg, HAL_WWDG_CallbackIDTypeDef CallbackID); 00276 #endif 00277 00278 /** 00279 * @} 00280 */ 00281 00282 /** @addtogroup WWDG_Exported_Functions_Group2 00283 * @{ 00284 */ 00285 /* I/O operation functions ******************************************************/ 00286 HAL_StatusTypeDef HAL_WWDG_Refresh(WWDG_HandleTypeDef *hwwdg); 00287 void HAL_WWDG_IRQHandler(WWDG_HandleTypeDef *hwwdg); 00288 void HAL_WWDG_EarlyWakeupCallback(WWDG_HandleTypeDef *hwwdg); 00289 /** 00290 * @} 00291 */ 00292 00293 /** 00294 * @} 00295 */ 00296 00297 /** 00298 * @} 00299 */ 00300 00301 /** 00302 * @} 00303 */ 00304 00305 #ifdef __cplusplus 00306 } 00307 #endif 00308 00309 #endif /* __STM32L4xx_HAL_WWDG_H */ 00310 00311 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/