tae32f53xx_ll_wwdg.h 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296
  1. /**
  2. ******************************************************************************
  3. * @file tae32f53xx_ll_wwdg.h
  4. * @author MCD Application Team
  5. * @brief Header file of WWDG LL module.
  6. *
  7. ******************************************************************************
  8. * @attention
  9. *
  10. * <h2><center>&copy; Copyright (c) 2020 Tai-Action.
  11. * All rights reserved.</center></h2>
  12. *
  13. * This software is licensed by Tai-Action under BSD 3-Clause license,
  14. * the "License"; You may not use this file except in compliance with the
  15. * License. You may obtain a copy of the License at:
  16. * opensource.org/licenses/BSD-3-Clause
  17. *
  18. ******************************************************************************
  19. */
  20. /* Define to prevent recursive inclusion -------------------------------------*/
  21. #ifndef _TAE32F53XX_LL_WWDG_H_
  22. #define _TAE32F53XX_LL_WWDG_H_
  23. #ifdef __cplusplus
  24. extern "C" {
  25. #endif /* __cplusplus */
  26. /* Includes ------------------------------------------------------------------*/
  27. #include "tae32f53xx_ll_def.h"
  28. /** @addtogroup TAE32F53xx_LL_Driver
  29. * @{
  30. */
  31. /** @addtogroup WWDG_LL
  32. * @{
  33. */
  34. /* Exported types ------------------------------------------------------------*/
  35. /** @defgroup WWDG_LL_Exported_Types WWDG LL Exported Types
  36. * @brief WWDG LL Exported Types
  37. * @{
  38. */
  39. /**
  40. @brief WWDG Early Wakeup Interrupt Mode
  41. */
  42. typedef enum {
  43. WWDG_EWI_DISABLE = 0x00000000U, /*!< Rsest */
  44. WWDG_EWI_ENABLE = WWDG_CR_EWIE, /*!< Early Wakeup Interrupt */
  45. } WWDG_EWIETypeDef;
  46. /**
  47. * @brief WWDG Init structure definition
  48. */
  49. typedef struct __WWDG_InitTypeDef {
  50. uint32_t Prescaler; /*!< Specifies the prescaler value of the WWDG.
  51. This parameter must be a number Min_Data = 0x00 and Max_Data = 0xFFFF */
  52. uint32_t Window; /*!< Specifies the WWDG window value to be compared to the downcounter.
  53. This parameter must be a number Min_Data = 0x40 and Max_Data = 0xFFFF */
  54. uint32_t Counter; /*!< Specifies the WWDG free-running downcounter value.
  55. This parameter must be a number between Min_Data = 0x40 and Max_Data = 0xFFFF */
  56. WWDG_EWIETypeDef EWIMode; /*!< Specifies if WWDG Early Wakeup Interupt is enable or not. */
  57. } WWDG_InitTypeDef;
  58. /**
  59. * @}
  60. */
  61. /* Exported constants --------------------------------------------------------*/
  62. /** @defgroup WWDG_LL_Exported_Constants WWDG LL Exported Constants
  63. * @brief WWDG LL Exported Constants
  64. * @{
  65. */
  66. /** @defgroup WWDG_Interrupt_definition WWDG Interrupt definition
  67. * @{
  68. */
  69. #define WWDG_IT_EWIE WWDG_CR_EWIE /*!< Early wakeup interrupt */
  70. /**
  71. * @}
  72. */
  73. /** @defgroup WWDG_Flag_definition WWDG Flag definition
  74. * @brief WWDG Flag definition
  75. * @{
  76. */
  77. #define WWDG_FLAG_EWIF WWDG_ISR_EWIF /*!< Early wakeup interrupt flag */
  78. /**
  79. * @}
  80. */
  81. /**
  82. * @}
  83. */
  84. /* Exported macro ------------------------------------------------------------*/
  85. /** @defgroup WWDG_LL_Exported_Macros WWDG LL Exported Macros
  86. * @brief WWDG LL Exported Macros
  87. * @{
  88. */
  89. /**
  90. * @brief Enable the WWDG peripheral.
  91. * @param __INSTANCE__ WWDG peripheral
  92. * @retval None
  93. */
  94. #define __LL_WWDG_ENABLE(__INSTANCE__) SET_BIT((__INSTANCE__)->CR, WWDG_CR_WEN)
  95. /**
  96. * @brief Disable the WWDG peripheral.
  97. * @param __INSTANCE__ WWDG peripheral
  98. * @retval None
  99. */
  100. #define __LL_WWDG_DISABLE(__INSTANCE__) CLEAR_BIT((__INSTANCE__)->CR, WWDG_CR_WEN)
  101. /**
  102. * @brief Enable the specified WWDG interrupt.
  103. * @param __INSTANCE__ WWDG peripheral
  104. * @param __INTERRUPT__ specifies the interrupt to enable.
  105. * This parameter can be one of the following values:
  106. * @arg WWDG_IT_EWIE: Early wakeup interrupt
  107. * @retval None
  108. */
  109. #define __LL_WWDG_IT_ENABLE(__INSTANCE__, __INTERRUPT__) SET_BIT((__INSTANCE__)->CR, (__INTERRUPT__))
  110. /**
  111. * @brief Disable the specified WWDG interrupt.
  112. * @param __INSTANCE__ WWDG peripheral
  113. * @param __INTERRUPT__ specifies the interrupt to enable.
  114. * This parameter can be one of the following values:
  115. * @arg WWDG_IT_EWIE: Early wakeup interrupt
  116. * @retval None
  117. */
  118. #define __LL_WWDG_IT_DISABLE(__INSTANCE__, __INTERRUPT__) CLEAR_BIT((__INSTANCE__)->CR, (__INTERRUPT__))
  119. /**
  120. * @brief Check whether the specified WWDG flag is set or not.
  121. * @param __INSTANCE__ WWDG peripheral
  122. * @param __FLAG__ specifies the flag to check.
  123. * This parameter can be one of the following values:
  124. * @arg WWDG_FLAG_EWIF: Early wakeup interrupt flag
  125. * @retval The new state of WWDG_FLAG (SET or RESET).
  126. */
  127. #define __LL_WWDG_GET_FLAG(__INSTANCE__, __FLAG__) ((READ_BIT((__INSTANCE__)->ISR, (__FLAG__)) == (__FLAG__)) ? SET : RESET)
  128. /**
  129. * @brief Clears the WWDG's pending flags.
  130. * @param __INSTANCE__ WWDG peripheral
  131. * @param __FLAG__ specifies the flag to clear.
  132. * This parameter can be one of the following values:
  133. * @arg WWDG_FLAG_EWIF: Early wakeup interrupt flag
  134. * @retval None
  135. */
  136. #define __LL_WWDG_CLEAR_FLAG(__INSTANCE__, __FLAG__) WRITE_REG((__INSTANCE__)->ISR, (__FLAG__))
  137. /**
  138. * @brief Checks if the specified WWDG interrupt source is enabled or disabled.
  139. * @param __INSTANCE__ WWDG peripheral
  140. * @param __INTERRUPT__ specifies the WWDG interrupt source to check.
  141. * This parameter can be one of the following values:
  142. * @arg WWDG_IT_EWIE: Early Wakeup Interrupt
  143. * @retval state of __INTERRUPT__ (SET or RESET).
  144. */
  145. #define __LL_WWDG_CHECK_IT_SOURCE(__INSTANCE__, __INTERRUPT__) \
  146. ((READ_BIT((__INSTANCE__)->CR, (__INTERRUPT__)) == (__INTERRUPT__)) ? SET : RESET)
  147. /**
  148. * @brief Get the WWDG Counter Register value on runtime.
  149. * @param __INSTANCE__ WWDG peripheral
  150. * @retval 16-bit value of the WWDG counter register (WWDG_CVR)
  151. */
  152. #define __LL_WWDG_GET_COUNTER(__INSTANCE__) (READ_REG((__INSTANCE__)->CVR))
  153. /**
  154. * @brief Set the WWDG Counter Register value to refresh WWDG.
  155. * @param __INSTANCE__ WWDG peripheral
  156. * @param __COUNTER__ specifies WWDG counter value to refresh with
  157. * @retval None
  158. */
  159. #define __LL_WWDG_SET_COUNTER(__INSTANCE__, __COUNTER__) WRITE_REG((__INSTANCE__)->CVR, __COUNTER__)
  160. /**
  161. * @}
  162. */
  163. /* Exported functions --------------------------------------------------------*/
  164. /** @addtogroup WWDG_LL_Exported_Functions
  165. * @{
  166. */
  167. /** @addtogroup WWDG_LL_Exported_Functions_Group1
  168. * @{
  169. */
  170. LL_StatusETypeDef LL_WWDG_Init(WWDG_TypeDef *Instance, WWDG_InitTypeDef *Init);
  171. LL_StatusETypeDef LL_WWDG_DeInit(WWDG_TypeDef *Instance);
  172. void LL_WWDG_MspInit(WWDG_TypeDef *Instance);
  173. void LL_WWDG_MspDeInit(WWDG_TypeDef *Instance);
  174. /**
  175. * @}
  176. */
  177. /** @addtogroup WWDG_LL_Exported_Functions_Group2
  178. * @{
  179. */
  180. LL_StatusETypeDef LL_WWDG_Refresh(WWDG_TypeDef *Instance, uint16_t Counter);
  181. /**
  182. * @}
  183. */
  184. /** @addtogroup WWDG_LL_Exported_Functions_Interrupt
  185. * @{
  186. */
  187. void LL_WWDG_IRQHandler(WWDG_TypeDef *Instance);
  188. void LL_WWDG_EarlyWakeUpCallback(WWDG_TypeDef *Instance);
  189. /**
  190. * @}
  191. */
  192. /**
  193. * @}
  194. */
  195. /* Private types -------------------------------------------------------------*/
  196. /* Private variables ---------------------------------------------------------*/
  197. /* Private constants ---------------------------------------------------------*/
  198. /* Private macros ------------------------------------------------------------*/
  199. /** @defgroup WWDG_LL_Private_Macros WWDG LL Private Macros
  200. * @brief WWDG LL Private Macros
  201. * @{
  202. */
  203. /**
  204. * @brief Judge is WWDG prescaler or not
  205. * @param __PRESCALER__ prescaler to judge
  206. * @retval 0 isn't WWDG prescaler
  207. * @retval 1 is WWDG prescaler
  208. */
  209. #define IS_WWDG_PRESCALER(__PRESCALER__) ((__PRESCALER__) <= 0xFFFFUL)
  210. /**
  211. * @brief Judge is WWDG window or not
  212. * @param __WINDOW__ window to judge
  213. * @retval 0 isn't WWDG window
  214. * @retval 1 is WWDG window
  215. */
  216. #define IS_WWDG_WINDOW(__WINDOW__) ((__WINDOW__) <= 0xFFFFUL)
  217. /**
  218. * @brief Judge is WWDG counter or not
  219. * @param __COUNTER__ counter to judge
  220. * @retval 0 isn't WWDG counter
  221. * @retval 1 is WWDG counter
  222. */
  223. #define IS_WWDG_COUNTER(__COUNTER__) ((__COUNTER__) <= 0xFFFFUL)
  224. /**
  225. * @}
  226. */
  227. /* Private functions ---------------------------------------------------------*/
  228. /**
  229. * @}
  230. */
  231. /**
  232. * @}
  233. */
  234. #ifdef __cplusplus
  235. }
  236. #endif /* __cplusplus */
  237. #endif /* _TAE32F53XX_LL_WWDG_H_ */
  238. /************************* (C) COPYRIGHT Tai-Action *****END OF FILE***********/