stm32f1xx_hal_iwdg.h 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. /**
  2. ******************************************************************************
  3. * @file stm32f1xx_hal_iwdg.h
  4. * @author MCD Application Team
  5. * @brief Header file of IWDG HAL module.
  6. ******************************************************************************
  7. * @attention
  8. *
  9. * Copyright (c) 2016 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 STM32F1xx_HAL_IWDG_H
  20. #define STM32F1xx_HAL_IWDG_H
  21. #ifdef __cplusplus
  22. extern "C" {
  23. #endif
  24. /* Includes ------------------------------------------------------------------*/
  25. #include "stm32f1xx_hal_def.h"
  26. /** @addtogroup STM32F1xx_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. } IWDG_InitTypeDef;
  46. /**
  47. * @brief IWDG Handle Structure definition
  48. */
  49. typedef struct
  50. {
  51. IWDG_TypeDef *Instance; /*!< Register base address */
  52. IWDG_InitTypeDef Init; /*!< IWDG required parameters */
  53. } IWDG_HandleTypeDef;
  54. /**
  55. * @}
  56. */
  57. /* Exported constants --------------------------------------------------------*/
  58. /** @defgroup IWDG_Exported_Constants IWDG Exported Constants
  59. * @{
  60. */
  61. /** @defgroup IWDG_Prescaler IWDG Prescaler
  62. * @{
  63. */
  64. #define IWDG_PRESCALER_4 0x00000000u /*!< IWDG prescaler set to 4 */
  65. #define IWDG_PRESCALER_8 IWDG_PR_PR_0 /*!< IWDG prescaler set to 8 */
  66. #define IWDG_PRESCALER_16 IWDG_PR_PR_1 /*!< IWDG prescaler set to 16 */
  67. #define IWDG_PRESCALER_32 (IWDG_PR_PR_1 | IWDG_PR_PR_0) /*!< IWDG prescaler set to 32 */
  68. #define IWDG_PRESCALER_64 IWDG_PR_PR_2 /*!< IWDG prescaler set to 64 */
  69. #define IWDG_PRESCALER_128 (IWDG_PR_PR_2 | IWDG_PR_PR_0) /*!< IWDG prescaler set to 128 */
  70. #define IWDG_PRESCALER_256 (IWDG_PR_PR_2 | IWDG_PR_PR_1) /*!< IWDG prescaler set to 256 */
  71. /**
  72. * @}
  73. */
  74. /**
  75. * @}
  76. */
  77. /* Exported macros -----------------------------------------------------------*/
  78. /** @defgroup IWDG_Exported_Macros IWDG Exported Macros
  79. * @{
  80. */
  81. /**
  82. * @brief Enable the IWDG peripheral.
  83. * @param __HANDLE__ IWDG handle
  84. * @retval None
  85. */
  86. #define __HAL_IWDG_START(__HANDLE__) WRITE_REG((__HANDLE__)->Instance->KR, IWDG_KEY_ENABLE)
  87. /**
  88. * @brief Reload IWDG counter with value defined in the reload register
  89. * (write access to IWDG_PR and IWDG_RLR registers disabled).
  90. * @param __HANDLE__ IWDG handle
  91. * @retval None
  92. */
  93. #define __HAL_IWDG_RELOAD_COUNTER(__HANDLE__) WRITE_REG((__HANDLE__)->Instance->KR, IWDG_KEY_RELOAD)
  94. /**
  95. * @}
  96. */
  97. /* Exported functions --------------------------------------------------------*/
  98. /** @defgroup IWDG_Exported_Functions IWDG Exported Functions
  99. * @{
  100. */
  101. /** @defgroup IWDG_Exported_Functions_Group1 Initialization and Start functions
  102. * @{
  103. */
  104. /* Initialization/Start functions ********************************************/
  105. HAL_StatusTypeDef HAL_IWDG_Init(IWDG_HandleTypeDef *hiwdg);
  106. /**
  107. * @}
  108. */
  109. /** @defgroup IWDG_Exported_Functions_Group2 IO operation functions
  110. * @{
  111. */
  112. /* I/O operation functions ****************************************************/
  113. HAL_StatusTypeDef HAL_IWDG_Refresh(IWDG_HandleTypeDef *hiwdg);
  114. /**
  115. * @}
  116. */
  117. /**
  118. * @}
  119. */
  120. /* Private constants ---------------------------------------------------------*/
  121. /** @defgroup IWDG_Private_Constants IWDG Private Constants
  122. * @{
  123. */
  124. /**
  125. * @brief IWDG Key Register BitMask
  126. */
  127. #define IWDG_KEY_RELOAD 0x0000AAAAu /*!< IWDG Reload Counter Enable */
  128. #define IWDG_KEY_ENABLE 0x0000CCCCu /*!< IWDG Peripheral Enable */
  129. #define IWDG_KEY_WRITE_ACCESS_ENABLE 0x00005555u /*!< IWDG KR Write Access Enable */
  130. #define IWDG_KEY_WRITE_ACCESS_DISABLE 0x00000000u /*!< IWDG KR Write Access Disable */
  131. /**
  132. * @}
  133. */
  134. /* Private macros ------------------------------------------------------------*/
  135. /** @defgroup IWDG_Private_Macros IWDG Private Macros
  136. * @{
  137. */
  138. /**
  139. * @brief Enable write access to IWDG_PR and IWDG_RLR registers.
  140. * @param __HANDLE__ IWDG handle
  141. * @retval None
  142. */
  143. #define IWDG_ENABLE_WRITE_ACCESS(__HANDLE__) WRITE_REG((__HANDLE__)->Instance->KR, IWDG_KEY_WRITE_ACCESS_ENABLE)
  144. /**
  145. * @brief Disable write access to IWDG_PR and IWDG_RLR registers.
  146. * @param __HANDLE__ IWDG handle
  147. * @retval None
  148. */
  149. #define IWDG_DISABLE_WRITE_ACCESS(__HANDLE__) WRITE_REG((__HANDLE__)->Instance->KR, IWDG_KEY_WRITE_ACCESS_DISABLE)
  150. /**
  151. * @brief Check IWDG prescaler value.
  152. * @param __PRESCALER__ IWDG prescaler value
  153. * @retval None
  154. */
  155. #define IS_IWDG_PRESCALER(__PRESCALER__) (((__PRESCALER__) == IWDG_PRESCALER_4) || \
  156. ((__PRESCALER__) == IWDG_PRESCALER_8) || \
  157. ((__PRESCALER__) == IWDG_PRESCALER_16) || \
  158. ((__PRESCALER__) == IWDG_PRESCALER_32) || \
  159. ((__PRESCALER__) == IWDG_PRESCALER_64) || \
  160. ((__PRESCALER__) == IWDG_PRESCALER_128)|| \
  161. ((__PRESCALER__) == IWDG_PRESCALER_256))
  162. /**
  163. * @brief Check IWDG reload value.
  164. * @param __RELOAD__ IWDG reload value
  165. * @retval None
  166. */
  167. #define IS_IWDG_RELOAD(__RELOAD__) ((__RELOAD__) <= IWDG_RLR_RL)
  168. /**
  169. * @}
  170. */
  171. /**
  172. * @}
  173. */
  174. /**
  175. * @}
  176. */
  177. #ifdef __cplusplus
  178. }
  179. #endif
  180. #endif /* STM32F1xx_HAL_IWDG_H */