01. WWDG概述3 e% k8 B5 F7 N
stm32f4xx_wwdg.h和 stm32f4xx_wwdg.c文件中。: S% z* {' \5 u9 A) A/ d
8 d0 n$ p6 p# b2 |2 I& K02. 相关类型& b8 Q4 D, ~# o
WWDG_Prescaler% Y3 {! ~1 [$ H- ~
9 E U/ H/ V3 _9 O- M' U+ M
- /** @defgroup WWDG_Prescaler 2 R. ]. u4 {: z( \* D" F& @
- * @{3 @7 ]& C, B) Y& J: A% r
- */, O+ z# \2 C% w2 a1 c6 f" I( s" Z# w5 {
2 v$ b) T0 [; s5 x- M- #define WWDG_Prescaler_1 ((uint32_t)0x00000000)" G8 ~# O1 v+ }% d
- #define WWDG_Prescaler_2 ((uint32_t)0x00000080); @! [# \2 U3 U( q" \9 L
- #define WWDG_Prescaler_4 ((uint32_t)0x00000100)
# o' _: g u% s( W5 y& F3 D - #define WWDG_Prescaler_8 ((uint32_t)0x00000180)# Q* i7 R% T- G; ^
- #define IS_WWDG_PRESCALER(PRESCALER) (((PRESCALER) == WWDG_Prescaler_1) || \
( Z! x% y% U9 t7 P6 K: n - ((PRESCALER) == WWDG_Prescaler_2) || \' A' x7 _) X; y9 Y
- ((PRESCALER) == WWDG_Prescaler_4) || \
6 \4 H, @! S5 f5 H u8 A - ((PRESCALER) == WWDG_Prescaler_8))7 u- E, |% v) j2 j ~8 H
- #define IS_WWDG_WINDOW_VALUE(VALUE) ((VALUE) <= 0x7F)$ P: M/ q: | n8 C6 ?; X
- #define IS_WWDG_COUNTER(COUNTER) (((COUNTER) >= 0x40) && ((COUNTER) <= 0x7F))
复制代码
- K) x. n' \ V3 C8 l+ N6 ~中断处理函数
6 R9 t, n$ F! V" T! _) b) m. V7 n6 F6 x: _* M8 O5 b: J
- WWDG_IRQn = 0, /*!< Window WatchDog Interrupt*/
复制代码
+ \* q" R: z, I0 E9 v! S0 s03. 相关函数
- m' v3 ]# D' X& ~) x- /* Function used to set the WWDG configuration to the default reset state ****/ 1 i* M: |1 z# c5 }2 @) I/ V
- void WWDG_DeInit(void);9 p3 p( x7 S3 {7 [- H# o( Z+ {6 c
- + }+ C# w' r# S' ?) ^7 ^6 x
- /* Prescaler, Refresh window and Counter configuration functions **************/
6 V; R' Z5 y! `* R - void WWDG_SetPrescaler(uint32_t WWDG_Prescaler);
( Y( }! g, l2 P W- I8 x( m5 J - void WWDG_SetWindowValue(uint8_t WindowValue);
( w0 h* F# f1 j# ~) G8 H - void WWDG_EnableIT(void);( k1 k( \2 K" }' h0 B
- void WWDG_SetCounter(uint8_t Counter);
! A* P9 q( ^1 X ~0 T2 l) o0 C
. X5 J8 o9 D+ w4 p. r$ \* h' I- /* WWDG activation function ***************************************************/
; t* P6 |% c* v9 D8 T% q - void WWDG_Enable(uint8_t Counter);$ I3 f7 w& v% X& d: M8 ^( x
8 ?$ L* R! T% \' G, l4 X9 n9 d- /* Interrupts and flags management functions **********************************/
* f' s. ^* E0 `( L; c# ?- c0 ]1 g& F - FlagStatus WWDG_GetFlagStatus(void);" O9 a. R( M' I; ?1 e* x3 p8 ^
- void WWDG_ClearFlag(void);
复制代码
/ A* I. R+ |( p2 j% s! c4 v5 n1 G04. 结构体封装
* N) t( y7 X& C- /**
( c# [8 |+ `* C! G9 F - * @brief Window WATCHDOG
, z2 P, L% ]- ~9 V1 F. p1 k - */
( Q7 N6 e4 o! }/ ?. T
2 X( b) }6 j. z' \7 n" x- typedef struct
1 Q- P2 l; |0 E! e& X4 o - {
& ]/ b) Q, t: @2 s, h - __IO uint32_t CR; /*!< WWDG Control register, Address offset: 0x00 */2 z% W. Z! w! U. p
- __IO uint32_t CFR; /*!< WWDG Configuration register, Address offset: 0x04 */
3 H# n2 K( a$ j( v3 q - __IO uint32_t SR; /*!< WWDG Status register, Address offset: 0x08 */
# c8 y7 ~2 ]3 u. j) Y; x - } WWDG_TypeDef;
复制代码 . F6 h5 r, y; X/ T9 ?3 P
& s0 T9 O7 Y2 f8 O5 o5 y, K
|