Merge pull request #11189 from klutvott123/move-telemetry-displayport-init
[betaflight.git] / lib / main / STM32F3 / Drivers / STM32F3xx_HAL_Driver / Inc / stm32f3xx_ll_iwdg.h
blobd5bcc9d61b45c0c4cea9025948ec16206bb369ab
1 /**
2 ******************************************************************************
3 * @file stm32f3xx_ll_iwdg.h
4 * @author MCD Application Team
5 * @brief Header file of IWDG LL module.
6 ******************************************************************************
7 * @attention
9 * <h2><center>&copy; COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
11 * Redistribution and use in source and binary forms, with or without modification,
12 * are permitted provided that the following conditions are met:
13 * 1. Redistributions of source code must retain the above copyright notice,
14 * this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright notice,
16 * this list of conditions and the following disclaimer in the documentation
17 * and/or other materials provided with the distribution.
18 * 3. Neither the name of STMicroelectronics nor the names of its contributors
19 * may be used to endorse or promote products derived from this software
20 * without specific prior written permission.
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
25 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
28 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
30 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 ******************************************************************************
36 /* Define to prevent recursive inclusion -------------------------------------*/
37 #ifndef __STM32F3xx_LL_IWDG_H
38 #define __STM32F3xx_LL_IWDG_H
40 #ifdef __cplusplus
41 extern "C" {
42 #endif
44 /* Includes ------------------------------------------------------------------*/
45 #include "stm32f3xx.h"
47 /** @addtogroup STM32F3xx_LL_Driver
48 * @{
51 #if defined(IWDG)
53 /** @defgroup IWDG_LL IWDG
54 * @{
57 /* Private types -------------------------------------------------------------*/
58 /* Private variables ---------------------------------------------------------*/
60 /* Private constants ---------------------------------------------------------*/
61 /** @defgroup IWDG_LL_Private_Constants IWDG Private Constants
62 * @{
65 #define LL_IWDG_KEY_RELOAD 0x0000AAAAU /*!< IWDG Reload Counter Enable */
66 #define LL_IWDG_KEY_ENABLE 0x0000CCCCU /*!< IWDG Peripheral Enable */
67 #define LL_IWDG_KEY_WR_ACCESS_ENABLE 0x00005555U /*!< IWDG KR Write Access Enable */
68 #define LL_IWDG_KEY_WR_ACCESS_DISABLE 0x00000000U /*!< IWDG KR Write Access Disable */
70 /**
71 * @}
74 /* Private macros ------------------------------------------------------------*/
76 /* Exported types ------------------------------------------------------------*/
77 /* Exported constants --------------------------------------------------------*/
78 /** @defgroup IWDG_LL_Exported_Constants IWDG Exported Constants
79 * @{
82 /** @defgroup IWDG_LL_EC_GET_FLAG Get Flags Defines
83 * @brief Flags defines which can be used with LL_IWDG_ReadReg function
84 * @{
86 #define LL_IWDG_SR_PVU IWDG_SR_PVU /*!< Watchdog prescaler value update */
87 #define LL_IWDG_SR_RVU IWDG_SR_RVU /*!< Watchdog counter reload value update */
88 #define LL_IWDG_SR_WVU IWDG_SR_WVU /*!< Watchdog counter window value update */
90 /**
91 * @}
94 /** @defgroup IWDG_LL_EC_PRESCALER Prescaler Divider
95 * @{
97 #define LL_IWDG_PRESCALER_4 0x00000000U /*!< Divider by 4 */
98 #define LL_IWDG_PRESCALER_8 (IWDG_PR_PR_0) /*!< Divider by 8 */
99 #define LL_IWDG_PRESCALER_16 (IWDG_PR_PR_1) /*!< Divider by 16 */
100 #define LL_IWDG_PRESCALER_32 (IWDG_PR_PR_1 | IWDG_PR_PR_0) /*!< Divider by 32 */
101 #define LL_IWDG_PRESCALER_64 (IWDG_PR_PR_2) /*!< Divider by 64 */
102 #define LL_IWDG_PRESCALER_128 (IWDG_PR_PR_2 | IWDG_PR_PR_0) /*!< Divider by 128 */
103 #define LL_IWDG_PRESCALER_256 (IWDG_PR_PR_2 | IWDG_PR_PR_1) /*!< Divider by 256 */
105 * @}
109 * @}
112 /* Exported macro ------------------------------------------------------------*/
113 /** @defgroup IWDG_LL_Exported_Macros IWDG Exported Macros
114 * @{
117 /** @defgroup IWDG_LL_EM_WRITE_READ Common Write and read registers Macros
118 * @{
122 * @brief Write a value in IWDG register
123 * @param __INSTANCE__ IWDG Instance
124 * @param __REG__ Register to be written
125 * @param __VALUE__ Value to be written in the register
126 * @retval None
128 #define LL_IWDG_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG(__INSTANCE__->__REG__, (__VALUE__))
131 * @brief Read a value in IWDG register
132 * @param __INSTANCE__ IWDG Instance
133 * @param __REG__ Register to be read
134 * @retval Register value
136 #define LL_IWDG_ReadReg(__INSTANCE__, __REG__) READ_REG(__INSTANCE__->__REG__)
138 * @}
142 * @}
146 /* Exported functions --------------------------------------------------------*/
147 /** @defgroup IWDG_LL_Exported_Functions IWDG Exported Functions
148 * @{
150 /** @defgroup IWDG_LL_EF_Configuration Configuration
151 * @{
155 * @brief Start the Independent Watchdog
156 * @note Except if the hardware watchdog option is selected
157 * @rmtoll KR KEY LL_IWDG_Enable
158 * @param IWDGx IWDG Instance
159 * @retval None
161 __STATIC_INLINE void LL_IWDG_Enable(IWDG_TypeDef *IWDGx)
163 WRITE_REG(IWDG->KR, LL_IWDG_KEY_ENABLE);
167 * @brief Reloads IWDG counter with value defined in the reload register
168 * @rmtoll KR KEY LL_IWDG_ReloadCounter
169 * @param IWDGx IWDG Instance
170 * @retval None
172 __STATIC_INLINE void LL_IWDG_ReloadCounter(IWDG_TypeDef *IWDGx)
174 WRITE_REG(IWDG->KR, LL_IWDG_KEY_RELOAD);
178 * @brief Enable write access to IWDG_PR, IWDG_RLR and IWDG_WINR registers
179 * @rmtoll KR KEY LL_IWDG_EnableWriteAccess
180 * @param IWDGx IWDG Instance
181 * @retval None
183 __STATIC_INLINE void LL_IWDG_EnableWriteAccess(IWDG_TypeDef *IWDGx)
185 WRITE_REG(IWDG->KR, LL_IWDG_KEY_WR_ACCESS_ENABLE);
189 * @brief Disable write access to IWDG_PR, IWDG_RLR and IWDG_WINR registers
190 * @rmtoll KR KEY LL_IWDG_DisableWriteAccess
191 * @param IWDGx IWDG Instance
192 * @retval None
194 __STATIC_INLINE void LL_IWDG_DisableWriteAccess(IWDG_TypeDef *IWDGx)
196 WRITE_REG(IWDG->KR, LL_IWDG_KEY_WR_ACCESS_DISABLE);
200 * @brief Select the prescaler of the IWDG
201 * @rmtoll PR PR LL_IWDG_SetPrescaler
202 * @param IWDGx IWDG Instance
203 * @param Prescaler This parameter 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
211 * @retval None
213 __STATIC_INLINE void LL_IWDG_SetPrescaler(IWDG_TypeDef *IWDGx, uint32_t Prescaler)
215 WRITE_REG(IWDGx->PR, IWDG_PR_PR & Prescaler);
219 * @brief Get the selected prescaler of the IWDG
220 * @rmtoll PR PR LL_IWDG_GetPrescaler
221 * @param IWDGx IWDG Instance
222 * @retval Returned value can be one of the following values:
223 * @arg @ref LL_IWDG_PRESCALER_4
224 * @arg @ref LL_IWDG_PRESCALER_8
225 * @arg @ref LL_IWDG_PRESCALER_16
226 * @arg @ref LL_IWDG_PRESCALER_32
227 * @arg @ref LL_IWDG_PRESCALER_64
228 * @arg @ref LL_IWDG_PRESCALER_128
229 * @arg @ref LL_IWDG_PRESCALER_256
231 __STATIC_INLINE uint32_t LL_IWDG_GetPrescaler(IWDG_TypeDef *IWDGx)
233 return (uint32_t)(READ_REG(IWDGx->PR));
237 * @brief Specify the IWDG down-counter reload value
238 * @rmtoll RLR RL LL_IWDG_SetReloadCounter
239 * @param IWDGx IWDG Instance
240 * @param Counter Value between Min_Data=0 and Max_Data=0x0FFF
241 * @retval None
243 __STATIC_INLINE void LL_IWDG_SetReloadCounter(IWDG_TypeDef *IWDGx, uint32_t Counter)
245 WRITE_REG(IWDGx->RLR, IWDG_RLR_RL & Counter);
249 * @brief Get the specified IWDG down-counter reload value
250 * @rmtoll RLR RL LL_IWDG_GetReloadCounter
251 * @param IWDGx IWDG Instance
252 * @retval Value between Min_Data=0 and Max_Data=0x0FFF
254 __STATIC_INLINE uint32_t LL_IWDG_GetReloadCounter(IWDG_TypeDef *IWDGx)
256 return (uint32_t)(READ_REG(IWDGx->RLR));
260 * @brief Specify high limit of the window value to be compared to the down-counter.
261 * @rmtoll WINR WIN LL_IWDG_SetWindow
262 * @param IWDGx IWDG Instance
263 * @param Window Value between Min_Data=0 and Max_Data=0x0FFF
264 * @retval None
266 __STATIC_INLINE void LL_IWDG_SetWindow(IWDG_TypeDef *IWDGx, uint32_t Window)
268 WRITE_REG(IWDGx->WINR, IWDG_WINR_WIN & Window);
272 * @brief Get the high limit of the window value specified.
273 * @rmtoll WINR WIN LL_IWDG_GetWindow
274 * @param IWDGx IWDG Instance
275 * @retval Value between Min_Data=0 and Max_Data=0x0FFF
277 __STATIC_INLINE uint32_t LL_IWDG_GetWindow(IWDG_TypeDef *IWDGx)
279 return (uint32_t)(READ_REG(IWDGx->WINR));
283 * @}
286 /** @defgroup IWDG_LL_EF_FLAG_Management FLAG_Management
287 * @{
291 * @brief Check if flag Prescaler Value Update is set or not
292 * @rmtoll SR PVU LL_IWDG_IsActiveFlag_PVU
293 * @param IWDGx IWDG Instance
294 * @retval State of bit (1 or 0).
296 __STATIC_INLINE uint32_t LL_IWDG_IsActiveFlag_PVU(IWDG_TypeDef *IWDGx)
298 return (READ_BIT(IWDGx->SR, IWDG_SR_PVU) == (IWDG_SR_PVU));
302 * @brief Check if flag Reload Value Update is set or not
303 * @rmtoll SR RVU LL_IWDG_IsActiveFlag_RVU
304 * @param IWDGx IWDG Instance
305 * @retval State of bit (1 or 0).
307 __STATIC_INLINE uint32_t LL_IWDG_IsActiveFlag_RVU(IWDG_TypeDef *IWDGx)
309 return (READ_BIT(IWDGx->SR, IWDG_SR_RVU) == (IWDG_SR_RVU));
313 * @brief Check if flag Window Value Update is set or not
314 * @rmtoll SR WVU LL_IWDG_IsActiveFlag_WVU
315 * @param IWDGx IWDG Instance
316 * @retval State of bit (1 or 0).
318 __STATIC_INLINE uint32_t LL_IWDG_IsActiveFlag_WVU(IWDG_TypeDef *IWDGx)
320 return (READ_BIT(IWDGx->SR, IWDG_SR_WVU) == (IWDG_SR_WVU));
324 * @brief Check if all flags Prescaler, Reload & Window Value Update are reset or not
325 * @rmtoll SR PVU LL_IWDG_IsReady\n
326 * SR WVU LL_IWDG_IsReady\n
327 * SR RVU LL_IWDG_IsReady
328 * @param IWDGx IWDG Instance
329 * @retval State of bits (1 or 0).
331 __STATIC_INLINE uint32_t LL_IWDG_IsReady(IWDG_TypeDef *IWDGx)
333 return (READ_BIT(IWDGx->SR, IWDG_SR_PVU | IWDG_SR_RVU | IWDG_SR_WVU) == 0U);
337 * @}
342 * @}
346 * @}
349 #endif /* IWDG) */
352 * @}
355 #ifdef __cplusplus
357 #endif
359 #endif /* __STM32F3xx_LL_IWDG_H */
361 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/