py32f0xx_hal_wwdg.h 10 KB

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