stm32h7xx_hal_iwdg.h 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. /**
  2. ******************************************************************************
  3. * @file stm32h7xx_hal_iwdg.h
  4. * @author MCD Application Team
  5. * @brief Header file of IWDG HAL module.
  6. ******************************************************************************
  7. * @attention
  8. *
  9. * Copyright (c) 2017 STMicroelectronics.
  10. * All rights reserved.
  11. *
  12. * This software is licensed under terms that can be found in the LICENSE file
  13. * in the root directory of this software component.
  14. * If no LICENSE file comes with this software, it is provided AS-IS.
  15. *
  16. ******************************************************************************
  17. */
  18. /* Define to prevent recursive inclusion -------------------------------------*/
  19. #ifndef STM32H7xx_HAL_IWDG_H
  20. #define STM32H7xx_HAL_IWDG_H
  21. #ifdef __cplusplus
  22. extern "C" {
  23. #endif
  24. /* Includes ------------------------------------------------------------------*/
  25. #include "stm32h7xx_hal_def.h"
  26. /** @addtogroup STM32H7xx_HAL_Driver
  27. * @{
  28. */
  29. /** @defgroup IWDG IWDG
  30. * @{
  31. */
  32. /* Exported types ------------------------------------------------------------*/
  33. /** @defgroup IWDG_Exported_Types IWDG Exported Types
  34. * @{
  35. */
  36. /**
  37. * @brief IWDG Init structure definition
  38. */
  39. typedef struct
  40. {
  41. uint32_t Prescaler; /*!< Select the prescaler of the IWDG.
  42. This parameter can be a value of @ref IWDG_Prescaler */
  43. uint32_t Reload; /*!< Specifies the IWDG down-counter reload value.
  44. This parameter must be a number between Min_Data = 0 and Max_Data = 0x0FFF */
  45. uint32_t Window; /*!< Specifies the window value to be compared to the down-counter.
  46. This parameter must be a number between Min_Data = 0 and Max_Data = 0x0FFF */
  47. } IWDG_InitTypeDef;
  48. /**
  49. * @brief IWDG Handle Structure definition
  50. */
  51. typedef struct
  52. {
  53. IWDG_TypeDef *Instance; /*!< Register base address */
  54. IWDG_InitTypeDef Init; /*!< IWDG required parameters */
  55. } IWDG_HandleTypeDef;
  56. /**
  57. * @}
  58. */
  59. /* Exported constants --------------------------------------------------------*/
  60. /** @defgroup IWDG_Exported_Constants IWDG Exported Constants
  61. * @{
  62. */
  63. /** @defgroup IWDG_Prescaler IWDG Prescaler
  64. * @{
  65. */
  66. #define IWDG_PRESCALER_4 0x00000000u /*!< IWDG prescaler set to 4 */
  67. #define IWDG_PRESCALER_8 IWDG_PR_PR_0 /*!< IWDG prescaler set to 8 */
  68. #define IWDG_PRESCALER_16 IWDG_PR_PR_1 /*!< IWDG prescaler set to 16 */
  69. #define IWDG_PRESCALER_32 (IWDG_PR_PR_1 | IWDG_PR_PR_0) /*!< IWDG prescaler set to 32 */
  70. #define IWDG_PRESCALER_64 IWDG_PR_PR_2 /*!< IWDG prescaler set to 64 */
  71. #define IWDG_PRESCALER_128 (IWDG_PR_PR_2 | IWDG_PR_PR_0) /*!< IWDG prescaler set to 128 */
  72. #define IWDG_PRESCALER_256 (IWDG_PR_PR_2 | IWDG_PR_PR_1) /*!< IWDG prescaler set to 256 */
  73. /**
  74. * @}
  75. */
  76. /** @defgroup IWDG_Window_option IWDG Window option
  77. * @{
  78. */
  79. #define IWDG_WINDOW_DISABLE IWDG_WINR_WIN
  80. /**
  81. * @}
  82. */
  83. /**
  84. * @}
  85. */
  86. /* Exported macros -----------------------------------------------------------*/
  87. /** @defgroup IWDG_Exported_Macros IWDG Exported Macros
  88. * @{
  89. */
  90. /**
  91. * @brief Enable the IWDG peripheral.
  92. * @param __HANDLE__ IWDG handle
  93. * @retval None
  94. */
  95. #define __HAL_IWDG_START(__HANDLE__) WRITE_REG((__HANDLE__)->Instance->KR, IWDG_KEY_ENABLE)
  96. /**
  97. * @brief Reload IWDG counter with value defined in the reload register
  98. * (write access to IWDG_PR, IWDG_RLR and IWDG_WINR registers disabled).
  99. * @param __HANDLE__ IWDG handle
  100. * @retval None
  101. */
  102. #define __HAL_IWDG_RELOAD_COUNTER(__HANDLE__) WRITE_REG((__HANDLE__)->Instance->KR, IWDG_KEY_RELOAD)
  103. /**
  104. * @}
  105. */
  106. /* Exported functions --------------------------------------------------------*/
  107. /** @defgroup IWDG_Exported_Functions IWDG Exported Functions
  108. * @{
  109. */
  110. /** @defgroup IWDG_Exported_Functions_Group1 Initialization and Start functions
  111. * @{
  112. */
  113. /* Initialization/Start functions ********************************************/
  114. HAL_StatusTypeDef HAL_IWDG_Init(IWDG_HandleTypeDef *hiwdg);
  115. /**
  116. * @}
  117. */
  118. /** @defgroup IWDG_Exported_Functions_Group2 IO operation functions
  119. * @{
  120. */
  121. /* I/O operation functions ****************************************************/
  122. HAL_StatusTypeDef HAL_IWDG_Refresh(IWDG_HandleTypeDef *hiwdg);
  123. /**
  124. * @}
  125. */
  126. /**
  127. * @}
  128. */
  129. /* Private constants ---------------------------------------------------------*/
  130. /** @defgroup IWDG_Private_Constants IWDG Private Constants
  131. * @{
  132. */
  133. /**
  134. * @brief IWDG Key Register BitMask
  135. */
  136. #define IWDG_KEY_RELOAD 0x0000AAAAu /*!< IWDG Reload Counter Enable */
  137. #define IWDG_KEY_ENABLE 0x0000CCCCu /*!< IWDG Peripheral Enable */
  138. #define IWDG_KEY_WRITE_ACCESS_ENABLE 0x00005555u /*!< IWDG KR Write Access Enable */
  139. #define IWDG_KEY_WRITE_ACCESS_DISABLE 0x00000000u /*!< IWDG KR Write Access Disable */
  140. /**
  141. * @}
  142. */
  143. /* Private macros ------------------------------------------------------------*/
  144. /** @defgroup IWDG_Private_Macros IWDG Private Macros
  145. * @{
  146. */
  147. /**
  148. * @brief Enable write access to IWDG_PR, IWDG_RLR and IWDG_WINR registers.
  149. * @param __HANDLE__ IWDG handle
  150. * @retval None
  151. */
  152. #define IWDG_ENABLE_WRITE_ACCESS(__HANDLE__) WRITE_REG((__HANDLE__)->Instance->KR, IWDG_KEY_WRITE_ACCESS_ENABLE)
  153. /**
  154. * @brief Disable write access to IWDG_PR, IWDG_RLR and IWDG_WINR registers.
  155. * @param __HANDLE__ IWDG handle
  156. * @retval None
  157. */
  158. #define IWDG_DISABLE_WRITE_ACCESS(__HANDLE__) WRITE_REG((__HANDLE__)->Instance->KR, IWDG_KEY_WRITE_ACCESS_DISABLE)
  159. /**
  160. * @brief Check IWDG prescaler value.
  161. * @param __PRESCALER__ IWDG prescaler value
  162. * @retval None
  163. */
  164. #define IS_IWDG_PRESCALER(__PRESCALER__) (((__PRESCALER__) == IWDG_PRESCALER_4) || \
  165. ((__PRESCALER__) == IWDG_PRESCALER_8) || \
  166. ((__PRESCALER__) == IWDG_PRESCALER_16) || \
  167. ((__PRESCALER__) == IWDG_PRESCALER_32) || \
  168. ((__PRESCALER__) == IWDG_PRESCALER_64) || \
  169. ((__PRESCALER__) == IWDG_PRESCALER_128)|| \
  170. ((__PRESCALER__) == IWDG_PRESCALER_256))
  171. /**
  172. * @brief Check IWDG reload value.
  173. * @param __RELOAD__ IWDG reload value
  174. * @retval None
  175. */
  176. #define IS_IWDG_RELOAD(__RELOAD__) ((__RELOAD__) <= IWDG_RLR_RL)
  177. /**
  178. * @brief Check IWDG window value.
  179. * @param __WINDOW__ IWDG window value
  180. * @retval None
  181. */
  182. #define IS_IWDG_WINDOW(__WINDOW__) ((__WINDOW__) <= IWDG_WINR_WIN)
  183. /**
  184. * @}
  185. */
  186. /**
  187. * @}
  188. */
  189. /**
  190. * @}
  191. */
  192. #ifdef __cplusplus
  193. }
  194. #endif
  195. #endif /* STM32H7xx_HAL_IWDG_H */