2 ******************************************************************************
3 * @file stm32h7xx_ll_iwdg.h
4 * @author MCD Application Team
5 * @brief Header file of IWDG LL module.
6 ******************************************************************************
9 * <h2><center>© Copyright (c) 2017 STMicroelectronics.
10 * All rights reserved.</center></h2>
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
17 ******************************************************************************
20 /* Define to prevent recursive inclusion -------------------------------------*/
21 #ifndef STM32H7xx_LL_IWDG_H
22 #define STM32H7xx_LL_IWDG_H
28 /* Includes ------------------------------------------------------------------*/
29 #include "stm32h7xx.h"
31 /** @addtogroup STM32H7xx_LL_Driver
35 #if defined(IWDG1) || defined(IWDG2)
37 /** @defgroup IWDG_LL IWDG
41 /* Private types -------------------------------------------------------------*/
42 /* Private variables ---------------------------------------------------------*/
44 /* Private constants ---------------------------------------------------------*/
45 /** @defgroup IWDG_LL_Private_Constants IWDG Private Constants
48 #define LL_IWDG_KEY_RELOAD 0x0000AAAAU /*!< IWDG Reload Counter Enable */
49 #define LL_IWDG_KEY_ENABLE 0x0000CCCCU /*!< IWDG Peripheral Enable */
50 #define LL_IWDG_KEY_WR_ACCESS_ENABLE 0x00005555U /*!< IWDG KR Write Access Enable */
51 #define LL_IWDG_KEY_WR_ACCESS_DISABLE 0x00000000U /*!< IWDG KR Write Access Disable */
56 /* Private macros ------------------------------------------------------------*/
58 /* Exported types ------------------------------------------------------------*/
59 /* Exported constants --------------------------------------------------------*/
60 /** @defgroup IWDG_LL_Exported_Constants IWDG Exported Constants
64 /** @defgroup IWDG_LL_EC_GET_FLAG Get Flags Defines
65 * @brief Flags defines which can be used with LL_IWDG_ReadReg function
68 #define LL_IWDG_SR_PVU IWDG_SR_PVU /*!< Watchdog prescaler value update */
69 #define LL_IWDG_SR_RVU IWDG_SR_RVU /*!< Watchdog counter reload value update */
70 #define LL_IWDG_SR_WVU IWDG_SR_WVU /*!< Watchdog counter window value update */
75 /** @defgroup IWDG_LL_EC_PRESCALER Prescaler Divider
78 #define LL_IWDG_PRESCALER_4 0x00000000U /*!< Divider by 4 */
79 #define LL_IWDG_PRESCALER_8 (IWDG_PR_PR_0) /*!< Divider by 8 */
80 #define LL_IWDG_PRESCALER_16 (IWDG_PR_PR_1) /*!< Divider by 16 */
81 #define LL_IWDG_PRESCALER_32 (IWDG_PR_PR_1 | IWDG_PR_PR_0) /*!< Divider by 32 */
82 #define LL_IWDG_PRESCALER_64 (IWDG_PR_PR_2) /*!< Divider by 64 */
83 #define LL_IWDG_PRESCALER_128 (IWDG_PR_PR_2 | IWDG_PR_PR_0) /*!< Divider by 128 */
84 #define LL_IWDG_PRESCALER_256 (IWDG_PR_PR_2 | IWDG_PR_PR_1) /*!< Divider by 256 */
93 /* Exported macro ------------------------------------------------------------*/
94 /** @defgroup IWDG_LL_Exported_Macros IWDG Exported Macros
98 /** @defgroup IWDG_LL_EM_WRITE_READ Common Write and read registers Macros
103 * @brief Write a value in IWDG register
104 * @param __INSTANCE__ IWDG Instance
105 * @param __REG__ Register to be written
106 * @param __VALUE__ Value to be written in the register
109 #define LL_IWDG_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG(__INSTANCE__->__REG__, (__VALUE__))
112 * @brief Read a value in IWDG register
113 * @param __INSTANCE__ IWDG Instance
114 * @param __REG__ Register to be read
115 * @retval Register value
117 #define LL_IWDG_ReadReg(__INSTANCE__, __REG__) READ_REG(__INSTANCE__->__REG__)
127 /* Exported functions --------------------------------------------------------*/
128 /** @defgroup IWDG_LL_Exported_Functions IWDG Exported Functions
131 /** @defgroup IWDG_LL_EF_Configuration Configuration
136 * @brief Start the Independent Watchdog
137 * @note Except if the hardware watchdog option is selected
138 * @rmtoll KR KEY LL_IWDG_Enable
139 * @param IWDGx IWDG Instance
142 __STATIC_INLINE
void LL_IWDG_Enable(IWDG_TypeDef
*IWDGx
)
144 WRITE_REG(IWDGx
->KR
, LL_IWDG_KEY_ENABLE
);
148 * @brief Reloads IWDG counter with value defined in the reload register
149 * @rmtoll KR KEY LL_IWDG_ReloadCounter
150 * @param IWDGx IWDG Instance
153 __STATIC_INLINE
void LL_IWDG_ReloadCounter(IWDG_TypeDef
*IWDGx
)
155 WRITE_REG(IWDGx
->KR
, LL_IWDG_KEY_RELOAD
);
159 * @brief Enable write access to IWDG_PR, IWDG_RLR and IWDG_WINR registers
160 * @rmtoll KR KEY LL_IWDG_EnableWriteAccess
161 * @param IWDGx IWDG Instance
164 __STATIC_INLINE
void LL_IWDG_EnableWriteAccess(IWDG_TypeDef
*IWDGx
)
166 WRITE_REG(IWDGx
->KR
, LL_IWDG_KEY_WR_ACCESS_ENABLE
);
170 * @brief Disable write access to IWDG_PR, IWDG_RLR and IWDG_WINR registers
171 * @rmtoll KR KEY LL_IWDG_DisableWriteAccess
172 * @param IWDGx IWDG Instance
175 __STATIC_INLINE
void LL_IWDG_DisableWriteAccess(IWDG_TypeDef
*IWDGx
)
177 WRITE_REG(IWDGx
->KR
, LL_IWDG_KEY_WR_ACCESS_DISABLE
);
181 * @brief Select the prescaler of the IWDG
182 * @rmtoll PR PR LL_IWDG_SetPrescaler
183 * @param IWDGx IWDG Instance
184 * @param Prescaler This parameter can be one of the following values:
185 * @arg @ref LL_IWDG_PRESCALER_4
186 * @arg @ref LL_IWDG_PRESCALER_8
187 * @arg @ref LL_IWDG_PRESCALER_16
188 * @arg @ref LL_IWDG_PRESCALER_32
189 * @arg @ref LL_IWDG_PRESCALER_64
190 * @arg @ref LL_IWDG_PRESCALER_128
191 * @arg @ref LL_IWDG_PRESCALER_256
194 __STATIC_INLINE
void LL_IWDG_SetPrescaler(IWDG_TypeDef
*IWDGx
, uint32_t Prescaler
)
196 WRITE_REG(IWDGx
->PR
, IWDG_PR_PR
& Prescaler
);
200 * @brief Get the selected prescaler of the IWDG
201 * @rmtoll PR PR LL_IWDG_GetPrescaler
202 * @param IWDGx IWDG Instance
203 * @retval Returned value can be one of the following values:
204 * @arg @ref LL_IWDG_PRESCALER_4
205 * @arg @ref LL_IWDG_PRESCALER_8
206 * @arg @ref LL_IWDG_PRESCALER_16
207 * @arg @ref LL_IWDG_PRESCALER_32
208 * @arg @ref LL_IWDG_PRESCALER_64
209 * @arg @ref LL_IWDG_PRESCALER_128
210 * @arg @ref LL_IWDG_PRESCALER_256
212 __STATIC_INLINE
uint32_t LL_IWDG_GetPrescaler(IWDG_TypeDef
*IWDGx
)
214 return (READ_REG(IWDGx
->PR
));
218 * @brief Specify the IWDG down-counter reload value
219 * @rmtoll RLR RL LL_IWDG_SetReloadCounter
220 * @param IWDGx IWDG Instance
221 * @param Counter Value between Min_Data=0 and Max_Data=0x0FFF
224 __STATIC_INLINE
void LL_IWDG_SetReloadCounter(IWDG_TypeDef
*IWDGx
, uint32_t Counter
)
226 WRITE_REG(IWDGx
->RLR
, IWDG_RLR_RL
& Counter
);
230 * @brief Get the specified IWDG down-counter reload value
231 * @rmtoll RLR RL LL_IWDG_GetReloadCounter
232 * @param IWDGx IWDG Instance
233 * @retval Value between Min_Data=0 and Max_Data=0x0FFF
235 __STATIC_INLINE
uint32_t LL_IWDG_GetReloadCounter(IWDG_TypeDef
*IWDGx
)
237 return (READ_REG(IWDGx
->RLR
));
241 * @brief Specify high limit of the window value to be compared to the down-counter.
242 * @rmtoll WINR WIN LL_IWDG_SetWindow
243 * @param IWDGx IWDG Instance
244 * @param Window Value between Min_Data=0 and Max_Data=0x0FFF
247 __STATIC_INLINE
void LL_IWDG_SetWindow(IWDG_TypeDef
*IWDGx
, uint32_t Window
)
249 WRITE_REG(IWDGx
->WINR
, IWDG_WINR_WIN
& Window
);
253 * @brief Get the high limit of the window value specified.
254 * @rmtoll WINR WIN LL_IWDG_GetWindow
255 * @param IWDGx IWDG Instance
256 * @retval Value between Min_Data=0 and Max_Data=0x0FFF
258 __STATIC_INLINE
uint32_t LL_IWDG_GetWindow(IWDG_TypeDef
*IWDGx
)
260 return (READ_REG(IWDGx
->WINR
));
267 /** @defgroup IWDG_LL_EF_FLAG_Management FLAG_Management
272 * @brief Check if flag Prescaler Value Update is set or not
273 * @rmtoll SR PVU LL_IWDG_IsActiveFlag_PVU
274 * @param IWDGx IWDG Instance
275 * @retval State of bit (1 or 0).
277 __STATIC_INLINE
uint32_t LL_IWDG_IsActiveFlag_PVU(IWDG_TypeDef
*IWDGx
)
279 return ((READ_BIT(IWDGx
->SR
, IWDG_SR_PVU
) == (IWDG_SR_PVU
)) ? 1UL : 0UL);
283 * @brief Check if flag Reload Value Update is set or not
284 * @rmtoll SR RVU LL_IWDG_IsActiveFlag_RVU
285 * @param IWDGx IWDG Instance
286 * @retval State of bit (1 or 0).
288 __STATIC_INLINE
uint32_t LL_IWDG_IsActiveFlag_RVU(IWDG_TypeDef
*IWDGx
)
290 return ((READ_BIT(IWDGx
->SR
, IWDG_SR_RVU
) == (IWDG_SR_RVU
)) ? 1UL : 0UL);
294 * @brief Check if flag Window Value Update is set or not
295 * @rmtoll SR WVU LL_IWDG_IsActiveFlag_WVU
296 * @param IWDGx IWDG Instance
297 * @retval State of bit (1 or 0).
299 __STATIC_INLINE
uint32_t LL_IWDG_IsActiveFlag_WVU(IWDG_TypeDef
*IWDGx
)
301 return ((READ_BIT(IWDGx
->SR
, IWDG_SR_WVU
) == (IWDG_SR_WVU
)) ? 1UL : 0UL);
305 * @brief Check if all flags Prescaler, Reload & Window Value Update are reset or not
306 * @rmtoll SR PVU LL_IWDG_IsReady\n
307 * SR WVU LL_IWDG_IsReady\n
308 * SR RVU LL_IWDG_IsReady
309 * @param IWDGx IWDG Instance
310 * @retval State of bits (1 or 0).
312 __STATIC_INLINE
uint32_t LL_IWDG_IsReady(IWDG_TypeDef
*IWDGx
)
314 return ((READ_BIT(IWDGx
->SR
, IWDG_SR_PVU
| IWDG_SR_RVU
| IWDG_SR_WVU
) == 0U) ? 1UL : 0UL);
330 #endif /* IWDG1 || IWDG2 */
340 #endif /* STM32H7xx_LL_IWDG_H */
342 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/