stm32f1xx_hal_wwdg.h 9.9 KB

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