01. IWDG概述
1 b+ z1 ]5 e! M bstm32f4xx_iwdg.h和stm32f4xx_iwdg.c文件中
! Q) C/ f/ G, C! u! r5 ^) O" {9 C% q% f% M5 t: |0 J( v
02. 相关类型2 N" l, M/ L/ b- W l
IWDG_WriteAccess- /** @defgroup IWDG_WriteAccess5 H5 K# e, n7 [, b' X
- * @{8 f R- P/ |5 T* \
- */
4 x$ i* ^1 r( q - #define IWDG_WriteAccess_Enable ((uint16_t)0x5555)
- \/ ]# w1 w, A& z: e - #define IWDG_WriteAccess_Disable ((uint16_t)0x0000)
` H% d8 t, X+ R' M3 q0 A - #define IS_IWDG_WRITE_ACCESS(ACCESS) (((ACCESS) == IWDG_WriteAccess_Enable) || \8 _' K& c' a7 I x! `, z
- ((ACCESS) == IWDG_WriteAccess_Disable))
复制代码 9 R( D: H4 ^; f
IWDG_prescaler
7 d* V6 o; v' e* D% X6 S8 A( O! k
) Q$ T6 y- P* }- /** @defgroup IWDG_prescaler % p, J) ^2 ?$ ?. Y3 v8 z. R$ `& Q
- * @{
+ H' f5 o d& D1 F; L/ M - */
2 J. C% p7 A( \/ ~9 \5 N& H2 ?2 W9 P - #define IWDG_Prescaler_4 ((uint8_t)0x00)! w6 O+ z, U1 _ l
- #define IWDG_Prescaler_8 ((uint8_t)0x01)
5 I* p9 p8 x5 e+ b6 z+ Y - #define IWDG_Prescaler_16 ((uint8_t)0x02)& G4 D, K$ m5 b" X$ w# i$ y8 w
- #define IWDG_Prescaler_32 ((uint8_t)0x03)! S8 r: R6 x8 V
- #define IWDG_Prescaler_64 ((uint8_t)0x04)
; S7 }7 b M: b) r. ]& n3 u2 v; ? - #define IWDG_Prescaler_128 ((uint8_t)0x05)
9 h3 A6 y! {3 |' Q! o# M0 }2 j - #define IWDG_Prescaler_256 ((uint8_t)0x06)' D/ g. _# _: `+ J7 [. Y8 l/ K( L& Z& u
- #define IS_IWDG_PRESCALER(PRESCALER) (((PRESCALER) == IWDG_Prescaler_4) || \
+ R& W+ q# X% |8 N( X - ((PRESCALER) == IWDG_Prescaler_8) || \" L T4 S# d$ z5 u# L w# e
- ((PRESCALER) == IWDG_Prescaler_16) || \' G7 p9 j1 R! F! B6 ]
- ((PRESCALER) == IWDG_Prescaler_32) || \0 x' E2 M/ d4 p$ Y
- ((PRESCALER) == IWDG_Prescaler_64) || \
; i$ n% L, v! O4 y8 K) m - ((PRESCALER) == IWDG_Prescaler_128)|| \
9 B* a4 J3 y# ^- l3 C3 p - ((PRESCALER) == IWDG_Prescaler_256))
复制代码
9 G1 e: b' r- M$ jIWDG_Flag
$ X/ r$ k2 h% j* G4 _1 ?5 K8 f) _
- /** @defgroup IWDG_Flag
" C) w1 A# t+ _! S) |# ^& K! D - * @{
* \; E# m- G: n" B6 Z2 ?6 [8 e - */
7 A. t4 w$ z5 C! P& `" Y - #define IWDG_FLAG_PVU ((uint16_t)0x0001)/ x8 J1 P6 W* }
- #define IWDG_FLAG_RVU ((uint16_t)0x0002)! [% r/ C2 X) h' x* ~1 L
- #define IS_IWDG_FLAG(FLAG) (((FLAG) == IWDG_FLAG_PVU) || ((FLAG) == IWDG_FLAG_RVU))/ Z+ l. M' c" S- E
- #define IS_IWDG_RELOAD(RELOAD) ((RELOAD) <= 0xFFF)
复制代码
, b' i! N1 @! C) |7 R03. 相关函数
/ \+ P/ Z( C- m* o* |: R2 `3 A2 \- /* Exported macro ------------------------------------------------------------*/. b# z- N8 G! T& F5 n
- /* Exported functions --------------------------------------------------------*/
. Z b* L0 H: [& A - O* l$ \% ?$ n: ^$ k" W" h8 j; R3 H4 u
- /* Prescaler and Counter configuration functions ******************************/ K. K; u3 a) q- E2 w
- void IWDG_WriteAccessCmd(uint16_t IWDG_WriteAccess);
# m- w% E, G- D. ], @ - void IWDG_SetPrescaler(uint8_t IWDG_Prescaler);
6 T2 i! L q( G/ d. n - void IWDG_SetReload(uint16_t Reload);
/ m% ~/ R6 B7 S - void IWDG_ReloadCounter(void);
7 G$ \& F- I* e) }- e% J9 z. G
4 j( o$ J4 s+ m- /* IWDG activation function ***************************************************/
# V8 ]6 v8 T7 x" j; X - void IWDG_Enable(void);
4 y, _( w1 Q! D' F% p+ B3 @6 Q) R
g+ x2 Z9 Z) J7 I- /* Flag management function ***************************************************// R* \0 r( R- c5 l
- FlagStatus IWDG_GetFlagStatus(uint16_t IWDG_FLAG);
复制代码
9 s5 `# z# x& J6 g% \5 b5 P+ G04. 结构体封装: w' t# X" v; ?8 @
- /** 9 Z+ y, D$ a' s7 j
- * @brief Independent WATCHDOG
% d+ Y( A+ a8 _4 g - */
. c3 U! J4 v) o2 N/ t4 k- w - + t2 G* S b4 `3 |
- typedef struct
4 e- ]5 y& f- z0 H" L) Q - {
7 N4 D5 R1 |5 e; Y3 p - __IO uint32_t KR; /*!< IWDG Key register, Address offset: 0x00 */
3 ?. U- w( g6 \3 w4 X, e( |2 X - __IO uint32_t PR; /*!< IWDG Prescaler register, Address offset: 0x04 */
5 A! I4 n) w/ G& B% N - __IO uint32_t RLR; /*!< IWDG Reload register, Address offset: 0x08 */1 B# @% v3 V) ]8 U3 k
- __IO uint32_t SR; /*!< IWDG Status register, Address offset: 0x0C *// R" {+ p q7 V' A. ?& t! x
- } IWDG_TypeDef;
复制代码 $ Z, z6 A9 B) w1 k1 Y' |- Y
|