Merge maintenance-8.x.x fixes into master
[inav.git] / lib / main / STM32H7 / Drivers / STM32H7xx_HAL_Driver / Inc / stm32h7xx_ll_iwdg.h
blob743c91730e4f03342d17413d1638e7d1c582a857
1 /**
2 ******************************************************************************
3 * @file stm32h7xx_ll_iwdg.h
4 * @author MCD Application Team
5 * @brief Header file of IWDG LL module.
6 ******************************************************************************
7 * @attention
9 * Copyright (c) 2017 STMicroelectronics.
10 * All rights reserved.
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.
16 ******************************************************************************
19 /* Define to prevent recursive inclusion -------------------------------------*/
20 #ifndef STM32H7xx_LL_IWDG_H
21 #define STM32H7xx_LL_IWDG_H
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
27 /* Includes ------------------------------------------------------------------*/
28 #include "stm32h7xx.h"
30 /** @addtogroup STM32H7xx_LL_Driver
31 * @{
34 #if defined(IWDG1) || defined(IWDG2)
36 /** @defgroup IWDG_LL IWDG
37 * @{
40 /* Private types -------------------------------------------------------------*/
41 /* Private variables ---------------------------------------------------------*/
43 /* Private constants ---------------------------------------------------------*/
44 /** @defgroup IWDG_LL_Private_Constants IWDG Private Constants
45 * @{
47 #define LL_IWDG_KEY_RELOAD 0x0000AAAAU /*!< IWDG Reload Counter Enable */
48 #define LL_IWDG_KEY_ENABLE 0x0000CCCCU /*!< IWDG Peripheral Enable */
49 #define LL_IWDG_KEY_WR_ACCESS_ENABLE 0x00005555U /*!< IWDG KR Write Access Enable */
50 #define LL_IWDG_KEY_WR_ACCESS_DISABLE 0x00000000U /*!< IWDG KR Write Access Disable */
51 /**
52 * @}
55 /* Private macros ------------------------------------------------------------*/
57 /* Exported types ------------------------------------------------------------*/
58 /* Exported constants --------------------------------------------------------*/
59 /** @defgroup IWDG_LL_Exported_Constants IWDG Exported Constants
60 * @{
63 /** @defgroup IWDG_LL_EC_GET_FLAG Get Flags Defines
64 * @brief Flags defines which can be used with LL_IWDG_ReadReg function
65 * @{
67 #define LL_IWDG_SR_PVU IWDG_SR_PVU /*!< Watchdog prescaler value update */
68 #define LL_IWDG_SR_RVU IWDG_SR_RVU /*!< Watchdog counter reload value update */
69 #define LL_IWDG_SR_WVU IWDG_SR_WVU /*!< Watchdog counter window value update */
70 /**
71 * @}
74 /** @defgroup IWDG_LL_EC_PRESCALER Prescaler Divider
75 * @{
77 #define LL_IWDG_PRESCALER_4 0x00000000U /*!< Divider by 4 */
78 #define LL_IWDG_PRESCALER_8 (IWDG_PR_PR_0) /*!< Divider by 8 */
79 #define LL_IWDG_PRESCALER_16 (IWDG_PR_PR_1) /*!< Divider by 16 */
80 #define LL_IWDG_PRESCALER_32 (IWDG_PR_PR_1 | IWDG_PR_PR_0) /*!< Divider by 32 */
81 #define LL_IWDG_PRESCALER_64 (IWDG_PR_PR_2) /*!< Divider by 64 */
82 #define LL_IWDG_PRESCALER_128 (IWDG_PR_PR_2 | IWDG_PR_PR_0) /*!< Divider by 128 */
83 #define LL_IWDG_PRESCALER_256 (IWDG_PR_PR_2 | IWDG_PR_PR_1) /*!< Divider by 256 */
84 /**
85 * @}
88 /**
89 * @}
92 /* Exported macro ------------------------------------------------------------*/
93 /** @defgroup IWDG_LL_Exported_Macros IWDG Exported Macros
94 * @{
97 /** @defgroup IWDG_LL_EM_WRITE_READ Common Write and read registers Macros
98 * @{
102 * @brief Write a value in IWDG register
103 * @param __INSTANCE__ IWDG Instance
104 * @param __REG__ Register to be written
105 * @param __VALUE__ Value to be written in the register
106 * @retval None
108 #define LL_IWDG_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG(__INSTANCE__->__REG__, (__VALUE__))
111 * @brief Read a value in IWDG register
112 * @param __INSTANCE__ IWDG Instance
113 * @param __REG__ Register to be read
114 * @retval Register value
116 #define LL_IWDG_ReadReg(__INSTANCE__, __REG__) READ_REG(__INSTANCE__->__REG__)
118 * @}
122 * @}
126 /* Exported functions --------------------------------------------------------*/
127 /** @defgroup IWDG_LL_Exported_Functions IWDG Exported Functions
128 * @{
130 /** @defgroup IWDG_LL_EF_Configuration Configuration
131 * @{
135 * @brief Start the Independent Watchdog
136 * @note Except if the hardware watchdog option is selected
137 * @rmtoll KR KEY LL_IWDG_Enable
138 * @param IWDGx IWDG Instance
139 * @retval None
141 __STATIC_INLINE void LL_IWDG_Enable(IWDG_TypeDef *IWDGx)
143 WRITE_REG(IWDGx->KR, LL_IWDG_KEY_ENABLE);
147 * @brief Reloads IWDG counter with value defined in the reload register
148 * @rmtoll KR KEY LL_IWDG_ReloadCounter
149 * @param IWDGx IWDG Instance
150 * @retval None
152 __STATIC_INLINE void LL_IWDG_ReloadCounter(IWDG_TypeDef *IWDGx)
154 WRITE_REG(IWDGx->KR, LL_IWDG_KEY_RELOAD);
158 * @brief Enable write access to IWDG_PR, IWDG_RLR and IWDG_WINR registers
159 * @rmtoll KR KEY LL_IWDG_EnableWriteAccess
160 * @param IWDGx IWDG Instance
161 * @retval None
163 __STATIC_INLINE void LL_IWDG_EnableWriteAccess(IWDG_TypeDef *IWDGx)
165 WRITE_REG(IWDGx->KR, LL_IWDG_KEY_WR_ACCESS_ENABLE);
169 * @brief Disable write access to IWDG_PR, IWDG_RLR and IWDG_WINR registers
170 * @rmtoll KR KEY LL_IWDG_DisableWriteAccess
171 * @param IWDGx IWDG Instance
172 * @retval None
174 __STATIC_INLINE void LL_IWDG_DisableWriteAccess(IWDG_TypeDef *IWDGx)
176 WRITE_REG(IWDGx->KR, LL_IWDG_KEY_WR_ACCESS_DISABLE);
180 * @brief Select the prescaler of the IWDG
181 * @rmtoll PR PR LL_IWDG_SetPrescaler
182 * @param IWDGx IWDG Instance
183 * @param Prescaler This parameter can be one of the following values:
184 * @arg @ref LL_IWDG_PRESCALER_4
185 * @arg @ref LL_IWDG_PRESCALER_8
186 * @arg @ref LL_IWDG_PRESCALER_16
187 * @arg @ref LL_IWDG_PRESCALER_32
188 * @arg @ref LL_IWDG_PRESCALER_64
189 * @arg @ref LL_IWDG_PRESCALER_128
190 * @arg @ref LL_IWDG_PRESCALER_256
191 * @retval None
193 __STATIC_INLINE void LL_IWDG_SetPrescaler(IWDG_TypeDef *IWDGx, uint32_t Prescaler)
195 WRITE_REG(IWDGx->PR, IWDG_PR_PR & Prescaler);
199 * @brief Get the selected prescaler of the IWDG
200 * @rmtoll PR PR LL_IWDG_GetPrescaler
201 * @param IWDGx IWDG Instance
202 * @retval Returned value can be one of the following values:
203 * @arg @ref LL_IWDG_PRESCALER_4
204 * @arg @ref LL_IWDG_PRESCALER_8
205 * @arg @ref LL_IWDG_PRESCALER_16
206 * @arg @ref LL_IWDG_PRESCALER_32
207 * @arg @ref LL_IWDG_PRESCALER_64
208 * @arg @ref LL_IWDG_PRESCALER_128
209 * @arg @ref LL_IWDG_PRESCALER_256
211 __STATIC_INLINE uint32_t LL_IWDG_GetPrescaler(const IWDG_TypeDef *IWDGx)
213 return (READ_REG(IWDGx->PR));
217 * @brief Specify the IWDG down-counter reload value
218 * @rmtoll RLR RL LL_IWDG_SetReloadCounter
219 * @param IWDGx IWDG Instance
220 * @param Counter Value between Min_Data=0 and Max_Data=0x0FFF
221 * @retval None
223 __STATIC_INLINE void LL_IWDG_SetReloadCounter(IWDG_TypeDef *IWDGx, uint32_t Counter)
225 WRITE_REG(IWDGx->RLR, IWDG_RLR_RL & Counter);
229 * @brief Get the specified IWDG down-counter reload value
230 * @rmtoll RLR RL LL_IWDG_GetReloadCounter
231 * @param IWDGx IWDG Instance
232 * @retval Value between Min_Data=0 and Max_Data=0x0FFF
234 __STATIC_INLINE uint32_t LL_IWDG_GetReloadCounter(const IWDG_TypeDef *IWDGx)
236 return (READ_REG(IWDGx->RLR));
240 * @brief Specify high limit of the window value to be compared to the down-counter.
241 * @rmtoll WINR WIN LL_IWDG_SetWindow
242 * @param IWDGx IWDG Instance
243 * @param Window Value between Min_Data=0 and Max_Data=0x0FFF
244 * @retval None
246 __STATIC_INLINE void LL_IWDG_SetWindow(IWDG_TypeDef *IWDGx, uint32_t Window)
248 WRITE_REG(IWDGx->WINR, IWDG_WINR_WIN & Window);
252 * @brief Get the high limit of the window value specified.
253 * @rmtoll WINR WIN LL_IWDG_GetWindow
254 * @param IWDGx IWDG Instance
255 * @retval Value between Min_Data=0 and Max_Data=0x0FFF
257 __STATIC_INLINE uint32_t LL_IWDG_GetWindow(const IWDG_TypeDef *IWDGx)
259 return (READ_REG(IWDGx->WINR));
263 * @}
266 /** @defgroup IWDG_LL_EF_FLAG_Management FLAG_Management
267 * @{
271 * @brief Check if flag Prescaler Value Update is set or not
272 * @rmtoll SR PVU LL_IWDG_IsActiveFlag_PVU
273 * @param IWDGx IWDG Instance
274 * @retval State of bit (1 or 0).
276 __STATIC_INLINE uint32_t LL_IWDG_IsActiveFlag_PVU(const IWDG_TypeDef *IWDGx)
278 return ((READ_BIT(IWDGx->SR, IWDG_SR_PVU) == (IWDG_SR_PVU)) ? 1UL : 0UL);
282 * @brief Check if flag Reload Value Update is set or not
283 * @rmtoll SR RVU LL_IWDG_IsActiveFlag_RVU
284 * @param IWDGx IWDG Instance
285 * @retval State of bit (1 or 0).
287 __STATIC_INLINE uint32_t LL_IWDG_IsActiveFlag_RVU(const IWDG_TypeDef *IWDGx)
289 return ((READ_BIT(IWDGx->SR, IWDG_SR_RVU) == (IWDG_SR_RVU)) ? 1UL : 0UL);
293 * @brief Check if flag Window Value Update is set or not
294 * @rmtoll SR WVU LL_IWDG_IsActiveFlag_WVU
295 * @param IWDGx IWDG Instance
296 * @retval State of bit (1 or 0).
298 __STATIC_INLINE uint32_t LL_IWDG_IsActiveFlag_WVU(const IWDG_TypeDef *IWDGx)
300 return ((READ_BIT(IWDGx->SR, IWDG_SR_WVU) == (IWDG_SR_WVU)) ? 1UL : 0UL);
304 * @brief Check if all flags Prescaler, Reload & Window Value Update are reset or not
305 * @rmtoll SR PVU LL_IWDG_IsReady\n
306 * SR RVU LL_IWDG_IsReady\n
307 * SR WVU LL_IWDG_IsReady
308 * @param IWDGx IWDG Instance
309 * @retval State of bits (1 or 0).
311 __STATIC_INLINE uint32_t LL_IWDG_IsReady(const IWDG_TypeDef *IWDGx)
313 return ((READ_BIT(IWDGx->SR, IWDG_SR_PVU | IWDG_SR_RVU | IWDG_SR_WVU) == 0U) ? 1UL : 0UL);
317 * @}
321 * @}
325 * @}
328 #endif /* IWDG1 || IWDG2 */
331 * @}
334 #ifdef __cplusplus
336 #endif
338 #endif /* STM32H7xx_LL_IWDG_H */