1
0

stm32l0xx_hal_wwdg.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348
  1. /**
  2. ******************************************************************************
  3. * @file stm32l0xx_hal_wwdg.h
  4. * @author MCD Application Team
  5. * @version V1.7.0
  6. * @date 31-May-2016
  7. * @brief Header file of WWDG HAL module.
  8. ******************************************************************************
  9. * @attention
  10. *
  11. * <h2><center>&copy; COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
  12. *
  13. * Redistribution and use in source and binary forms, with or without modification,
  14. * are permitted provided that the following conditions are met:
  15. * 1. Redistributions of source code must retain the above copyright notice,
  16. * this list of conditions and the following disclaimer.
  17. * 2. Redistributions in binary form must reproduce the above copyright notice,
  18. * this list of conditions and the following disclaimer in the documentation
  19. * and/or other materials provided with the distribution.
  20. * 3. Neither the name of STMicroelectronics nor the names of its contributors
  21. * may be used to endorse or promote products derived from this software
  22. * without specific prior written permission.
  23. *
  24. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  25. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  26. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  27. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  28. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  29. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  30. * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  31. * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  32. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  33. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  34. *
  35. ******************************************************************************
  36. */
  37. /* Define to prevent recursive inclusion -------------------------------------*/
  38. #ifndef __STM32L0xx_HAL_WWDG_H
  39. #define __STM32L0xx_HAL_WWDG_H
  40. #ifdef __cplusplus
  41. extern "C" {
  42. #endif
  43. /* Includes ------------------------------------------------------------------*/
  44. #include "stm32l0xx_hal_def.h"
  45. /** @addtogroup STM32L0xx_HAL_Driver
  46. * @{
  47. */
  48. /** @defgroup WWDG WWDG (Window watchdog)
  49. * @{
  50. */
  51. /* Exported types ------------------------------------------------------------*/
  52. /** @defgroup WWDG_Exported_Types WWDG Exported Types
  53. * @{
  54. */
  55. /** @defgroup WWDG_State WWDG state definition
  56. * @{
  57. */
  58. /**
  59. * @brief WWDG HAL State Structure definition
  60. */
  61. typedef enum
  62. {
  63. HAL_WWDG_STATE_RESET = 0x00U, /*!< WWDG not yet initialized or disabled */
  64. HAL_WWDG_STATE_READY = 0x01U, /*!< WWDG initialized and ready for use */
  65. HAL_WWDG_STATE_BUSY = 0x02U, /*!< WWDG internal process is ongoing */
  66. HAL_WWDG_STATE_TIMEOUT = 0x03U, /*!< WWDG timeout state */
  67. HAL_WWDG_STATE_ERROR = 0x04U /*!< WWDG error state */
  68. }HAL_WWDG_StateTypeDef;
  69. /**
  70. * @}
  71. */
  72. /** @defgroup WWDG_Init WWDG init configuration structure
  73. * @{
  74. */
  75. /**
  76. * @brief WWDG Init configuration structure
  77. */
  78. typedef struct
  79. {
  80. uint32_t Prescaler; /*!< Specifies the prescaler value of the WWDG.
  81. This parameter can be a value of @ref WWDG_Prescaler */
  82. uint32_t Window; /*!< Specifies the WWDG window value to be compared to the downcounter.
  83. This parameter must be a number lower than Max_Data = 0x80 */
  84. uint32_t Counter; /*!< Specifies the WWDG free-running downcounter value.
  85. This parameter must be a number between Min_Data = 0x40 and Max_Data = 0x7F */
  86. }WWDG_InitTypeDef;
  87. /**
  88. * @}
  89. */
  90. /** @defgroup WWDG_handle WWDG handler
  91. * @{
  92. */
  93. /**
  94. * @brief WWDG handle Structure definition
  95. */
  96. typedef struct
  97. {
  98. WWDG_TypeDef *Instance; /*!< Register base address */
  99. WWDG_InitTypeDef Init; /*!< WWDG required parameters */
  100. HAL_LockTypeDef Lock; /*!< WWDG locking object */
  101. __IO HAL_WWDG_StateTypeDef State; /*!< WWDG communication state */
  102. }WWDG_HandleTypeDef;
  103. /**
  104. * @}
  105. */
  106. /**
  107. * @}
  108. */
  109. /* Exported constants --------------------------------------------------------*/
  110. /** @defgroup WWDG_Exported_Constants WWDG Exported Constants
  111. * @{
  112. */
  113. /** @defgroup WWDG_BitAddress_AliasRegion WWDG BitAddress AliasRegion
  114. * @brief WWDG registers bit address in the alias region
  115. * @{
  116. */
  117. /* --- CFR Register ---*/
  118. /* Alias word address of EWI bit */
  119. #define WWDG_CFR_BASE (uint32_t)(WWDG_BASE + 0x04U)
  120. /**
  121. * @}
  122. */
  123. /** @defgroup WWDG_Interrupt_definition WWDG Interrupt definition
  124. * @{
  125. */
  126. #define WWDG_IT_EWI ((uint32_t)WWDG_CFR_EWI)
  127. /**
  128. * @}
  129. */
  130. /** @defgroup WWDG_Flag_definition WWDG Flag definition
  131. * @brief WWDG Flag definition
  132. * @{
  133. */
  134. #define WWDG_FLAG_EWIF ((uint32_t)WWDG_SR_EWIF) /*!< Early wakeup interrupt flag */
  135. /**
  136. * @}
  137. */
  138. /** @defgroup WWDG_Prescaler WWDG Prescaler
  139. * @{
  140. */
  141. #define WWDG_PRESCALER_1 ((uint32_t)0x00000000U) /*!< WWDG counter clock = (PCLK1/4096)/1 */
  142. #define WWDG_PRESCALER_2 ((uint32_t)WWDG_CFR_WDGTB0) /*!< WWDG counter clock = (PCLK1/4096)/2 */
  143. #define WWDG_PRESCALER_4 ((uint32_t)WWDG_CFR_WDGTB1) /*!< WWDG counter clock = (PCLK1/4096)/4 */
  144. #define WWDG_PRESCALER_8 ((uint32_t)WWDG_CFR_WDGTB) /*!< WWDG counter clock = (PCLK1/4096)/8 */
  145. /**
  146. * @}
  147. */
  148. #define IS_WWDG_PRESCALER(__PRESCALER__) (((__PRESCALER__) == WWDG_PRESCALER_1) || \
  149. ((__PRESCALER__) == WWDG_PRESCALER_2) || \
  150. ((__PRESCALER__) == WWDG_PRESCALER_4) || \
  151. ((__PRESCALER__) == WWDG_PRESCALER_8))
  152. /* Check for window */
  153. #define IS_WWDG_WINDOW(__WINDOW__) ((__WINDOW__) <= 0x7FU)
  154. /* Check for counter */
  155. #define IS_WWDG_COUNTER(__COUNTER__) (((__COUNTER__) >= 0x40U) && ((__COUNTER__) <= 0x7FU))
  156. /**
  157. * @}
  158. */
  159. /* Exported macro ------------------------------------------------------------*/
  160. /** @defgroup WWDG_Exported_Macros WWDG Exported Macros
  161. * @{
  162. */
  163. /** @brief Reset WWDG handle state
  164. * @param __HANDLE__: WWDG handle
  165. * @retval None
  166. */
  167. #define __HAL_WWDG_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_WWDG_STATE_RESET)
  168. /**
  169. * @brief Enables the WWDG peripheral.
  170. * @param __HANDLE__: WWDG handle
  171. * @retval None
  172. */
  173. #define __HAL_WWDG_ENABLE(__HANDLE__) SET_BIT((__HANDLE__)->Instance->CR, WWDG_CR_WDGA)
  174. /**
  175. * @brief Disables the WWDG peripheral.
  176. * @param __HANDLE__: WWDG handle
  177. * @note WARNING: This is a dummy macro for HAL code alignment.
  178. * Once enable, WWDG Peripheral cannot be disabled except by a system reset.
  179. * @retval None
  180. */
  181. #define __HAL_WWDG_DISABLE(__HANDLE__) /* dummy macro */
  182. /**
  183. * @brief Enables the WWDG early wakeup interrupt.
  184. * @param __HANDLE__: WWDG handle
  185. * @param __INTERRUPT__: specifies the interrupt to enable.
  186. * This parameter can be one of the following values:
  187. * @arg WWDG_IT_EWI: Early wakeup interrupt
  188. * @note Once enabled this interrupt cannot be disabled except by a system reset.
  189. * @retval None
  190. */
  191. #define __HAL_WWDG_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CFR |= (__INTERRUPT__))
  192. /**
  193. * @brief Disables the WWDG early wakeup interrupt.
  194. * @param __HANDLE__: WWDG handle:
  195. * @param __INTERRUPT__: specifies the interrupt to disable.
  196. * @arg WWDG_IT_EWI: Early wakeup interrupt
  197. * @note WARNING: This is a dummy macro for HAL code alignment.
  198. * Once enabled this interrupt cannot be disabled except by a system reset.
  199. * @retval None
  200. */
  201. #define __HAL_WWDG_DISABLE_IT(__HANDLE__, __INTERRUPT__) /* dummy macro */
  202. /**
  203. * @brief Gets the selected WWDG's it status.
  204. * @param __HANDLE__: WWDG handle
  205. * @param __INTERRUPT__: specifies the it to check.
  206. * This parameter can be one of the following values:
  207. * @arg WWDG_FLAG_EWIF: Early wakeup interrupt IT
  208. * @retval The new state of WWDG_FLAG (SET or RESET).
  209. */
  210. #define __HAL_WWDG_GET_IT(__HANDLE__, __INTERRUPT__) (((__HANDLE__)->Instance->SR & (__INTERRUPT__)) == (__INTERRUPT__))
  211. /** @brief Clear the WWDG's interrupt pending bits
  212. * bits to clear the selected interrupt pending bits.
  213. * @param __HANDLE__: WWDG handle
  214. * @param __INTERRUPT__: specifies the interrupt pending bit to clear.
  215. * This parameter can be one of the following values:
  216. * @arg WWDG_FLAG_EWIF: Early wakeup interrupt flag
  217. */
  218. #define __HAL_WWDG_CLEAR_IT(__HANDLE__, __INTERRUPT__) __HAL_WWDG_CLEAR_FLAG((__HANDLE__), (__INTERRUPT__))
  219. /**
  220. * @brief Gets the selected WWDG's flag status.
  221. * @param __HANDLE__: WWDG handle
  222. * @param __FLAG__: specifies the flag to check.
  223. * This parameter can be one of the following values:
  224. * @arg WWDG_FLAG_EWIF: Early wakeup interrupt flag
  225. * @retval The new state of WWDG_FLAG (SET or RESET).
  226. */
  227. #define __HAL_WWDG_GET_FLAG(__HANDLE__, __FLAG__) (((__HANDLE__)->Instance->SR & (__FLAG__)) == (__FLAG__))
  228. /**
  229. * @brief Clears the WWDG's pending flags.
  230. * @param __HANDLE__: WWDG handle
  231. * @param __FLAG__: specifies the flag to clear.
  232. * This parameter can be one of the following values:
  233. * @arg WWDG_FLAG_EWIF: Early wakeup interrupt flag
  234. * @retval None
  235. */
  236. #define __HAL_WWDG_CLEAR_FLAG(__HANDLE__, __FLAG__) (((__HANDLE__)->Instance->SR) = ~(__FLAG__))
  237. /** @brief Checks if the specified WWDG interrupt source is enabled or disabled.
  238. * @param __HANDLE__: WWDG Handle.
  239. * @param __INTERRUPT__: specifies the WWDG interrupt source to check.
  240. * This parameter can be one of the following values:
  241. * @arg WWDG_IT_EWI: Early Wakeup Interrupt
  242. * @retval state of __INTERRUPT__ (TRUE or FALSE).
  243. */
  244. #define __HAL_WWDG_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) (((__HANDLE__)->Instance->CFR & (__INTERRUPT__)) == (__INTERRUPT__))
  245. /**
  246. * @}
  247. */
  248. /** @defgroup WWDG_Exported_Functions WWDG Exported Functions
  249. * @{
  250. */
  251. /** @defgroup WWDG_Exported_Functions_Group1 Initialization and de-initialization functions
  252. * @{
  253. */
  254. HAL_StatusTypeDef HAL_WWDG_Init(WWDG_HandleTypeDef *hwwdg);
  255. HAL_StatusTypeDef HAL_WWDG_DeInit(WWDG_HandleTypeDef *hwwdg);
  256. void HAL_WWDG_MspInit(WWDG_HandleTypeDef *hwwdg);
  257. void HAL_WWDG_MspDeInit(WWDG_HandleTypeDef *hwwdg);
  258. void HAL_WWDG_WakeupCallback(WWDG_HandleTypeDef* hwwdg);
  259. /**
  260. * @}
  261. */
  262. /** @defgroup WWDG_Exported_Functions_Group2 IO operation functions
  263. * @{
  264. */
  265. HAL_StatusTypeDef HAL_WWDG_Start(WWDG_HandleTypeDef *hwwdg);
  266. HAL_StatusTypeDef HAL_WWDG_Start_IT(WWDG_HandleTypeDef *hwwdg);
  267. HAL_StatusTypeDef HAL_WWDG_Refresh(WWDG_HandleTypeDef *hwwdg, uint32_t Counter);
  268. void HAL_WWDG_IRQHandler(WWDG_HandleTypeDef *hwwdg);
  269. /**
  270. * @}
  271. */
  272. /** @defgroup WWDG_Exported_Functions_Group3 Peripheral State functions
  273. * @{
  274. */
  275. HAL_WWDG_StateTypeDef HAL_WWDG_GetState(WWDG_HandleTypeDef *hwwdg);
  276. /**
  277. * @}
  278. */
  279. /**
  280. * @}
  281. */
  282. /**
  283. * @}
  284. */
  285. /**
  286. * @}
  287. */
  288. #ifdef __cplusplus
  289. }
  290. #endif
  291. #endif /* __STM32L0xx_HAL_WWDG_H */
  292. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/