01. IWDG概述% f+ n- Q3 M& z
stm32f4xx_iwdg.h和stm32f4xx_iwdg.c文件中
" M& e* Y: a! g5 F, M5 ^9 C5 g3 s
b: I" i P! w02. 相关类型! Y2 I2 F4 X# u" B* e5 b# U
IWDG_WriteAccess- /** @defgroup IWDG_WriteAccess6 w2 v. x: V6 e$ w* K: q) O
- * @{
: z C; \8 l: g0 B3 m5 g - */
4 i; S4 l" K: T; O. z# R9 _ - #define IWDG_WriteAccess_Enable ((uint16_t)0x5555)7 d0 m M' \3 W$ e, i; G' X. L& ^
- #define IWDG_WriteAccess_Disable ((uint16_t)0x0000)4 U: }( n4 E- s6 ^- ?, ]/ J
- #define IS_IWDG_WRITE_ACCESS(ACCESS) (((ACCESS) == IWDG_WriteAccess_Enable) || \
. r. d+ ]" N* Q - ((ACCESS) == IWDG_WriteAccess_Disable))
复制代码
! G0 \+ a% R) O% _$ r& Y+ o: @IWDG_prescaler
' ?3 r h5 Y* Q3 I
A) l/ R7 h) H( y- /** @defgroup IWDG_prescaler . c5 D0 F) H. u% U
- * @{
9 z: i( R4 {: |' ^" j - */* f; Y1 W7 |/ M6 ]; @2 E- ]$ Z
- #define IWDG_Prescaler_4 ((uint8_t)0x00)
3 Q% ?7 T# E: z4 b0 K) x1 M- ` - #define IWDG_Prescaler_8 ((uint8_t)0x01)
0 v% _( c3 Z) \) ~ - #define IWDG_Prescaler_16 ((uint8_t)0x02)
( k- f: ? N& b9 [+ d& |- c: N$ [7 r - #define IWDG_Prescaler_32 ((uint8_t)0x03)2 B! @0 i* Z2 M) H% l) {7 ^; Q7 G" b2 P
- #define IWDG_Prescaler_64 ((uint8_t)0x04)& G7 A2 u/ a7 K# [5 n: U& w
- #define IWDG_Prescaler_128 ((uint8_t)0x05)& Y3 o; x1 Y: M, d
- #define IWDG_Prescaler_256 ((uint8_t)0x06)' B+ j; |- B( P
- #define IS_IWDG_PRESCALER(PRESCALER) (((PRESCALER) == IWDG_Prescaler_4) || \4 `) r) P9 G+ y
- ((PRESCALER) == IWDG_Prescaler_8) || \
8 A. t" b2 M" ~( d, T# {: E2 _ - ((PRESCALER) == IWDG_Prescaler_16) || \
% k% x( H6 N: a; f0 E - ((PRESCALER) == IWDG_Prescaler_32) || \
! n9 Y# Q% {/ v4 j* e3 S - ((PRESCALER) == IWDG_Prescaler_64) || \8 l# n k. ^! f, a+ t" b9 Z
- ((PRESCALER) == IWDG_Prescaler_128)|| \
8 t- m2 x3 f: ]% S$ c - ((PRESCALER) == IWDG_Prescaler_256))
复制代码 6 C" B: r# |; P+ w
IWDG_Flag2 _- T; ?! k( g. R% H; W/ y0 _2 `
5 x* Z: s5 {0 g. M# v- T
- /** @defgroup IWDG_Flag
7 ~" f( g7 G$ J, m, ]0 G0 ~7 q+ t - * @{& Y3 O- [9 c+ e8 k" V0 J
- */+ ^. o% i6 F) v8 e) F# r
- #define IWDG_FLAG_PVU ((uint16_t)0x0001)
" D- b7 B; V/ ~ - #define IWDG_FLAG_RVU ((uint16_t)0x0002) R0 Q9 x( M0 x5 |& P: [
- #define IS_IWDG_FLAG(FLAG) (((FLAG) == IWDG_FLAG_PVU) || ((FLAG) == IWDG_FLAG_RVU))
' A! g- y$ [/ K: z& i/ _ - #define IS_IWDG_RELOAD(RELOAD) ((RELOAD) <= 0xFFF)
复制代码
* Y0 S! _- ~3 X" m1 d0 b B03. 相关函数
9 d4 `5 u+ Q" t- /* Exported macro ------------------------------------------------------------*/
3 D8 B0 o8 R* c% t( G) } - /* Exported functions --------------------------------------------------------*/; c) f1 H3 ^& A, ~+ H+ n$ b- w
8 x7 q$ g1 @- l2 w# b3 }3 ?& ^" q- /* Prescaler and Counter configuration functions ******************************// ^* R# T/ _! k. }2 r' X0 d
- void IWDG_WriteAccessCmd(uint16_t IWDG_WriteAccess);% [& e W: t0 Y' s
- void IWDG_SetPrescaler(uint8_t IWDG_Prescaler);
6 L) A' s0 F( z& E - void IWDG_SetReload(uint16_t Reload);
: _: H" {4 d' L! T7 y' L' y3 s2 w/ w- V - void IWDG_ReloadCounter(void);$ Z" R; h1 ]+ E0 N/ D; U
- , q, W! y/ F* t2 f
- /* IWDG activation function ***************************************************/
C5 Y2 O) i8 C$ C - void IWDG_Enable(void);6 e+ [# ?- V N y4 l
; H9 D0 |2 |7 y/ o( C4 [3 M% S- /* Flag management function ***************************************************/3 u7 N) \/ G# C
- FlagStatus IWDG_GetFlagStatus(uint16_t IWDG_FLAG);
复制代码
# i- L0 u+ w) ^. A04. 结构体封装1 J/ W3 C, a w9 L3 q/ T/ b; e
- /** ' c/ e0 u+ [# [
- * @brief Independent WATCHDOG) `6 F+ v* k2 b( d" `: V
- */0 Q" y% L0 d5 u8 \% a4 R
- * s9 m* f$ h3 }( P' B
- typedef struct8 R% ?0 M+ y) _5 h, K( M0 ?5 r
- {2 J( y( g8 E& N# z# C# k
- __IO uint32_t KR; /*!< IWDG Key register, Address offset: 0x00 */
+ n) H3 E) U* L3 z- R) v; R - __IO uint32_t PR; /*!< IWDG Prescaler register, Address offset: 0x04 */
. \. ^$ ?3 W5 N9 s! I - __IO uint32_t RLR; /*!< IWDG Reload register, Address offset: 0x08 */" r; R* C, u% |
- __IO uint32_t SR; /*!< IWDG Status register, Address offset: 0x0C */
+ @0 _1 f7 u8 C* f: q8 n) w7 R - } IWDG_TypeDef;
复制代码 2 h4 }0 D" G8 x" b0 O
|