2 ******************************************************************************
3 * @file stm32f3xx_hal_iwdg.h
4 * @author MCD Application Team
5 * @brief Header file of IWDG HAL module.
6 ******************************************************************************
9 * <h2><center>© 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_HAL_IWDG_H
38 #define __STM32F3xx_HAL_IWDG_H
44 /* Includes ------------------------------------------------------------------*/
45 #include "stm32f3xx_hal_def.h"
47 /** @addtogroup STM32F3xx_HAL_Driver
51 /** @defgroup IWDG IWDG
55 /* Exported types ------------------------------------------------------------*/
56 /** @defgroup IWDG_Exported_Types IWDG Exported Types
61 * @brief IWDG Init structure definition
65 uint32_t Prescaler
; /*!< Select the prescaler of the IWDG.
66 This parameter can be a value of @ref IWDG_Prescaler */
68 uint32_t Reload
; /*!< Specifies the IWDG down-counter reload value.
69 This parameter must be a number between Min_Data = 0 and Max_Data = 0x0FFFU */
71 uint32_t Window
; /*!< Specifies the window value to be compared to the down-counter.
72 This parameter must be a number between Min_Data = 0 and Max_Data = 0x0FFFU */
77 * @brief IWDG Handle Structure definition
81 IWDG_TypeDef
*Instance
; /*!< Register base address */
83 IWDG_InitTypeDef Init
; /*!< IWDG required parameters */
91 /* Exported constants --------------------------------------------------------*/
92 /** @defgroup IWDG_Exported_Constants IWDG Exported Constants
96 /** @defgroup IWDG_Prescaler IWDG Prescaler
99 #define IWDG_PRESCALER_4 0x00000000u /*!< IWDG prescaler set to 4 */
100 #define IWDG_PRESCALER_8 IWDG_PR_PR_0 /*!< IWDG prescaler set to 8 */
101 #define IWDG_PRESCALER_16 IWDG_PR_PR_1 /*!< IWDG prescaler set to 16 */
102 #define IWDG_PRESCALER_32 (IWDG_PR_PR_1 | IWDG_PR_PR_0) /*!< IWDG prescaler set to 32 */
103 #define IWDG_PRESCALER_64 IWDG_PR_PR_2 /*!< IWDG prescaler set to 64 */
104 #define IWDG_PRESCALER_128 (IWDG_PR_PR_2 | IWDG_PR_PR_0) /*!< IWDG prescaler set to 128U */
105 #define IWDG_PRESCALER_256 (IWDG_PR_PR_2 | IWDG_PR_PR_1) /*!< IWDG prescaler set to 256U */
110 /** @defgroup IWDG_Window_option IWDG Window option
113 #define IWDG_WINDOW_DISABLE IWDG_WINR_WIN
122 /* Exported macros -----------------------------------------------------------*/
123 /** @defgroup IWDG_Exported_Macros IWDG Exported Macros
128 * @brief Enable the IWDG peripheral.
129 * @param __HANDLE__ IWDG handle
132 #define __HAL_IWDG_START(__HANDLE__) WRITE_REG((__HANDLE__)->Instance->KR, IWDG_KEY_ENABLE)
135 * @brief Reload IWDG counter with value defined in the reload register
136 * (write access to IWDG_PR, IWDG_RLR & IWDG_WINR registers disabled).
137 * @param __HANDLE__ IWDG handle
140 #define __HAL_IWDG_RELOAD_COUNTER(__HANDLE__) WRITE_REG((__HANDLE__)->Instance->KR, IWDG_KEY_RELOAD)
146 /* Exported functions --------------------------------------------------------*/
147 /** @defgroup IWDG_Exported_Functions IWDG Exported Functions
151 /** @defgroup IWDG_Exported_Functions_Group1 Initialization and Start functions
154 /* Initialization/Start functions ********************************************/
155 HAL_StatusTypeDef
HAL_IWDG_Init(IWDG_HandleTypeDef
*hiwdg
);
160 /** @defgroup IWDG_Exported_Functions_Group2 IO operation functions
163 /* I/O operation functions ****************************************************/
164 HAL_StatusTypeDef
HAL_IWDG_Refresh(IWDG_HandleTypeDef
*hiwdg
);
173 /* Private constants ---------------------------------------------------------*/
174 /** @defgroup IWDG_Private_Constants IWDG Private Constants
178 * @brief IWDG Key Register BitMask
180 #define IWDG_KEY_RELOAD 0x0000AAAAu /*!< IWDG Reload Counter Enable */
181 #define IWDG_KEY_ENABLE 0x0000CCCCu /*!< IWDG Peripheral Enable */
182 #define IWDG_KEY_WRITE_ACCESS_ENABLE 0x00005555u /*!< IWDG KR Write Access Enable */
183 #define IWDG_KEY_WRITE_ACCESS_DISABLE 0x00000000u /*!< IWDG KR Write Access Disable */
189 /* Private macros ------------------------------------------------------------*/
190 /** @defgroup IWDG_Private_Macros IWDG Private Macros
194 * @brief Enable write access to IWDG_PR, IWDG_RLR and IWDG_WINR registers.
195 * @param __HANDLE__ IWDG handle
198 #define IWDG_ENABLE_WRITE_ACCESS(__HANDLE__) WRITE_REG((__HANDLE__)->Instance->KR, IWDG_KEY_WRITE_ACCESS_ENABLE)
201 * @brief Disable write access to IWDG_PR, IWDG_RLR and IWDG_WINR registers.
202 * @param __HANDLE__ IWDG handle
205 #define IWDG_DISABLE_WRITE_ACCESS(__HANDLE__) WRITE_REG((__HANDLE__)->Instance->KR, IWDG_KEY_WRITE_ACCESS_DISABLE)
208 * @brief Check IWDG prescaler value.
209 * @param __PRESCALER__ IWDG prescaler value
212 #define IS_IWDG_PRESCALER(__PRESCALER__) (((__PRESCALER__) == IWDG_PRESCALER_4) || \
213 ((__PRESCALER__) == IWDG_PRESCALER_8) || \
214 ((__PRESCALER__) == IWDG_PRESCALER_16) || \
215 ((__PRESCALER__) == IWDG_PRESCALER_32) || \
216 ((__PRESCALER__) == IWDG_PRESCALER_64) || \
217 ((__PRESCALER__) == IWDG_PRESCALER_128)|| \
218 ((__PRESCALER__) == IWDG_PRESCALER_256))
221 * @brief Check IWDG reload value.
222 * @param __RELOAD__ IWDG reload value
225 #define IS_IWDG_RELOAD(__RELOAD__) ((__RELOAD__) <= IWDG_RLR_RL)
228 * @brief Check IWDG window value.
229 * @param __WINDOW__ IWDG window value
232 #define IS_IWDG_WINDOW(__WINDOW__) ((__WINDOW__) <= IWDG_WINR_WIN)
251 #endif /* __STM32F3xx_HAL_IWDG_H */
253 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/