Merge pull request #11270 from haslinghuis/rename_attr
[betaflight.git] / lib / main / STM32H7 / Drivers / STM32H7xx_HAL_Driver / Inc / stm32h7xx_hal_iwdg.h
blob2157e774dcef7b0794143d071748bcf0ba5c880f
1 /**
2 ******************************************************************************
3 * @file stm32h7xx_hal_iwdg.h
4 * @author MCD Application Team
5 * @brief Header file of IWDG HAL module.
6 ******************************************************************************
7 * @attention
9 * <h2><center>&copy; 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_HAL_IWDG_H
22 #define STM32H7xx_HAL_IWDG_H
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
28 /* Includes ------------------------------------------------------------------*/
29 #include "stm32h7xx_hal_def.h"
31 /** @addtogroup STM32H7xx_HAL_Driver
32 * @{
35 /** @defgroup IWDG IWDG
36 * @{
39 /* Exported types ------------------------------------------------------------*/
40 /** @defgroup IWDG_Exported_Types IWDG Exported Types
41 * @{
44 /**
45 * @brief IWDG Init structure definition
47 typedef struct
49 uint32_t Prescaler; /*!< Select the prescaler of the IWDG.
50 This parameter can be a value of @ref IWDG_Prescaler */
52 uint32_t Reload; /*!< Specifies the IWDG down-counter reload value.
53 This parameter must be a number between Min_Data = 0 and Max_Data = 0x0FFF */
55 uint32_t Window; /*!< Specifies the window value to be compared to the down-counter.
56 This parameter must be a number between Min_Data = 0 and Max_Data = 0x0FFF */
58 } IWDG_InitTypeDef;
60 /**
61 * @brief IWDG Handle Structure definition
63 typedef struct
65 IWDG_TypeDef *Instance; /*!< Register base address */
67 IWDG_InitTypeDef Init; /*!< IWDG required parameters */
68 } IWDG_HandleTypeDef;
71 /**
72 * @}
75 /* Exported constants --------------------------------------------------------*/
76 /** @defgroup IWDG_Exported_Constants IWDG Exported Constants
77 * @{
80 /** @defgroup IWDG_Prescaler IWDG Prescaler
81 * @{
83 #define IWDG_PRESCALER_4 0x00000000u /*!< IWDG prescaler set to 4 */
84 #define IWDG_PRESCALER_8 IWDG_PR_PR_0 /*!< IWDG prescaler set to 8 */
85 #define IWDG_PRESCALER_16 IWDG_PR_PR_1 /*!< IWDG prescaler set to 16 */
86 #define IWDG_PRESCALER_32 (IWDG_PR_PR_1 | IWDG_PR_PR_0) /*!< IWDG prescaler set to 32 */
87 #define IWDG_PRESCALER_64 IWDG_PR_PR_2 /*!< IWDG prescaler set to 64 */
88 #define IWDG_PRESCALER_128 (IWDG_PR_PR_2 | IWDG_PR_PR_0) /*!< IWDG prescaler set to 128 */
89 #define IWDG_PRESCALER_256 (IWDG_PR_PR_2 | IWDG_PR_PR_1) /*!< IWDG prescaler set to 256 */
91 /**
92 * @}
95 /** @defgroup IWDG_Window_option IWDG Window option
96 * @{
98 #define IWDG_WINDOW_DISABLE IWDG_WINR_WIN
99 /**
100 * @}
105 * @}
108 /* Exported macros -----------------------------------------------------------*/
109 /** @defgroup IWDG_Exported_Macros IWDG Exported Macros
110 * @{
114 * @brief Enable the IWDG peripheral.
115 * @param __HANDLE__ IWDG handle
116 * @retval None
118 #define __HAL_IWDG_START(__HANDLE__) WRITE_REG((__HANDLE__)->Instance->KR, IWDG_KEY_ENABLE)
121 * @brief Reload IWDG counter with value defined in the reload register
122 * (write access to IWDG_PR, IWDG_RLR and IWDG_WINR registers disabled).
123 * @param __HANDLE__ IWDG handle
124 * @retval None
126 #define __HAL_IWDG_RELOAD_COUNTER(__HANDLE__) WRITE_REG((__HANDLE__)->Instance->KR, IWDG_KEY_RELOAD)
129 * @}
132 /* Exported functions --------------------------------------------------------*/
133 /** @defgroup IWDG_Exported_Functions IWDG Exported Functions
134 * @{
137 /** @defgroup IWDG_Exported_Functions_Group1 Initialization and Start functions
138 * @{
140 /* Initialization/Start functions ********************************************/
141 HAL_StatusTypeDef HAL_IWDG_Init(IWDG_HandleTypeDef *hiwdg);
143 * @}
146 /** @defgroup IWDG_Exported_Functions_Group2 IO operation functions
147 * @{
149 /* I/O operation functions ****************************************************/
150 HAL_StatusTypeDef HAL_IWDG_Refresh(IWDG_HandleTypeDef *hiwdg);
152 * @}
156 * @}
159 /* Private constants ---------------------------------------------------------*/
160 /** @defgroup IWDG_Private_Constants IWDG Private Constants
161 * @{
165 * @brief IWDG Key Register BitMask
167 #define IWDG_KEY_RELOAD 0x0000AAAAu /*!< IWDG Reload Counter Enable */
168 #define IWDG_KEY_ENABLE 0x0000CCCCu /*!< IWDG Peripheral Enable */
169 #define IWDG_KEY_WRITE_ACCESS_ENABLE 0x00005555u /*!< IWDG KR Write Access Enable */
170 #define IWDG_KEY_WRITE_ACCESS_DISABLE 0x00000000u /*!< IWDG KR Write Access Disable */
173 * @}
176 /* Private macros ------------------------------------------------------------*/
177 /** @defgroup IWDG_Private_Macros IWDG Private Macros
178 * @{
182 * @brief Enable write access to IWDG_PR, IWDG_RLR and IWDG_WINR registers.
183 * @param __HANDLE__ IWDG handle
184 * @retval None
186 #define IWDG_ENABLE_WRITE_ACCESS(__HANDLE__) WRITE_REG((__HANDLE__)->Instance->KR, IWDG_KEY_WRITE_ACCESS_ENABLE)
189 * @brief Disable write access to IWDG_PR, IWDG_RLR and IWDG_WINR registers.
190 * @param __HANDLE__ IWDG handle
191 * @retval None
193 #define IWDG_DISABLE_WRITE_ACCESS(__HANDLE__) WRITE_REG((__HANDLE__)->Instance->KR, IWDG_KEY_WRITE_ACCESS_DISABLE)
196 * @brief Check IWDG prescaler value.
197 * @param __PRESCALER__ IWDG prescaler value
198 * @retval None
200 #define IS_IWDG_PRESCALER(__PRESCALER__) (((__PRESCALER__) == IWDG_PRESCALER_4) || \
201 ((__PRESCALER__) == IWDG_PRESCALER_8) || \
202 ((__PRESCALER__) == IWDG_PRESCALER_16) || \
203 ((__PRESCALER__) == IWDG_PRESCALER_32) || \
204 ((__PRESCALER__) == IWDG_PRESCALER_64) || \
205 ((__PRESCALER__) == IWDG_PRESCALER_128)|| \
206 ((__PRESCALER__) == IWDG_PRESCALER_256))
209 * @brief Check IWDG reload value.
210 * @param __RELOAD__ IWDG reload value
211 * @retval None
213 #define IS_IWDG_RELOAD(__RELOAD__) ((__RELOAD__) <= IWDG_RLR_RL)
216 * @brief Check IWDG window value.
217 * @param __WINDOW__ IWDG window value
218 * @retval None
220 #define IS_IWDG_WINDOW(__WINDOW__) ((__WINDOW__) <= IWDG_WINR_WIN)
224 * @}
228 * @}
232 * @}
236 #ifdef __cplusplus
238 #endif
240 #endif /* STM32H7xx_HAL_IWDG_H */
242 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/