2 ******************************************************************************
3 * @file stm32h7xx_hal_iwdg.h
4 * @author MCD Application Team
5 * @brief Header file of IWDG HAL 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_HAL_IWDG_H
22 #define STM32H7xx_HAL_IWDG_H
28 /* Includes ------------------------------------------------------------------*/
29 #include "stm32h7xx_hal_def.h"
31 /** @addtogroup STM32H7xx_HAL_Driver
35 /** @defgroup IWDG IWDG
39 /* Exported types ------------------------------------------------------------*/
40 /** @defgroup IWDG_Exported_Types IWDG Exported Types
45 * @brief IWDG Init structure definition
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 */
61 * @brief IWDG Handle Structure definition
65 IWDG_TypeDef
*Instance
; /*!< Register base address */
67 IWDG_InitTypeDef Init
; /*!< IWDG required parameters */
75 /* Exported constants --------------------------------------------------------*/
76 /** @defgroup IWDG_Exported_Constants IWDG Exported Constants
80 /** @defgroup IWDG_Prescaler IWDG Prescaler
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 */
95 /** @defgroup IWDG_Window_option IWDG Window option
98 #define IWDG_WINDOW_DISABLE IWDG_WINR_WIN
108 /* Exported macros -----------------------------------------------------------*/
109 /** @defgroup IWDG_Exported_Macros IWDG Exported Macros
114 * @brief Enable the IWDG peripheral.
115 * @param __HANDLE__ IWDG handle
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
126 #define __HAL_IWDG_RELOAD_COUNTER(__HANDLE__) WRITE_REG((__HANDLE__)->Instance->KR, IWDG_KEY_RELOAD)
132 /* Exported functions --------------------------------------------------------*/
133 /** @defgroup IWDG_Exported_Functions IWDG Exported Functions
137 /** @defgroup IWDG_Exported_Functions_Group1 Initialization and Start functions
140 /* Initialization/Start functions ********************************************/
141 HAL_StatusTypeDef
HAL_IWDG_Init(IWDG_HandleTypeDef
*hiwdg
);
146 /** @defgroup IWDG_Exported_Functions_Group2 IO operation functions
149 /* I/O operation functions ****************************************************/
150 HAL_StatusTypeDef
HAL_IWDG_Refresh(IWDG_HandleTypeDef
*hiwdg
);
159 /* Private constants ---------------------------------------------------------*/
160 /** @defgroup IWDG_Private_Constants IWDG Private Constants
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 */
176 /* Private macros ------------------------------------------------------------*/
177 /** @defgroup IWDG_Private_Macros IWDG Private Macros
182 * @brief Enable write access to IWDG_PR, IWDG_RLR and IWDG_WINR registers.
183 * @param __HANDLE__ IWDG handle
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
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
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
213 #define IS_IWDG_RELOAD(__RELOAD__) ((__RELOAD__) <= IWDG_RLR_RL)
216 * @brief Check IWDG window value.
217 * @param __WINDOW__ IWDG window value
220 #define IS_IWDG_WINDOW(__WINDOW__) ((__WINDOW__) <= IWDG_WINR_WIN)
240 #endif /* STM32H7xx_HAL_IWDG_H */
242 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/