stm32f4xx_hal_wwdg.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301
  1. /**
  2. ******************************************************************************
  3. * @file stm32f4xx_hal_wwdg.h
  4. * @author MCD Application Team
  5. * @brief Header file of WWDG HAL module.
  6. ******************************************************************************
  7. * @attention
  8. *
  9. * <h2><center>&copy; Copyright (c) 2016 STMicroelectronics.
  10. * All rights reserved.</center></h2>
  11. *
  12. * This software component is licensed by ST under BSD 3-Clause license,
  13. * the "License"; You may not use this file except in compliance with the
  14. * License. You may obtain a copy of the License at:
  15. * opensource.org/licenses/BSD-3-Clause
  16. *
  17. ******************************************************************************
  18. */
  19. /* Define to prevent recursive inclusion -------------------------------------*/
  20. #ifndef STM32F4xx_HAL_WWDG_H
  21. #define STM32F4xx_HAL_WWDG_H
  22. #ifdef __cplusplus
  23. extern "C" {
  24. #endif
  25. /* Includes ------------------------------------------------------------------*/
  26. #include "stm32f4xx_hal_def.h"
  27. /** @addtogroup STM32F4xx_HAL_Driver
  28. * @{
  29. */
  30. /** @addtogroup WWDG
  31. * @{
  32. */
  33. /* Exported types ------------------------------------------------------------*/
  34. /** @defgroup WWDG_Exported_Types WWDG Exported Types
  35. * @{
  36. */
  37. /**
  38. * @brief WWDG Init structure definition
  39. */
  40. typedef struct
  41. {
  42. uint32_t Prescaler; /*!< Specifies the prescaler value of the WWDG.
  43. This parameter can be a value of @ref WWDG_Prescaler */
  44. uint32_t Window; /*!< Specifies the WWDG window value to be compared to the downcounter.
  45. This parameter must be a number Min_Data = 0x40 and Max_Data = 0x7F */
  46. uint32_t Counter; /*!< Specifies the WWDG free-running downcounter value.
  47. This parameter must be a number between Min_Data = 0x40 and Max_Data = 0x7F */
  48. uint32_t EWIMode ; /*!< Specifies if WWDG Early Wakeup Interrupt is enable or not.
  49. This parameter can be a value of @ref WWDG_EWI_Mode */
  50. } WWDG_InitTypeDef;
  51. /**
  52. * @brief WWDG handle Structure definition
  53. */
  54. #if (USE_HAL_WWDG_REGISTER_CALLBACKS == 1)
  55. typedef struct __WWDG_HandleTypeDef
  56. #else
  57. typedef struct
  58. #endif /* USE_HAL_WWDG_REGISTER_CALLBACKS */
  59. {
  60. WWDG_TypeDef *Instance; /*!< Register base address */
  61. WWDG_InitTypeDef Init; /*!< WWDG required parameters */
  62. #if (USE_HAL_WWDG_REGISTER_CALLBACKS == 1)
  63. void (* EwiCallback)(struct __WWDG_HandleTypeDef *hwwdg); /*!< WWDG Early WakeUp Interrupt callback */
  64. void (* MspInitCallback)(struct __WWDG_HandleTypeDef *hwwdg); /*!< WWDG Msp Init callback */
  65. #endif /* USE_HAL_WWDG_REGISTER_CALLBACKS */
  66. } WWDG_HandleTypeDef;
  67. #if (USE_HAL_WWDG_REGISTER_CALLBACKS == 1)
  68. /**
  69. * @brief HAL WWDG common Callback ID enumeration definition
  70. */
  71. typedef enum
  72. {
  73. HAL_WWDG_EWI_CB_ID = 0x00U, /*!< WWDG EWI callback ID */
  74. HAL_WWDG_MSPINIT_CB_ID = 0x01U, /*!< WWDG MspInit callback ID */
  75. } HAL_WWDG_CallbackIDTypeDef;
  76. /**
  77. * @brief HAL WWDG Callback pointer definition
  78. */
  79. typedef void (*pWWDG_CallbackTypeDef)(WWDG_HandleTypeDef *hppp); /*!< pointer to a WWDG common callback functions */
  80. #endif /* USE_HAL_WWDG_REGISTER_CALLBACKS */
  81. /**
  82. * @}
  83. */
  84. /* Exported constants --------------------------------------------------------*/
  85. /** @defgroup WWDG_Exported_Constants WWDG Exported Constants
  86. * @{
  87. */
  88. /** @defgroup WWDG_Interrupt_definition WWDG Interrupt definition
  89. * @{
  90. */
  91. #define WWDG_IT_EWI WWDG_CFR_EWI /*!< Early wakeup interrupt */
  92. /**
  93. * @}
  94. */
  95. /** @defgroup WWDG_Flag_definition WWDG Flag definition
  96. * @brief WWDG Flag definition
  97. * @{
  98. */
  99. #define WWDG_FLAG_EWIF WWDG_SR_EWIF /*!< Early wakeup interrupt flag */
  100. /**
  101. * @}
  102. */
  103. /** @defgroup WWDG_Prescaler WWDG Prescaler
  104. * @{
  105. */
  106. #define WWDG_PRESCALER_1 0x00000000u /*!< WWDG counter clock = (PCLK1/4096)/1 */
  107. #define WWDG_PRESCALER_2 WWDG_CFR_WDGTB_0 /*!< WWDG counter clock = (PCLK1/4096)/2 */
  108. #define WWDG_PRESCALER_4 WWDG_CFR_WDGTB_1 /*!< WWDG counter clock = (PCLK1/4096)/4 */
  109. #define WWDG_PRESCALER_8 (WWDG_CFR_WDGTB_1 | WWDG_CFR_WDGTB_0) /*!< WWDG counter clock = (PCLK1/4096)/8 */
  110. /**
  111. * @}
  112. */
  113. /** @defgroup WWDG_EWI_Mode WWDG Early Wakeup Interrupt Mode
  114. * @{
  115. */
  116. #define WWDG_EWI_DISABLE 0x00000000u /*!< EWI Disable */
  117. #define WWDG_EWI_ENABLE WWDG_CFR_EWI /*!< EWI Enable */
  118. /**
  119. * @}
  120. */
  121. /**
  122. * @}
  123. */
  124. /* Private macros ------------------------------------------------------------*/
  125. /** @defgroup WWDG_Private_Macros WWDG Private Macros
  126. * @{
  127. */
  128. #define IS_WWDG_PRESCALER(__PRESCALER__) (((__PRESCALER__) == WWDG_PRESCALER_1) || \
  129. ((__PRESCALER__) == WWDG_PRESCALER_2) || \
  130. ((__PRESCALER__) == WWDG_PRESCALER_4) || \
  131. ((__PRESCALER__) == WWDG_PRESCALER_8))
  132. #define IS_WWDG_WINDOW(__WINDOW__) (((__WINDOW__) >= WWDG_CFR_W_6) && ((__WINDOW__) <= WWDG_CFR_W))
  133. #define IS_WWDG_COUNTER(__COUNTER__) (((__COUNTER__) >= WWDG_CR_T_6) && ((__COUNTER__) <= WWDG_CR_T))
  134. #define IS_WWDG_EWI_MODE(__MODE__) (((__MODE__) == WWDG_EWI_ENABLE) || \
  135. ((__MODE__) == WWDG_EWI_DISABLE))
  136. /**
  137. * @}
  138. */
  139. /* Exported macros ------------------------------------------------------------*/
  140. /** @defgroup WWDG_Exported_Macros WWDG Exported Macros
  141. * @{
  142. */
  143. /**
  144. * @brief Enable the WWDG peripheral.
  145. * @param __HANDLE__ WWDG handle
  146. * @retval None
  147. */
  148. #define __HAL_WWDG_ENABLE(__HANDLE__) SET_BIT((__HANDLE__)->Instance->CR, WWDG_CR_WDGA)
  149. /**
  150. * @brief Enable the WWDG early wakeup interrupt.
  151. * @param __HANDLE__: WWDG handle
  152. * @param __INTERRUPT__ specifies the interrupt to enable.
  153. * This parameter can be one of the following values:
  154. * @arg WWDG_IT_EWI: Early wakeup interrupt
  155. * @note Once enabled this interrupt cannot be disabled except by a system reset.
  156. * @retval None
  157. */
  158. #define __HAL_WWDG_ENABLE_IT(__HANDLE__, __INTERRUPT__) SET_BIT((__HANDLE__)->Instance->CFR, (__INTERRUPT__))
  159. /**
  160. * @brief Check whether the selected WWDG interrupt has occurred or not.
  161. * @param __HANDLE__ WWDG handle
  162. * @param __INTERRUPT__ specifies the it to check.
  163. * This parameter can be one of the following values:
  164. * @arg WWDG_FLAG_EWIF: Early wakeup interrupt IT
  165. * @retval The new state of WWDG_FLAG (SET or RESET).
  166. */
  167. #define __HAL_WWDG_GET_IT(__HANDLE__, __INTERRUPT__) __HAL_WWDG_GET_FLAG((__HANDLE__),(__INTERRUPT__))
  168. /** @brief Clear the WWDG interrupt pending bits.
  169. * bits to clear the selected interrupt pending bits.
  170. * @param __HANDLE__ WWDG handle
  171. * @param __INTERRUPT__ specifies the interrupt pending bit to clear.
  172. * This parameter can be one of the following values:
  173. * @arg WWDG_FLAG_EWIF: Early wakeup interrupt flag
  174. */
  175. #define __HAL_WWDG_CLEAR_IT(__HANDLE__, __INTERRUPT__) __HAL_WWDG_CLEAR_FLAG((__HANDLE__), (__INTERRUPT__))
  176. /**
  177. * @brief Check whether the specified WWDG flag is set or not.
  178. * @param __HANDLE__ WWDG handle
  179. * @param __FLAG__ specifies the flag to check.
  180. * This parameter can be one of the following values:
  181. * @arg WWDG_FLAG_EWIF: Early wakeup interrupt flag
  182. * @retval The new state of WWDG_FLAG (SET or RESET).
  183. */
  184. #define __HAL_WWDG_GET_FLAG(__HANDLE__, __FLAG__) (((__HANDLE__)->Instance->SR & (__FLAG__)) == (__FLAG__))
  185. /**
  186. * @brief Clear the WWDG's pending flags.
  187. * @param __HANDLE__ WWDG handle
  188. * @param __FLAG__ specifies the flag to clear.
  189. * This parameter can be one of the following values:
  190. * @arg WWDG_FLAG_EWIF: Early wakeup interrupt flag
  191. * @retval None
  192. */
  193. #define __HAL_WWDG_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->SR = ~(__FLAG__))
  194. /** @brief Check whether the specified WWDG interrupt source is enabled or not.
  195. * @param __HANDLE__ WWDG Handle.
  196. * @param __INTERRUPT__ specifies the WWDG interrupt source to check.
  197. * This parameter can be one of the following values:
  198. * @arg WWDG_IT_EWI: Early Wakeup Interrupt
  199. * @retval state of __INTERRUPT__ (TRUE or FALSE).
  200. */
  201. #define __HAL_WWDG_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) (((__HANDLE__)->Instance->CFR\
  202. & (__INTERRUPT__)) == (__INTERRUPT__))
  203. /**
  204. * @}
  205. */
  206. /* Exported functions --------------------------------------------------------*/
  207. /** @addtogroup WWDG_Exported_Functions
  208. * @{
  209. */
  210. /** @addtogroup WWDG_Exported_Functions_Group1
  211. * @{
  212. */
  213. /* Initialization/de-initialization functions **********************************/
  214. HAL_StatusTypeDef HAL_WWDG_Init(WWDG_HandleTypeDef *hwwdg);
  215. void HAL_WWDG_MspInit(WWDG_HandleTypeDef *hwwdg);
  216. /* Callbacks Register/UnRegister functions ***********************************/
  217. #if (USE_HAL_WWDG_REGISTER_CALLBACKS == 1)
  218. HAL_StatusTypeDef HAL_WWDG_RegisterCallback(WWDG_HandleTypeDef *hwwdg, HAL_WWDG_CallbackIDTypeDef CallbackID,
  219. pWWDG_CallbackTypeDef pCallback);
  220. HAL_StatusTypeDef HAL_WWDG_UnRegisterCallback(WWDG_HandleTypeDef *hwwdg, HAL_WWDG_CallbackIDTypeDef CallbackID);
  221. #endif /* USE_HAL_WWDG_REGISTER_CALLBACKS */
  222. /**
  223. * @}
  224. */
  225. /** @addtogroup WWDG_Exported_Functions_Group2
  226. * @{
  227. */
  228. /* I/O operation functions ******************************************************/
  229. HAL_StatusTypeDef HAL_WWDG_Refresh(WWDG_HandleTypeDef *hwwdg);
  230. void HAL_WWDG_IRQHandler(WWDG_HandleTypeDef *hwwdg);
  231. void HAL_WWDG_EarlyWakeupCallback(WWDG_HandleTypeDef *hwwdg);
  232. /**
  233. * @}
  234. */
  235. /**
  236. * @}
  237. */
  238. /**
  239. * @}
  240. */
  241. /**
  242. * @}
  243. */
  244. #ifdef __cplusplus
  245. }
  246. #endif
  247. #endif /* STM32F4xx_HAL_WWDG_H */
  248. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/