stm32l4xx_hal_wwdg.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  1. /**
  2. ******************************************************************************
  3. * @file stm32l4xx_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) 2017 STMicroelectronics</center></h2>
  10. *
  11. * Redistribution and use in source and binary forms, with or without modification,
  12. * are permitted provided that the following conditions are met:
  13. * 1. Redistributions of source code must retain the above copyright notice,
  14. * this list of conditions and the following disclaimer.
  15. * 2. Redistributions in binary form must reproduce the above copyright notice,
  16. * this list of conditions and the following disclaimer in the documentation
  17. * and/or other materials provided with the distribution.
  18. * 3. Neither the name of STMicroelectronics nor the names of its contributors
  19. * may be used to endorse or promote products derived from this software
  20. * without specific prior written permission.
  21. *
  22. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  23. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  24. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  25. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  26. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  27. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  28. * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  29. * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  30. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  31. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  32. *
  33. ******************************************************************************
  34. */
  35. /* Define to prevent recursive inclusion -------------------------------------*/
  36. #ifndef __STM32L4xx_HAL_WWDG_H
  37. #define __STM32L4xx_HAL_WWDG_H
  38. #ifdef __cplusplus
  39. extern "C" {
  40. #endif
  41. /* Includes ------------------------------------------------------------------*/
  42. #include "stm32l4xx_hal_def.h"
  43. /** @addtogroup STM32L4xx_HAL_Driver
  44. * @{
  45. */
  46. /** @addtogroup WWDG
  47. * @{
  48. */
  49. /* Exported types ------------------------------------------------------------*/
  50. /** @defgroup WWDG_Exported_Types WWDG Exported Types
  51. * @{
  52. */
  53. /**
  54. * @brief WWDG Init structure definition
  55. */
  56. typedef struct
  57. {
  58. uint32_t Prescaler; /*!< Specifies the prescaler value of the WWDG.
  59. This parameter can be a value of @ref WWDG_Prescaler */
  60. uint32_t Window; /*!< Specifies the WWDG window value to be compared to the downcounter.
  61. This parameter must be a number Min_Data = 0x40 and Max_Data = 0x7F */
  62. uint32_t Counter; /*!< Specifies the WWDG free-running downcounter value.
  63. This parameter must be a number between Min_Data = 0x40 and Max_Data = 0x7F */
  64. uint32_t EWIMode ; /*!< Specifies if WWDG Early Wakeup Interupt is enable or not.
  65. This parameter can be a value of @ref WWDG_EWI_Mode */
  66. }WWDG_InitTypeDef;
  67. /**
  68. * @brief WWDG handle Structure definition
  69. */
  70. typedef struct
  71. {
  72. WWDG_TypeDef *Instance; /*!< Register base address */
  73. WWDG_InitTypeDef Init; /*!< WWDG required parameters */
  74. }WWDG_HandleTypeDef;
  75. /**
  76. * @}
  77. */
  78. /* Exported constants --------------------------------------------------------*/
  79. /** @defgroup WWDG_Exported_Constants WWDG Exported Constants
  80. * @{
  81. */
  82. /** @defgroup WWDG_Interrupt_definition WWDG Interrupt definition
  83. * @{
  84. */
  85. #define WWDG_IT_EWI WWDG_CFR_EWI /*!< Early wakeup interrupt */
  86. /**
  87. * @}
  88. */
  89. /** @defgroup WWDG_Flag_definition WWDG Flag definition
  90. * @brief WWDG Flag definition
  91. * @{
  92. */
  93. #define WWDG_FLAG_EWIF WWDG_SR_EWIF /*!< Early wakeup interrupt flag */
  94. /**
  95. * @}
  96. */
  97. /** @defgroup WWDG_Prescaler WWDG Prescaler
  98. * @{
  99. */
  100. #define WWDG_PRESCALER_1 0x00000000u /*!< WWDG counter clock = (PCLK1/4096)/1 */
  101. #define WWDG_PRESCALER_2 WWDG_CFR_WDGTB_0 /*!< WWDG counter clock = (PCLK1/4096)/2 */
  102. #define WWDG_PRESCALER_4 WWDG_CFR_WDGTB_1 /*!< WWDG counter clock = (PCLK1/4096)/4 */
  103. #define WWDG_PRESCALER_8 WWDG_CFR_WDGTB /*!< WWDG counter clock = (PCLK1/4096)/8 */
  104. /**
  105. * @}
  106. */
  107. /** @defgroup WWDG_EWI_Mode WWDG Early Wakeup Interrupt Mode
  108. * @{
  109. */
  110. #define WWDG_EWI_DISABLE 0x00000000u /*!< EWI Disable */
  111. #define WWDG_EWI_ENABLE WWDG_CFR_EWI /*!< EWI Enable */
  112. /**
  113. * @}
  114. */
  115. /**
  116. * @}
  117. */
  118. /* Private macros ------------------------------------------------------------*/
  119. /** @defgroup WWDG_Private_Macros WWDG Private Macros
  120. * @{
  121. */
  122. #define IS_WWDG_PRESCALER(__PRESCALER__) (((__PRESCALER__) == WWDG_PRESCALER_1) || \
  123. ((__PRESCALER__) == WWDG_PRESCALER_2) || \
  124. ((__PRESCALER__) == WWDG_PRESCALER_4) || \
  125. ((__PRESCALER__) == WWDG_PRESCALER_8))
  126. #define IS_WWDG_WINDOW(__WINDOW__) (((__WINDOW__) >= WWDG_CFR_W_6) && ((__WINDOW__) <= WWDG_CFR_W))
  127. #define IS_WWDG_COUNTER(__COUNTER__) (((__COUNTER__) >= WWDG_CR_T_6) && ((__COUNTER__) <= WWDG_CR_T))
  128. #define IS_WWDG_EWI_MODE(__MODE__) (((__MODE__) == WWDG_EWI_ENABLE) || \
  129. ((__MODE__) == WWDG_EWI_DISABLE))
  130. /**
  131. * @}
  132. */
  133. /* Exported macros ------------------------------------------------------------*/
  134. /** @defgroup WWDG_Exported_Macros WWDG Exported Macros
  135. * @{
  136. */
  137. /**
  138. * @brief Enable the WWDG peripheral.
  139. * @param __HANDLE__ WWDG handle
  140. * @retval None
  141. */
  142. #define __HAL_WWDG_ENABLE(__HANDLE__) SET_BIT((__HANDLE__)->Instance->CR, WWDG_CR_WDGA)
  143. /**
  144. * @brief Enable the WWDG early wakeup interrupt.
  145. * @param __HANDLE__: WWDG handle
  146. * @param __INTERRUPT__ specifies the interrupt to enable.
  147. * This parameter can be one of the following values:
  148. * @arg WWDG_IT_EWI: Early wakeup interrupt
  149. * @note Once enabled this interrupt cannot be disabled except by a system reset.
  150. * @retval None
  151. */
  152. #define __HAL_WWDG_ENABLE_IT(__HANDLE__, __INTERRUPT__) SET_BIT((__HANDLE__)->Instance->CFR, (__INTERRUPT__))
  153. /**
  154. * @brief Check whether the selected WWDG interrupt has occurred or not.
  155. * @param __HANDLE__ WWDG handle
  156. * @param __INTERRUPT__ specifies the it to check.
  157. * This parameter can be one of the following values:
  158. * @arg WWDG_FLAG_EWIF: Early wakeup interrupt IT
  159. * @retval The new state of WWDG_FLAG (SET or RESET).
  160. */
  161. #define __HAL_WWDG_GET_IT(__HANDLE__, __INTERRUPT__) __HAL_WWDG_GET_FLAG((__HANDLE__),(__INTERRUPT__))
  162. /** @brief Clear the WWDG interrupt pending bits.
  163. * bits to clear the selected interrupt pending bits.
  164. * @param __HANDLE__ WWDG handle
  165. * @param __INTERRUPT__ specifies the interrupt pending bit to clear.
  166. * This parameter can be one of the following values:
  167. * @arg WWDG_FLAG_EWIF: Early wakeup interrupt flag
  168. */
  169. #define __HAL_WWDG_CLEAR_IT(__HANDLE__, __INTERRUPT__) __HAL_WWDG_CLEAR_FLAG((__HANDLE__), (__INTERRUPT__))
  170. /**
  171. * @brief Check whether the specified WWDG flag is set or not.
  172. * @param __HANDLE__ WWDG handle
  173. * @param __FLAG__ specifies the flag to check.
  174. * This parameter can be one of the following values:
  175. * @arg WWDG_FLAG_EWIF: Early wakeup interrupt flag
  176. * @retval The new state of WWDG_FLAG (SET or RESET).
  177. */
  178. #define __HAL_WWDG_GET_FLAG(__HANDLE__, __FLAG__) (((__HANDLE__)->Instance->SR & (__FLAG__)) == (__FLAG__))
  179. /**
  180. * @brief Clear the WWDG's pending flags.
  181. * @param __HANDLE__ WWDG handle
  182. * @param __FLAG__ specifies the flag to clear.
  183. * This parameter can be one of the following values:
  184. * @arg WWDG_FLAG_EWIF: Early wakeup interrupt flag
  185. * @retval None
  186. */
  187. #define __HAL_WWDG_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->SR = ~(__FLAG__))
  188. /** @brief Check whether the specified WWDG interrupt source is enabled or not.
  189. * @param __HANDLE__ WWDG Handle.
  190. * @param __INTERRUPT__ specifies the WWDG interrupt source to check.
  191. * This parameter can be one of the following values:
  192. * @arg WWDG_IT_EWI: Early Wakeup Interrupt
  193. * @retval state of __INTERRUPT__ (TRUE or FALSE).
  194. */
  195. #define __HAL_WWDG_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) (((__HANDLE__)->Instance->CFR & (__INTERRUPT__)) == (__INTERRUPT__))
  196. /**
  197. * @}
  198. */
  199. /* Exported functions --------------------------------------------------------*/
  200. /** @addtogroup WWDG_Exported_Functions
  201. * @{
  202. */
  203. /** @addtogroup WWDG_Exported_Functions_Group1
  204. * @{
  205. */
  206. /* Initialization/de-initialization functions **********************************/
  207. HAL_StatusTypeDef HAL_WWDG_Init(WWDG_HandleTypeDef *hwwdg);
  208. void HAL_WWDG_MspInit(WWDG_HandleTypeDef *hwwdg);
  209. /**
  210. * @}
  211. */
  212. /** @addtogroup WWDG_Exported_Functions_Group2
  213. * @{
  214. */
  215. /* I/O operation functions ******************************************************/
  216. HAL_StatusTypeDef HAL_WWDG_Refresh(WWDG_HandleTypeDef *hwwdg);
  217. void HAL_WWDG_IRQHandler(WWDG_HandleTypeDef *hwwdg);
  218. void HAL_WWDG_EarlyWakeupCallback(WWDG_HandleTypeDef* hwwdg);
  219. /**
  220. * @}
  221. */
  222. /**
  223. * @}
  224. */
  225. /**
  226. * @}
  227. */
  228. /**
  229. * @}
  230. */
  231. #ifdef __cplusplus
  232. }
  233. #endif
  234. #endif /* __STM32L4xx_HAL_WWDG_H */
  235. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/