tae32f53xx_ll_iwdg.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321
  1. /**
  2. ******************************************************************************
  3. * @file tae32f53xx_ll_iwdg.h
  4. * @author MCD Application Team
  5. * @brief Header file of IWDG 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_IWDG_H_
  22. #define _TAE32F53XX_LL_IWDG_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 IWDG_LL
  32. * @{
  33. */
  34. /* Exported types ------------------------------------------------------------*/
  35. /** @defgroup IWDG_LL_Exported_Types IWDG LL Exported Types
  36. * @brief IWDG LL Exported Types
  37. * @{
  38. */
  39. /**
  40. * @brief IWDG Prescaler enumeration
  41. */
  42. typedef enum {
  43. IWDG_PRESCALER_4 = IWDG_PSCR_PSC_0, /*!< IWDG prescaler set to 4 */
  44. IWDG_PRESCALER_8 = IWDG_PSCR_PSC_1, /*!< IWDG prescaler set to 8 */
  45. IWDG_PRESCALER_16 = IWDG_PSCR_PSC_2, /*!< IWDG prescaler set to 16 */
  46. IWDG_PRESCALER_32 = IWDG_PSCR_PSC_3, /*!< IWDG prescaler set to 32 */
  47. IWDG_PRESCALER_64 = IWDG_PSCR_PSC_4, /*!< IWDG prescaler set to 64 */
  48. IWDG_PRESCALER_128 = IWDG_PSCR_PSC_5, /*!< IWDG prescaler set to 128 */
  49. IWDG_PRESCALER_256 = IWDG_PSCR_PSC_6, /*!< IWDG prescaler set to 256 */
  50. IWDG_PRESCALER_512 = IWDG_PSCR_PSC_7, /*!< IWDG prescaler set to 512 */
  51. } IWDG_PreScalerETypeDef;
  52. /**
  53. @brief IWDG Mode enumeration
  54. */
  55. typedef enum {
  56. IWDG_MODE_RESET = IWDG_CR_MODE_RESET, /*!< IWDG Reset after timeout */
  57. IWDG_MODE_INTERRUPT = IWDG_CR_MODE_INTERRUPT, /*!< IWDG Trigger a interrupt after timeout */
  58. } IWDG_ModeETypeDef;
  59. /**
  60. * @brief IWDG Init structure definition
  61. */
  62. typedef struct __IWDG_InitTypeDef {
  63. IWDG_PreScalerETypeDef Prescaler; /*!< Select the prescaler of the IWDG. */
  64. uint32_t Reload_val; /*!< Specifies the IWDG down-counter reload value.
  65. This parameter must be a number between Min_Data = 0 and Max_Data = 0x0FFF */
  66. IWDG_ModeETypeDef Mode; /*!< Specifies the IWDG bahavior after timeout.*/
  67. } IWDG_InitTypeDef;
  68. /**
  69. * @}
  70. */
  71. /* Exported constants --------------------------------------------------------*/
  72. /** @defgroup IWDG_LL_Exported_Constants IWDG LL Exported Constants
  73. * @brief IWDG LL Exported Constants
  74. * @{
  75. */
  76. /** @defgroup IWDG_Interrupt_definition IWDG interrupt Definition
  77. * @{
  78. */
  79. #define IWDG_IT_TOIE IWDG_CR_TOIE /*!< IWDG Timeout Interrupte Enable */
  80. /**
  81. * @}
  82. */
  83. /** @defgroup IWDG_Flag_definition IWDG Flag Definition
  84. * @{
  85. */
  86. #define IWDG_FLAG_PSCUPD IWDG_SR_PSCUPD /*!< IWDG Prescaler Update flag */
  87. #define IWDG_FLAG_RLVUPD IWDG_SR_RLVUPD /*!< IWDG Reload Value Update flag */
  88. #define IWDG_FLAG_TOIF IWDG_SR_TOIF /*!< IWDG Timeout Interrupt flag */
  89. /**
  90. * @}
  91. */
  92. /** @defgroup IWDG_Key_definition IWDG Key Definition
  93. * @{
  94. */
  95. #define IWDG_KEY_RELOAD 0x0000AAAAU /*!< IWDG Reload Counter Enable */
  96. #define IWDG_KEY_ENABLE 0x0000CCCCU /*!< IWDG Peripheral Enable */
  97. #define IWDG_KEY_DISABLE 0x0000DDDDU /*!< IWDG Peripheral Disable */
  98. #define IWDG_KEY_WRITE_ACCESS_ENABLE 0x00005003U /*!< IWDG Write Access Enable */
  99. #define IWDG_KEY_WRITE_ACCESS_DISABLE 0x00000000U /*!< IWDG Write Access Disable */
  100. /**
  101. * @}
  102. */
  103. /**
  104. * @}
  105. */
  106. /* Exported macro ------------------------------------------------------------*/
  107. /** @defgroup IWDG_LL_Exported_Macros IWDG LL Exported Macros
  108. * @brief IWDG LL Exported Constants
  109. * @{
  110. */
  111. /**
  112. * @brief Enable write access to IWDG_PSCR, IWDG_RLR and IWDG_CR registers.
  113. * @param __INSTANCE__ IWDG peripheral
  114. * @return None
  115. */
  116. #define __LL_IWDG_ENABLE_WRITE_ACCESS(__INSTANCE__) WRITE_REG((__INSTANCE__)->KEYR, IWDG_KEY_WRITE_ACCESS_ENABLE)
  117. /**
  118. * @brief Disable write access to IWDG_PSCR, IWDG_RLR and IWDG_CR registers.
  119. * @param __INSTANCE__ IWDG peripheral
  120. * @return None
  121. */
  122. #define __LL_IWDG_DISABLE_WRITE_ACCESS(__INSTANCE__) WRITE_REG((__INSTANCE__)->KEYR, IWDG_KEY_WRITE_ACCESS_DISABLE)
  123. /**
  124. * @brief Enable the IWDG peripheral.
  125. * @param __INSTANCE__ IWDG peripheral
  126. * @return None
  127. */
  128. #define __LL_IWDG_START(__INSTANCE__) WRITE_REG((__INSTANCE__)->KEYR, IWDG_KEY_ENABLE)
  129. /**
  130. * @brief Disable the IWDG peripheral.
  131. * @param __INSTANCE__ IWDG peripheral
  132. * @return None
  133. */
  134. #define __LL_IWDG_STOP(__INSTANCE__) WRITE_REG((__INSTANCE__)->KEYR, IWDG_KEY_DISABLE)
  135. /** @brief Enable the specified IWDG interrupt.
  136. * @note __LL_IWDG_ENABLE_WRITE_ACCESS() must be called to enable write access before enable
  137. * the IWDG interrupt.
  138. * @param __INSTANCE__ IWDG peripheral
  139. * @param __INTERRUPT__ specifies the IWDG interrupt source to enable.
  140. * This parameter can be one of the following values:
  141. * @arg IWDG_IT_TOIE: Timeout interrupt flag
  142. * @retrun None
  143. */
  144. #define __LL_IWDG_ENABLE_IT(__INSTANCE__, __INTERRUPT__) SET_BIT((__INSTANCE__)->CR, (__INTERRUPT__))
  145. /** @brief Disable the specified TIM interrupt.
  146. * @note __LL_IWDG_ENABLE_WRITE_ACCESS() must be called to enable write access before disable
  147. * the IWDG interrupt.
  148. * @param __INSTANCE__ IWDG peripheral
  149. * @param __INTERRUPT__ specifies the IWDG interrupt source to enable.
  150. * This parameter can be one of the following values:
  151. * @arg IWDG_IT_TOIE: Timeout interrupt flag
  152. * @retval None
  153. */
  154. #define __LL_IWDG_DISABLE_IT(__INSTANCE__, __INTERRUPT__) CLEAR_BIT((__INSTANCE__)->CR, (__INTERRUPT__))
  155. /** @brief Check whether the specified IWDG status or interrupt flag is set or not.
  156. * @param __INSTANCE__ IWDG peripheral
  157. * @param __FLAG__ specifies the IWDG flag to check.
  158. * This parameter can be one of the following values:
  159. * @arg IWDG_FLAG_PSCUPD: Prescaler value update flag
  160. * @arg IWDG_FLAG_RLVUPD: Reload value update flag
  161. * @arg IWDG_FLAG_TOIF: Timeout interrupt flag
  162. * @return The new state of __FLAG__ (SET or RESET).
  163. */
  164. #define __LL_IWDG_GET_FLAG(__INSTANCE__, __FLAG__) \
  165. ((READ_BIT((__INSTANCE__)->SR, (__FLAG__)) == (__FLAG__)) ? SET : RESET)
  166. /**
  167. * @brief Clear the specified IWDG status or interrupt flag.
  168. * @param __INSTANCE__ IWDG peripheral
  169. * @param __FLAG__ specifies the IWDG flag to clear.
  170. * This parameter can be one of the following values:
  171. * @arg IWDG_FLAG_TOIF: Timeout interrupt flag
  172. * @return None
  173. */
  174. #define __LL_IWDG_CLEAR_FLAG(__INSTANCE__, __FLAG__) WRITE_REG((__INSTANCE__)->SR, (__FLAG__))
  175. /**
  176. * @brief Check whether the specified IWDG interrupt source is enabled or not.
  177. * @param __INSTANCE__ IWDG peripheral
  178. * @param __INTERRUPT__ specifies the IWDG interrupt source to check.
  179. * This parameter can be one of the following values:
  180. * @arg IWDG_IT_TOIE: Timeout interrupt
  181. * @return The state of __INTERRUPT__ (SET or RESET).
  182. */
  183. #define __LL_IWDG_IT_CHECK_SOURCE(__INSTANCE__, __INTERRUPT__) \
  184. ((READ_BIT((__INSTANCE__)->CR, (__INTERRUPT__)) == (__INTERRUPT__)) ? SET : RESET)
  185. /**
  186. * @brief Reload IWDG counter with value defined in the reload register
  187. * (write access to IWDG_PR & IWDG_RLR registers disabled).
  188. * @note Flag RLVUPD and PSCUPD must be 0 before refreshing IWDG counter.
  189. * @param __INSTANCE__ IWDG peripheral
  190. * @return None
  191. */
  192. #define __LL_IWDG_RELOAD_COUNTER(__INSTANCE__) WRITE_REG((__INSTANCE__)->KEYR, IWDG_KEY_RELOAD)
  193. /**
  194. * @}
  195. */
  196. /* Exported functions --------------------------------------------------------*/
  197. /** @addtogroup IWDG_LL_Exported_Functions
  198. * @{
  199. */
  200. /** @addtogroup IWDG_LL_Exported_Functions_Group1
  201. * @{
  202. */
  203. LL_StatusETypeDef LL_IWDG_Init(IWDG_TypeDef *Instance, IWDG_InitTypeDef *Init);
  204. LL_StatusETypeDef LL_IWDG_DeInit(IWDG_TypeDef *Instance);
  205. void LL_IWDG_MspInit(IWDG_TypeDef *Instance);
  206. void LL_IWDG_MspDeInit(IWDG_TypeDef *Instance);
  207. /**
  208. * @}
  209. */
  210. /** @addtogroup IWDG_LL_Exported_Functions_Group2
  211. * @{
  212. */
  213. LL_StatusETypeDef LL_IWDG_Refresh(IWDG_TypeDef *Instance);
  214. /**
  215. * @}
  216. */
  217. /** @addtogroup IWDG_LL_Exported_Functions_Interrupt
  218. * @{
  219. */
  220. void LL_IWDG_IRQHandler(IWDG_TypeDef *Instance);
  221. void LL_IWDG_TimeOutCallBack(IWDG_TypeDef *Instance);
  222. /**
  223. * @}
  224. */
  225. /**
  226. * @}
  227. */
  228. /* Private types -------------------------------------------------------------*/
  229. /* Private variables ---------------------------------------------------------*/
  230. /* Private constants ---------------------------------------------------------*/
  231. /* Private macros ------------------------------------------------------------*/
  232. /** @defgroup IWDG_LL_Private_Macros IWDG LL Private Macros
  233. * @brief IWDG LL Private Macros
  234. * @{
  235. */
  236. /**
  237. * @brief Check IWDG prescaler value.
  238. * @param __PRESCALER__ IWDG prescaler value
  239. * @return None
  240. */
  241. /**
  242. * @brief Check IWDG reload value.
  243. * @param __RELOAD__ IWDG reload value
  244. * @return None
  245. */
  246. #define IS_IWDG_RELOAD_Val(__RELOAD__) ((__RELOAD__) <= IWDG_RLR_RLV)
  247. /**
  248. * @}
  249. */
  250. /* Private functions ---------------------------------------------------------*/
  251. /**
  252. * @}
  253. */
  254. /**
  255. * @}
  256. */
  257. #ifdef __cplusplus
  258. }
  259. #endif /* __cplusplus */
  260. #endif /* _TAE32F53XX_LL_IWDG_H_ */
  261. /************************* (C) COPYRIGHT Tai-Action *****END OF FILE***********/