You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

243 lines
7.2 KiB

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