source: trunk/firmware/Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_hal_iwdg.h

Last change on this file was 6, checked in by f.jahn, 8 months ago
File size: 7.4 KB
Line 
1/**
2 ******************************************************************************
3 * @file stm32g0xx_hal_iwdg.h
4 * @author MCD Application Team
5 * @brief Header file of IWDG HAL module.
6 ******************************************************************************
7 * @attention
8 *
9 * <h2><center>&copy; Copyright (c) 2018 STMicroelectronics.
10 * All rights reserved.</center></h2>
11 *
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
16 *
17 ******************************************************************************
18 */
19
20/* Define to prevent recursive inclusion -------------------------------------*/
21#ifndef STM32G0xx_HAL_IWDG_H
22#define STM32G0xx_HAL_IWDG_H
23
24#ifdef __cplusplus
25extern "C" {
26#endif
27
28/* Includes ------------------------------------------------------------------*/
29#include "stm32g0xx_hal_def.h"
30
31/** @addtogroup STM32G0xx_HAL_Driver
32 * @{
33 */
34
35/** @defgroup IWDG IWDG
36 * @{
37 */
38
39/* Exported types ------------------------------------------------------------*/
40/** @defgroup IWDG_Exported_Types IWDG Exported Types
41 * @{
42 */
43
44/**
45 * @brief IWDG Init structure definition
46 */
47typedef struct
48{
49 uint32_t Prescaler; /*!< Select the prescaler of the IWDG.
50 This parameter can be a value of @ref IWDG_Prescaler */
51
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 */
54
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 */
57
58} IWDG_InitTypeDef;
59
60/**
61 * @brief IWDG Handle Structure definition
62 */
63typedef struct
64{
65 IWDG_TypeDef *Instance; /*!< Register base address */
66
67 IWDG_InitTypeDef Init; /*!< IWDG required parameters */
68} IWDG_HandleTypeDef;
69
70
71/**
72 * @}
73 */
74
75/* Exported constants --------------------------------------------------------*/
76/** @defgroup IWDG_Exported_Constants IWDG Exported Constants
77 * @{
78 */
79
80/** @defgroup IWDG_Prescaler IWDG Prescaler
81 * @{
82 */
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 */
90
91/**
92 * @}
93 */
94
95/** @defgroup IWDG_Window_option IWDG Window option
96 * @{
97 */
98#define IWDG_WINDOW_DISABLE IWDG_WINR_WIN
99/**
100 * @}
101 */
102
103
104/**
105 * @}
106 */
107
108/* Exported macros -----------------------------------------------------------*/
109/** @defgroup IWDG_Exported_Macros IWDG Exported Macros
110 * @{
111 */
112
113/**
114 * @brief Enable the IWDG peripheral.
115 * @param __HANDLE__ IWDG handle
116 * @retval None
117 */
118#define __HAL_IWDG_START(__HANDLE__) WRITE_REG((__HANDLE__)->Instance->KR, IWDG_KEY_ENABLE)
119
120/**
121 * @brief Reload IWDG counter with value defined in the reload register
122 * (write access to IWDG_PR, IWDG_RLR & IWDG_WINR registers disabled).
123 * @param __HANDLE__ IWDG handle
124 * @retval None
125 */
126#define __HAL_IWDG_RELOAD_COUNTER(__HANDLE__) WRITE_REG((__HANDLE__)->Instance->KR, IWDG_KEY_RELOAD)
127
128/**
129 * @}
130 */
131
132/* Exported functions --------------------------------------------------------*/
133/** @defgroup IWDG_Exported_Functions IWDG Exported Functions
134 * @{
135 */
136
137/** @defgroup IWDG_Exported_Functions_Group1 Initialization and Start functions
138 * @{
139 */
140/* Initialization/Start functions ********************************************/
141HAL_StatusTypeDef HAL_IWDG_Init(IWDG_HandleTypeDef *hiwdg);
142/**
143 * @}
144 */
145
146/** @defgroup IWDG_Exported_Functions_Group2 IO operation functions
147 * @{
148 */
149/* I/O operation functions ****************************************************/
150HAL_StatusTypeDef HAL_IWDG_Refresh(IWDG_HandleTypeDef *hiwdg);
151/**
152 * @}
153 */
154
155/**
156 * @}
157 */
158
159/* Private constants ---------------------------------------------------------*/
160/** @defgroup IWDG_Private_Constants IWDG Private Constants
161 * @{
162 */
163
164/**
165 * @brief IWDG Key Register BitMask
166 */
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 */
171
172/**
173 * @}
174 */
175
176/* Private macros ------------------------------------------------------------*/
177/** @defgroup IWDG_Private_Macros IWDG Private Macros
178 * @{
179 */
180
181/**
182 * @brief Enable write access to IWDG_PR, IWDG_RLR and IWDG_WINR registers.
183 * @param __HANDLE__ IWDG handle
184 * @retval None
185 */
186#define IWDG_ENABLE_WRITE_ACCESS(__HANDLE__) WRITE_REG((__HANDLE__)->Instance->KR, IWDG_KEY_WRITE_ACCESS_ENABLE)
187
188/**
189 * @brief Disable write access to IWDG_PR, IWDG_RLR and IWDG_WINR registers.
190 * @param __HANDLE__ IWDG handle
191 * @retval None
192 */
193#define IWDG_DISABLE_WRITE_ACCESS(__HANDLE__) WRITE_REG((__HANDLE__)->Instance->KR, IWDG_KEY_WRITE_ACCESS_DISABLE)
194
195/**
196 * @brief Check IWDG prescaler value.
197 * @param __PRESCALER__ IWDG prescaler value
198 * @retval None
199 */
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))
207
208/**
209 * @brief Check IWDG reload value.
210 * @param __RELOAD__ IWDG reload value
211 * @retval None
212 */
213#define IS_IWDG_RELOAD(__RELOAD__) ((__RELOAD__) <= IWDG_RLR_RL)
214
215/**
216 * @brief Check IWDG window value.
217 * @param __WINDOW__ IWDG window value
218 * @retval None
219 */
220#define IS_IWDG_WINDOW(__WINDOW__) ((__WINDOW__) <= IWDG_WINR_WIN)
221
222/**
223 * @}
224 */
225
226/**
227 * @}
228 */
229
230/**
231 * @}
232 */
233
234
235#ifdef __cplusplus
236}
237#endif
238
239#endif /* STM32G0xx_HAL_IWDG_H */
240
241/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
Note: See TracBrowser for help on using the repository browser.