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