提交 | 用户 | age
|
483170
|
1 |
/** |
Q |
2 |
****************************************************************************** |
|
3 |
* @file stm32f0xx_ll_iwdg.h |
|
4 |
* @author MCD Application Team |
|
5 |
* @brief Header file of IWDG LL module. |
|
6 |
****************************************************************************** |
|
7 |
* @attention |
|
8 |
* |
|
9 |
* <h2><center>© COPYRIGHT(c) 2016 STMicroelectronics</center></h2> |
|
10 |
* |
|
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. |
|
21 |
* |
|
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. |
|
32 |
* |
|
33 |
****************************************************************************** |
|
34 |
*/ |
|
35 |
|
|
36 |
/* Define to prevent recursive inclusion -------------------------------------*/ |
|
37 |
#ifndef __STM32F0xx_LL_IWDG_H |
|
38 |
#define __STM32F0xx_LL_IWDG_H |
|
39 |
|
|
40 |
#ifdef __cplusplus |
|
41 |
extern "C" { |
|
42 |
#endif |
|
43 |
|
|
44 |
/* Includes ------------------------------------------------------------------*/ |
|
45 |
#include "stm32f0xx.h" |
|
46 |
|
|
47 |
/** @addtogroup STM32F0xx_LL_Driver |
|
48 |
* @{ |
|
49 |
*/ |
|
50 |
|
|
51 |
#if defined(IWDG) |
|
52 |
|
|
53 |
/** @defgroup IWDG_LL IWDG |
|
54 |
* @{ |
|
55 |
*/ |
|
56 |
|
|
57 |
/* Private types -------------------------------------------------------------*/ |
|
58 |
/* Private variables ---------------------------------------------------------*/ |
|
59 |
|
|
60 |
/* Private constants ---------------------------------------------------------*/ |
|
61 |
/** @defgroup IWDG_LL_Private_Constants IWDG Private Constants |
|
62 |
* @{ |
|
63 |
*/ |
|
64 |
|
|
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 */ |
|
69 |
|
|
70 |
/** |
|
71 |
* @} |
|
72 |
*/ |
|
73 |
|
|
74 |
/* Private macros ------------------------------------------------------------*/ |
|
75 |
|
|
76 |
/* Exported types ------------------------------------------------------------*/ |
|
77 |
/* Exported constants --------------------------------------------------------*/ |
|
78 |
/** @defgroup IWDG_LL_Exported_Constants IWDG Exported Constants |
|
79 |
* @{ |
|
80 |
*/ |
|
81 |
|
|
82 |
/** @defgroup IWDG_LL_EC_GET_FLAG Get Flags Defines |
|
83 |
* @brief Flags defines which can be used with LL_IWDG_ReadReg function |
|
84 |
* @{ |
|
85 |
*/ |
|
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 */ |
|
89 |
|
|
90 |
/** |
|
91 |
* @} |
|
92 |
*/ |
|
93 |
|
|
94 |
/** @defgroup IWDG_LL_EC_PRESCALER Prescaler Divider |
|
95 |
* @{ |
|
96 |
*/ |
|
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 */ |
|
104 |
/** |
|
105 |
* @} |
|
106 |
*/ |
|
107 |
|
|
108 |
/** |
|
109 |
* @} |
|
110 |
*/ |
|
111 |
|
|
112 |
/* Exported macro ------------------------------------------------------------*/ |
|
113 |
/** @defgroup IWDG_LL_Exported_Macros IWDG Exported Macros |
|
114 |
* @{ |
|
115 |
*/ |
|
116 |
|
|
117 |
/** @defgroup IWDG_LL_EM_WRITE_READ Common Write and read registers Macros |
|
118 |
* @{ |
|
119 |
*/ |
|
120 |
|
|
121 |
/** |
|
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 |
|
127 |
*/ |
|
128 |
#define LL_IWDG_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG(__INSTANCE__->__REG__, (__VALUE__)) |
|
129 |
|
|
130 |
/** |
|
131 |
* @brief Read a value in IWDG register |
|
132 |
* @param __INSTANCE__ IWDG Instance |
|
133 |
* @param __REG__ Register to be read |
|
134 |
* @retval Register value |
|
135 |
*/ |
|
136 |
#define LL_IWDG_ReadReg(__INSTANCE__, __REG__) READ_REG(__INSTANCE__->__REG__) |
|
137 |
/** |
|
138 |
* @} |
|
139 |
*/ |
|
140 |
|
|
141 |
/** |
|
142 |
* @} |
|
143 |
*/ |
|
144 |
|
|
145 |
|
|
146 |
/* Exported functions --------------------------------------------------------*/ |
|
147 |
/** @defgroup IWDG_LL_Exported_Functions IWDG Exported Functions |
|
148 |
* @{ |
|
149 |
*/ |
|
150 |
/** @defgroup IWDG_LL_EF_Configuration Configuration |
|
151 |
* @{ |
|
152 |
*/ |
|
153 |
|
|
154 |
/** |
|
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 |
|
160 |
*/ |
|
161 |
__STATIC_INLINE void LL_IWDG_Enable(IWDG_TypeDef *IWDGx) |
|
162 |
{ |
|
163 |
WRITE_REG(IWDG->KR, LL_IWDG_KEY_ENABLE); |
|
164 |
} |
|
165 |
|
|
166 |
/** |
|
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 |
|
171 |
*/ |
|
172 |
__STATIC_INLINE void LL_IWDG_ReloadCounter(IWDG_TypeDef *IWDGx) |
|
173 |
{ |
|
174 |
WRITE_REG(IWDG->KR, LL_IWDG_KEY_RELOAD); |
|
175 |
} |
|
176 |
|
|
177 |
/** |
|
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 |
|
182 |
*/ |
|
183 |
__STATIC_INLINE void LL_IWDG_EnableWriteAccess(IWDG_TypeDef *IWDGx) |
|
184 |
{ |
|
185 |
WRITE_REG(IWDG->KR, LL_IWDG_KEY_WR_ACCESS_ENABLE); |
|
186 |
} |
|
187 |
|
|
188 |
/** |
|
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 |
|
193 |
*/ |
|
194 |
__STATIC_INLINE void LL_IWDG_DisableWriteAccess(IWDG_TypeDef *IWDGx) |
|
195 |
{ |
|
196 |
WRITE_REG(IWDG->KR, LL_IWDG_KEY_WR_ACCESS_DISABLE); |
|
197 |
} |
|
198 |
|
|
199 |
/** |
|
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 |
|
212 |
*/ |
|
213 |
__STATIC_INLINE void LL_IWDG_SetPrescaler(IWDG_TypeDef *IWDGx, uint32_t Prescaler) |
|
214 |
{ |
|
215 |
WRITE_REG(IWDGx->PR, IWDG_PR_PR & Prescaler); |
|
216 |
} |
|
217 |
|
|
218 |
/** |
|
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 |
|
230 |
*/ |
|
231 |
__STATIC_INLINE uint32_t LL_IWDG_GetPrescaler(IWDG_TypeDef *IWDGx) |
|
232 |
{ |
|
233 |
return (uint32_t)(READ_REG(IWDGx->PR)); |
|
234 |
} |
|
235 |
|
|
236 |
/** |
|
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 |
|
242 |
*/ |
|
243 |
__STATIC_INLINE void LL_IWDG_SetReloadCounter(IWDG_TypeDef *IWDGx, uint32_t Counter) |
|
244 |
{ |
|
245 |
WRITE_REG(IWDGx->RLR, IWDG_RLR_RL & Counter); |
|
246 |
} |
|
247 |
|
|
248 |
/** |
|
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 |
|
253 |
*/ |
|
254 |
__STATIC_INLINE uint32_t LL_IWDG_GetReloadCounter(IWDG_TypeDef *IWDGx) |
|
255 |
{ |
|
256 |
return (uint32_t)(READ_REG(IWDGx->RLR)); |
|
257 |
} |
|
258 |
|
|
259 |
/** |
|
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 |
|
265 |
*/ |
|
266 |
__STATIC_INLINE void LL_IWDG_SetWindow(IWDG_TypeDef *IWDGx, uint32_t Window) |
|
267 |
{ |
|
268 |
WRITE_REG(IWDGx->WINR, IWDG_WINR_WIN & Window); |
|
269 |
} |
|
270 |
|
|
271 |
/** |
|
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 |
|
276 |
*/ |
|
277 |
__STATIC_INLINE uint32_t LL_IWDG_GetWindow(IWDG_TypeDef *IWDGx) |
|
278 |
{ |
|
279 |
return (uint32_t)(READ_REG(IWDGx->WINR)); |
|
280 |
} |
|
281 |
|
|
282 |
/** |
|
283 |
* @} |
|
284 |
*/ |
|
285 |
|
|
286 |
/** @defgroup IWDG_LL_EF_FLAG_Management FLAG_Management |
|
287 |
* @{ |
|
288 |
*/ |
|
289 |
|
|
290 |
/** |
|
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). |
|
295 |
*/ |
|
296 |
__STATIC_INLINE uint32_t LL_IWDG_IsActiveFlag_PVU(IWDG_TypeDef *IWDGx) |
|
297 |
{ |
|
298 |
return (READ_BIT(IWDGx->SR, IWDG_SR_PVU) == (IWDG_SR_PVU)); |
|
299 |
} |
|
300 |
|
|
301 |
/** |
|
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). |
|
306 |
*/ |
|
307 |
__STATIC_INLINE uint32_t LL_IWDG_IsActiveFlag_RVU(IWDG_TypeDef *IWDGx) |
|
308 |
{ |
|
309 |
return (READ_BIT(IWDGx->SR, IWDG_SR_RVU) == (IWDG_SR_RVU)); |
|
310 |
} |
|
311 |
|
|
312 |
/** |
|
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). |
|
317 |
*/ |
|
318 |
__STATIC_INLINE uint32_t LL_IWDG_IsActiveFlag_WVU(IWDG_TypeDef *IWDGx) |
|
319 |
{ |
|
320 |
return (READ_BIT(IWDGx->SR, IWDG_SR_WVU) == (IWDG_SR_WVU)); |
|
321 |
} |
|
322 |
|
|
323 |
/** |
|
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). |
|
330 |
*/ |
|
331 |
__STATIC_INLINE uint32_t LL_IWDG_IsReady(IWDG_TypeDef *IWDGx) |
|
332 |
{ |
|
333 |
return (READ_BIT(IWDGx->SR, IWDG_SR_PVU | IWDG_SR_RVU | IWDG_SR_WVU) == 0U); |
|
334 |
} |
|
335 |
|
|
336 |
/** |
|
337 |
* @} |
|
338 |
*/ |
|
339 |
|
|
340 |
|
|
341 |
/** |
|
342 |
* @} |
|
343 |
*/ |
|
344 |
|
|
345 |
/** |
|
346 |
* @} |
|
347 |
*/ |
|
348 |
|
|
349 |
#endif /* IWDG) */ |
|
350 |
|
|
351 |
/** |
|
352 |
* @} |
|
353 |
*/ |
|
354 |
|
|
355 |
#ifdef __cplusplus |
|
356 |
} |
|
357 |
#endif |
|
358 |
|
|
359 |
#endif /* __STM32F0xx_LL_IWDG_H */ |
|
360 |
|
|
361 |
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |