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.

stm32l1xx_hal_iwdg.h 6.5KB

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