/**这里是STM32比较重要的头文件 ; E+ b' @# G4 b4 @
******************************************************************************- v+ O% ^- T( Q( n- j
* @file stm32f10x.h ST 标准的头文件
9 H5 [! h% c3 y/ R7 f+ C: g * @author MCD Application Team 微控制器开发小组。5 L6 {# x9 X: c
* @version V3.5.0 版本
. D- [5 p* {# x; s& K * @date 11-March-2011 2011年3月11
4 ]# G7 g0 I* A( D8 u * @brief CMSIS Cortex-M3 Device Peripheral Access Layer Header File.(CMSIS:Cortex Microcontroller Software Interface Standard) 是 Cortex-M 处理器系列的与供应商无关的硬件抽象层。 , L3 Y# l6 q! Z; \3 z: @7 _
* This file contains all the peripheral register’s definitions, bits
0 Z/ w7 v" d9 b( b/ v/ H * definitions and memory mapping for STM32F10x Connectivity line,
2 Y2 Y, q, f% j- ?; P9 G4 E% J- L! f * High density, High density value line, Medium density, + v9 w2 V+ S) ^/ L O
* Medium density Value line, Low density, Low density Value line $ X2 ]5 n. q& n7 ]: Y4 q8 o
* and XL-density devices.
9 [8 O: G0 `+ ^; m+ I * 这个文件包含了芯片STM32F10X(接口增强型)内部的寄存器定义,位定义,内存地址变换定义,还有一些相应的高密度,低密度产品线的设备。
8 L" {/ ~; L5 u
( J. g9 u) U2 C* The file is the unique include file that the application programmer
+ K; @; A3 C1 I" y8 E" E/ D+ n P * is using in the C source code, usually in main.c. This file contains:6 k/ q) x p8 J! b# p9 y
* - Configuration section that allows to select:
0 s; U+ O2 B- V* F5 Z- c# Z * - The device used in the target application5 @) U- m# M6 x! M. Z2 w1 e8 i
* - To use or not the peripherals drivers in application code(i.e.
$ Y7 u$ M4 l2 U( b0 C6 p2 j" y * code will be based on direct access to peripherals registers + G. D$ R% @) Z3 j# z) v& ]: Z
* rather than drivers API), this option is controlled by ) G$ h0 c+ w p
* “#define USE_STDPERIPH_DRIVER”9 Q$ O0 h' B, e2 o) K
* - To change few application-specific parameters such as the HSE * Z0 S- u- ]& p1 l0 A
* crystal frequency8 ~( |' {+ Z7 ^/ G* I
* - Data structures and the address mapping for all peripherals% u7 p% H2 Z8 a' B" P& T
* - Peripheral’s registers declarations and bits definition
. i8 q. i0 k( D: x b * - Macros to access peripheral registers hardware
! g- n$ Q d% B *这个文件在应用程序中是至关重要的头文件,它是用C代码编写而成。通常包括在MAIN主程序中。它包括:1 设备中使用的目标应用程序。
4 q3 L& b( r4 h* ]5 S2 决定是否使用外部设备的代码(例如使用基于寄存器的代码,而不是我们所熟悉的API应用程序接口代码)。这一设备可以通过设置 ”#define USE_STDPERIPH_DRIVER” 来实现。/ u6 y, k$ S/ ~1 w* P
3 通过这一文件可以改变诸如外部设备的频率参数。& N; P) A9 E$ |
4 可以了解程序的数据结构以及外设的地址映射。
$ v7 ]; Q5 f% k5 外设的寄存器声明和位定义可以在这个文件里面了解到。
2 X& K1 e0 q3 T$ r% A) T2 {3 r" z
******************************************************************************8 V$ z% C+ c, f' n
* @attention( ~* G$ X5 a9 Y0 t' |9 Y
*
2 G$ }2 O9 M7 f) U4 f' { * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS; d1 m# K9 I7 X3 W# ]4 Y9 D
* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
! c7 d0 J+ e* K6 V3 y4 Z! N( Q * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
# y3 ?- j8 E. w * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING7 g6 W/ l8 j* A$ F
* FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE0 }' I9 g- r& X+ u
* CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
$ M3 J$ [" \$ X8 A *注意:这一文件代码供应给用户,旨在帮助用户提升效率节约时间。ST将不会提供任何对于用户自己代码的解释和帮助。也不会解决其在代码中的任何BUG。- t7 H3 H# [: ?0 _4 U9 G
* <h2><center>© COPYRIGHT 2011 STMicroelectronics</center></h2>
& g, j: J1 v8 I% Z& l ******************************************************************************
$ _7 Y$ i1 m1 j& { */+ `: s4 Q& N; l5 Y/ ]
- e5 g3 h( f' A W/** @addtogroup CMSIS
8 y& E) H7 f3 J1 F2 o * @{( _4 A$ @; U& t7 \- [! n5 Z
*/这个不需要关心,只是说明这个文件的作者,公司产品等等,你贴出来的估计是小小的广而告之,这也是程序员的一点小小的特权嘛( I4 @( `4 H: P+ H, |9 X/ `1 D
8 W) v1 ]1 v5 m1 D) Y" s( G
/** @addtogroup stm32f10x- M: d% j! y- B
* @{
1 L0 `; v. F, ~ Q) k: C, y */+ `- w4 N# C: M) Z4 a( C' B
$ Q9 I7 Z9 D* s2 w
#ifndef __STM32F10x_H//如果没有定义__STM32F10x_H ,则定义__STM32F10x_H 9 |0 ]' S9 c! d. T. A
#define __STM32F10x_H
; J1 y( ]( E, E$ b- v, n
: m E( Q. P. L#ifdef __cplusplus//
6 j4 s9 }5 ^! B4 kextern “C” {
# Z# o3 R& G$ H2 S+ f#endif ' l8 N/ Y0 j6 N9 B. M2 P: F
这里是一种条件编译。extern “C”指令非常有用,因为C和C++的近亲关系。注意:extern “C”指令中的C,表示的一种编译和连接规约,而不是一种语言。C表示符合C语言的编译和连接规约的任何语言,如Fortran、assembler等。
3 X+ p+ p( u/ t' w6 }
! X) p, i/ T) S2 |" P* Y+ ~还有要说明的是,extern “C”指令仅指定编译和连接规约,但不影响语义。例如在函数声明中,指定了extern “C”,仍然要遵守C++的类型检测、参数转换规则。/** @addtogroup Library_configuration_section
' x( k* h6 [- f/ q) o! f7 D+ n * @{
: v h+ _& h6 r+ N */
1 h+ j1 o9 a7 l8 h
8 e5 Z% o9 l8 z4 n6 Q! N3 l2 U/* Uncomment the line below according to the target STM32 device used in your
& o: \; r# Z9 B6 B3 I# L application . h6 V" Q% U1 v* C& m! W1 D# S
*/
h6 w, _& c3 Q# k7 P [% _4 N, h% S2 P0 `8 ~4 t( c
#if !defined (STM32F10X_LD) && !defined (STM32F10X_LD_VL) && !defined (STM32F10X_MD) && !defined (STM32F10X_MD_VL) && !defined (STM32F10X_HD) && !defined (STM32F10X_HD_VL) && !defined (STM32F10X_XL) && !defined (STM32F10X_CL) - j/ D8 l* t: |3 R0 c$ d
/* #define STM32F10X_LD */ /*!< STM32F10X_LD: STM32 Low density devices */4 j( Z u& L5 L) B$ A& V6 w
/* #define STM32F10X_LD_VL */ /*!< STM32F10X_LD_VL: STM32 Low density Value Line devices */ 4 m: n, G$ G/ \- x0 a( N
/* #define STM32F10X_MD */ /*!< STM32F10X_MD: STM32 Medium density devices *// C& G5 x1 g0 q; Z5 {) T0 T* i# x' d& ~
/* #define STM32F10X_MD_VL */ /*!< STM32F10X_MD_VL: STM32 Medium density Value Line devices */ . `/ F& \+ a$ Y6 X6 D
/* #define STM32F10X_HD */ /*!< STM32F10X_HD: STM32 High density devices */" B/ G5 {# L. w2 B- D
/* #define STM32F10X_HD_VL */ /*!< STM32F10X_HD_VL: STM32 High density value line devices */
) b, T) o# [! j4 T6 M6 F: n. h# t /* #define STM32F10X_XL */ /*!< STM32F10X_XL: STM32 XL-density devices */
( l, ?8 J3 v7 y5 R+ g" w5 h, _ /* #define STM32F10X_CL */ /*!< STM32F10X_CL: STM32 Connectivity line devices */
$ r& y, p& M7 `#endif
6 ~' k8 d- X+ USTM32启动文件选择:
- M& p) v% [5 g- D/ P: ]- startup_stm32f10x_ld_vl.s: for STM32 Low density Value line devices - startup_stm32f10x_ld.s: for STM32 Low density devices - startup_stm32f10x_md_vl.s: for STM32 Medium density Value line devices - startup_stm32f10x_md.s: for STM32 Medium density devices - startup_stm32f10x_hd.s: for STM32 High density devices - startup_stm32f10x_xl.s: for STM32 XL density devices - startup_stm32f10x_cl.s: for STM32 Connectivity line devices
) x8 Q4 b5 {2 y cl:互联型产品,stm32f105/107系列! {0 u5 E# r/ \( x# `
vl:超值型产品,stm32f100系列 + o$ L4 `- D; _+ `# f, B6 w8 T
xl:超高密度产品,stm32f101/103系列
( {8 _$ ~, E( l; E# ild:低密度产品,FLASH小于64K
3 D$ P- [3 q3 \8 F! M7 ]1 omd:中等密度产品,FLASH=64 or 128% W% \1 ^# i5 H! J. _5 ~
hd:高密度产品,FLASH大于128
( g2 d4 C: A9 [- A+ x+ q3 T$ O/* Tip: To avoid modifying this file each time you need to switch between these; {, _( X0 E$ I* Y) D8 F0 c! `
devices, you can define the device in your toolchain compiler preprocessor.% o) v1 e2 t4 U6 b5 R
提示:为了避免每次编译都要修改这些文件,意思是可以使用编译器的preprocessor选项来定义芯片型号等,免得反复更新这个文件。…
& }" c9 T. n. `8 _: j# w- _- Low-density devices are STM32F101xx, STM32F102xx and STM32F103xx microcontrollers( ]: z8 E# A% \; ^
where the Flash memory density ranges between 16 and 32 Kbytes.
$ V4 j) r$ a' ^- Low-density value line devices are STM32F100xx microcontrollers where the Flash* t ^2 t% O$ X
memory density ranges between 16 and 32 Kbytes.
/ L- J' ?4 _3 P! ~- Medium-density devices are STM32F101xx, STM32F102xx and STM32F103xx microcontrollers这里定义的是各种产品线的FLASH的大小。& T0 p, j4 i4 |2 |
where the Flash memory density ranges between 64 and 128 Kbytes.
9 l2 E2 a0 a+ \1 }2 @- Medium-density value line devices are STM32F100xx microcontrollers where the ; H3 z* |& c# D$ F
Flash memory density ranges between 64 and 128 Kbytes. " H; C, F: i4 m( G% ^/ @& }) S' q
- High-density devices are STM32F101xx and STM32F103xx microcontrollers where$ R; Y8 l1 q8 m9 R1 T H
the Flash memory density ranges between 256 and 512 Kbytes.& _( C; l* y# m, G9 w+ q( G9 I- @2 \
- High-density value line devices are STM32F100xx microcontrollers where the
2 x' M7 T- b s9 a Flash memory density ranges between 256 and 512 Kbytes. 1 y& n' l* J2 q- p
- XL-density devices are STM32F101xx and STM32F103xx microcontrollers where+ A% E6 P6 N2 t" h8 \; ]) M
the Flash memory density ranges between 512 and 1024 Kbytes.
1 O: ]" j" ]9 T- Connectivity line devices are STM32F105xx and STM32F107xx microcontrollers., C' ]- ]' L U& F& f8 Z& [! {
*/: K7 M7 A; x( Y9 ?4 u/ c
3 Y! A6 S5 b9 I3 z1 U% D#if !defined (STM32F10X_LD) && !defined (STM32F10X_LD_VL) && !defined (STM32F10X_MD) && !defined (STM32F10X_MD_VL) && !defined (STM32F10X_HD) && !defined (STM32F10X_HD_VL) && !defined (STM32F10X_XL) && !defined (STM32F10X_CL)8 A3 e7 S1 Q; K) O
#error “Please select first the target STM32F10x device used in your application (in stm32f10x.h file)”
, m0 z9 X- x0 o% F$ e9 P, C#endif 如果设备类型选择不正确,这里会报错的。% m3 T* _' b9 ~! ~& N
' M1 v \) f% t! b8 O
#if !defined USE_STDPERIPH_DRIVER
+ ^4 ?) K b. X4 Y) D9 ]# H x/**
* {7 A% a7 K: p* F* @brief Comment the line below if you will not use the peripherals drivers.7 P- W( O0 L: y K
In this case, these drivers will not be included and the application code will ( D2 q+ N+ l, |6 G+ P5 _5 _' W
be based on direct access to peripherals registers 9 U: P" N, P+ U0 z' `1 ^
*/
0 J6 x& w1 x6 z# G) t" J4 w /*#define USE_STDPERIPH_DRIVER*/+ q! r, y# X2 Q
#endif
% W6 F# W! ?: ~ L9 N% {. {, Q M) g
/**7 |5 D) t0 [; ^+ ]- o, J2 ] R" R3 @
* @brief In the following line adjust the value of External High Speed oscillator (HSE)7 l6 P5 c0 R5 m1 h; V3 D
used in your application
7 s' E+ |9 [. C- U6 @: P+ U1 q, }$ D0 b& p" R* a% R5 W% B: R) j, q+ I
Tip: To avoid modifying this file each time you need to use different HSE, you
+ o% U5 Z. H7 s$ | can define the HSE value in your toolchain compiler preprocessor.
: c3 A/ ~& ^& j6 U9 @提示:为了避免每次编译都要修改这些文件,意思是可以使用编译器的preprocessor选项来定义芯片型号等,免得反复更新这个文件。… ) U' h) J; j. W4 v! o" b& M* N$ j
*/
( w) ]. d w* V; v+ T" N#if !defined HSE_VALUE
5 i& K& c$ ^% h |0 \#ifdef STM32F10X_CL
* `9 h* I( y2 \) K4 Y4 y! K0 A3 x #define HSE_VALUE ((uint32_t)25000000) /*!< Value of the External oscillator in Hz */' n* S, x6 \/ x9 w; m: U4 H; D
#else
9 r. x; q. Q0 a+ C2 K J) h #define HSE_VALUE ((uint32_t)8000000) /*!< Value of the External oscillator in Hz */
( d% o% X+ R& u, n' W' a, C#endif /* STM32F10X_CL *// B( E- w% B! d( s+ _
#endif /* HSE_VALUE */
2 n. {5 A4 o% d8 j$ B3 c& }# e# [& I' [4 K e! w
B5 T0 p: C4 H6 J& c8 l/**
$ m2 ?4 I0 L0 P1 K# l4 g1 l A* @brief In the following line adjust the External High Speed oscillator (HSE) Startup
" i( |3 _! z0 r2 g' R. ` p& a+ O Timeout value
5 X# `" t- h: Z3 ^2 Q1 L */①、HSI是高速内部时钟,RC振荡器,频率为8MHz。 ②、HSE是高速外部时钟,可接石英/陶瓷谐振器,或者接外部时钟源,频率范围为4MHz~16MHz。/ O D7 H I" m; F! a; G. T
③、LSI是低速内部时钟,RC振荡器,频率为40kHz。
) G. C( T2 p( g( M ④、LSE是低速外部时钟,接频率为32.768kHz的石英晶体。& v1 { c( o- L0 V; W% Y& X+ i
⑤、PLL为锁相环倍频输出,其时钟输入源可选择为HSI/2、HSE或者HSE/2。倍频可选择为2~16倍,但是其输出频率最大不得超过72MHz。, U: i) h+ Q7 `/ h6 j6 r0 Z
#define HSE_STARTUP_TIMEOUT ((uint16_t)0x0500) /*!< Time out for HSE start up */) t$ g% [* ^0 M+ \9 b
高速外部时钟启动时间8 B( ]* i$ G" w5 r/ ]; J8 _
#define HSI_VALUE ((uint32_t)8000000) /*!< Value of the Internal oscillator in Hz*/: X6 r. |9 N# K
外部时钟设置的值" n; l( j( v- \- r x& P
/**
$ l1 o$ W! K7 x+ }: K* @brief STM32F10x Standard Peripheral Library version number
8 z! L. P" S5 y2 d. C: x' v) e9 a */+ K7 k& w( G- X4 r" K# r
#define __STM32F10X_STDPERIPH_VERSION_MAIN (0x03) /*!< [31:24] main version */
% y8 }) K! C3 b) J. G/ L#define __STM32F10X_STDPERIPH_VERSION_SUB1 (0x05) /*!< [23:16] sub1 version *// U4 y U3 D |
#define __STM32F10X_STDPERIPH_VERSION_SUB2 (0x00) /*!< [15:8] sub2 version */* o0 G: T z+ {, A
#define __STM32F10X_STDPERIPH_VERSION_RC (0x00) /*!< [7:0] release candidate */
; W" q5 O* Z+ r& k" d#define __STM32F10X_STDPERIPH_VERSION ( (__STM32F10X_STDPERIPH_VERSION_MAIN << 24)\( u5 X4 U$ N& N5 q1 w6 k
|(__STM32F10X_STDPERIPH_VERSION_SUB1 << 16)\
, v1 Z9 |% p) j- T. C- w7 p1 w |(__STM32F10X_STDPERIPH_VERSION_SUB2 << 8)\
/ B! B) e; f7 ~2 m |(__STM32F10X_STDPERIPH_VERSION_RC))
0 o8 h; T0 y! q0 R- b" z# U4 u
- w4 {) Y& T5 x7 b# s1 H0 w. l! f1 m/**4 l* Q2 s ~, b) _, o6 L2 f3 \. R
* @}" ]) z3 G8 j- g% k
*/! I. i; q/ L1 m2 {6 Q( X, t
5 t8 Y2 n3 {6 y5 z, c
/** @addtogroup Configuration_section_for_CMSIS& y5 j4 L6 \9 h1 V8 z
* @{
! d! Z) _- t9 y2 P, N, H7 R */; R* q( a% o. B0 @' S
1 t4 [) E) J. y# X& u1 W$ V/**3 V5 f0 w _/ H; Y: W- d1 S
* @brief Configuration of the Cortex-M3 Processor and Core Peripherals
' f7 ^% w3 W, i) h*/
& Q7 i3 ]/ K* G$ t#ifdef STM32F10X_XL! s0 c9 I8 y% s3 R8 k8 S1 k
#define __MPU_PRESENT 1 /*!< STM32 XL-density devices provide an MPU */, k) u( }6 }- E! M; M
#else* [+ O% ~ n2 e$ @( d. ~/ ~
#define __MPU_PRESENT 0 /*!< Other STM32 devices does not provide an MPU */
3 }, N1 {+ x2 L( e# ^! i$ ]#endif /* STM32F10X_XL */
& a. ~3 c- S' V! R#define __NVIC_PRIO_BITS 4 /*!< STM32 uses 4 Bits for the Priority Levels */! M& k* K6 z ^+ a& b1 ?8 `# o
#define __Vendor_SysTickConfig 0 /*!< Set to 1 if different SysTick Config is used */
$ Q" A! r p, G, D
) B( J2 ^) n# s/**# m3 y# V: f/ e5 A9 q
* @brief STM32F10x Interrupt Number Definition, according to the selected device
! C- ^5 f3 Z0 D, \' O$ R* in @ref Library_configuration_section
- \* J% { y( c$ e- c. Q2 l*/
& R8 V( ?( Z9 ]& Ntypedef enum IRQn0 Q; T" M2 ?# V) ]' a2 @$ W1 ~
{
: ?' p4 @/ I( `2 L- M* q/****** Cortex-M3 Processor Exceptions Numbers ***************************************************/
5 m# s) I) Z1 n7 _ NonMaskableInt_IRQn = -14, /*!< 2 Non Maskable Interrupt */- ~; M; m+ A% [
MemoryManagement_IRQn = -12, /*!< 4 Cortex-M3 Memory Management Interrupt */
, {/ {) H' B2 n1 ^+ M BusFault_IRQn = -11, /*!< 5 Cortex-M3 Bus Fault Interrupt */
$ J5 y, E7 ?5 `4 y+ E UsageFault_IRQn = -10, /*!< 6 Cortex-M3 Usage Fault Interrupt */
5 `; S9 Q, V( f7 U; H) X SVCall_IRQn = -5, /*!< 11 Cortex-M3 SV Call Interrupt */
5 [( j$ t- ~( M DebugMonitor_IRQn = -4, /*!< 12 Cortex-M3 Debug Monitor Interrupt */. W O3 j. g: [9 d. R$ F1 _; y
PendSV_IRQn = -2, /*!< 14 Cortex-M3 Pend SV Interrupt */
7 l! E9 V. k+ P4 [& ? SysTick_IRQn = -1, /*!< 15 Cortex-M3 System Tick Interrupt */ ) f$ @1 g: Q; J+ o" K R% s
————————————————————————————————————————————————————————- ————————————————————————————————————————————————————————- /**这里是STM32比较重要的头文件
1 H _' d+ j( F w8 y! G3 a' d ******************************************************************************3 N. A. K- n/ P0 E$ O) ]) _
ST版本库的 stm32f10x.h 文件,包含整个头文件代码。综合以上,可以看出 stm32f10x.h 用于定义了器件、中断线、数据类型、结构体封装的寄存器、寄存器地址映射、寄存器位操作以及防C++编译的条件编译。 * @file stm32f10x.h ST 标准的头文件
( g6 ?4 T; K# k2 f- X2 X * @author MCD Application Team 微控制器开发小组。6 y1 H- m1 `% [9 K( d, M
* @version V3.5.0 版本
2 s( [) G1 |! V, t# {; H: r * @date 11-March-2011 2011年3月11
9 F' u2 j3 `( T" P6 A6 q) O * @brief CMSIS Cortex-M3 Device Peripheral Access Layer Header File.(CMSIS:Cortex Microcontroller Software Interface Standard) 是 Cortex-M 处理器系列的与供应商无关的硬件抽象层。 7 V. o7 X( @8 W! e; Y" g
* This file contains all the peripheral register’s definitions, bits & E+ p' A; D+ g( B1 B( ?. N2 {
* definitions and memory mapping for STM32F10x Connectivity line, * S* O1 u, z( G( V- g
* High density, High density value line, Medium density, 3 z7 A8 M& R+ _1 l" M, D4 }- c# }
* Medium density Value line, Low density, Low density Value line
# p/ m' e2 @( P8 ] {/ e * and XL-density devices.
- x4 [ z$ |' ]0 J- ^+ \+ d+ W * 这个文件包含了芯片STM32F10X(接口增强型)内部的寄存器定义,位定义,内存地址变换定义,还有一些相应的高密度,低密度产品线的设备。
0 Y b3 f% m: A4 V+ z; j0 V 8 N4 ?, q/ i6 g4 w# w
* The file is the unique include file that the application programmer! f" a2 u% E7 p" A5 Z" \ F
* is using in the C source code, usually in main.c. This file contains:
$ g% R* H6 u0 U& T; X9 Q * - Configuration section that allows to select:. N6 I' r2 w$ e0 ^+ E
* - The device used in the target application" @) v# x, M- y' H3 m) A
* - To use or not the peripherals drivers in application code(i.e. * q2 q Z- s2 `3 q+ b. t, L
* code will be based on direct access to peripherals registers
; _! o; t' V' y0 O% @ * rather than drivers API), this option is controlled by
8 C5 E: P X1 K+ N6 x9 h * “#define USE_STDPERIPH_DRIVER”2 R ?" Z; t% ~9 w
* - To change few application-specific parameters such as the HSE % Y. D3 K V( z3 T, Z' l
* crystal frequency
0 ]) I( H, }7 K1 l6 D j; ` * - Data structures and the address mapping for all peripherals3 `. ]( h* I( u5 r
* - Peripheral’s registers declarations and bits definition
. u, G9 W K! I+ S/ ] * - Macros to access peripheral registers hardware
; C$ k. l+ B, _% R; b- ~! E% i8 C/ b; u*这个文件在应用程序中是至关重要的头文件,它是用C代码编写而成。通常包括在MAIN主程序中。它包括:1 设备中使用的目标应用程序。
8 r' B7 Q4 `) ?) g: |* s2 决定是否使用外部设备的代码(例如使用基于寄存器的代码,而不是我们所熟悉的API应用程序接口代码)。这一设备可以通过设置 “#define USE_STDPERIPH_DRIVER” 来实现。
' q+ X& r* V5 q& P3 |: D: T C+ l3 通过这一文件可以改变诸如外部设备的频率参数。
6 B) L, K; j; L5 A! u4 可以了解程序的数据结构以及外设的地址映射。+ b# ~8 p$ B7 z& g# y6 c( A+ `
5 外设的寄存器声明和位定义可以在这个文件里面了解到。" x' M! O5 f) m) o% v5 r- C" O+ R
1 }5 h7 @/ `( l$ M0 @1 [; F8 P! n
******************************************************************************% P- _7 ]( a; N! |$ h
* @attention- j7 X+ @% `$ G/ F! m
*
: }0 f1 x1 i. X, J * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS) ~# H9 V; {9 l( B( r
* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE3 g7 L! N0 s. U- F" A+ W X5 M
* TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
; v& \, a: p& G3 s6 F+ Y * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
+ I% q# E* ]( F M$ u, m * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE+ U" b& I- C5 o% ?. t
* CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
w7 I! A2 a; O$ ?7 E) e *注意:这一文件代码供应给用户,旨在帮助用户提升效率节约时间。ST将不会提供任何对于用户自己代码的解释和帮助。也不会解决其在代码中的任何BUG。
/ b- q p% F; ~9 O$ w * <h2><center>? COPYRIGHT 2011 STMicroelectronics</center></h2># S7 [- [- B! m1 @& @0 e
******************************************************************************) W F) Z* z& W M! a' {* u
*/
$ K: w4 E1 }9 X$ O$ O6 P& A. S- v
, I1 W/ P0 S( j9 Q# E7 t# D0 c0 z/** @addtogroup CMSIS
& A0 |! W8 _0 u9 |6 | * @{
) c; M) V. V- A& O x */这个不需要关心,只是说明这个文件的作者,公司产品等等,你贴出来的估计是小小的广而告之,这也是程序员的一点小小的特权嘛0 ?" U; [1 ^/ l; M$ X* Z0 y
% l% Y7 b; y. W
/** @addtogroup stm32f10x. K3 S" n8 `( c/ X2 W+ I0 r: {# K
* @{0 g, x" n% ?8 W2 q8 @" X0 F! `
*/
7 O; [1 y& \8 S: `! M* \& Y9 ]& z7 Y( j8 r0 W: }
#ifndef __STM32F10x_H//如果没有定义__STM32F10x_H ,则定义__STM32F10x_H 8 r2 M9 Z) Y( c% f% L0 r: a
#define __STM32F10x_H
6 J7 E: o/ W! _ Q; ?4 D/ Q. D
7 a1 u6 {( q: x" }* L#ifdef __cplusplus// ' \' N; a. D" C% w$ Y7 G
extern “C” {, c# V# C" f" x0 ?7 k
#endif 2 \1 c- [1 U2 E, m2 x
这里是一种条件编译。extern “C”指令非常有用,因为C和C++的近亲关系。注意:extern “C”指令中的C,表示的一种编译和连接规约,而不是一种语言。C表示符合C语言的编译和连接规约的任何语言,如Fortran、assembler等。8 z0 E& q4 C. l' m
7 G7 O" X% t' l% t# }% F3 b还有要说明的是,extern “C”指令仅指定编译和连接规约,但不影响语义。例如在函数声明中,指定了extern “C”,仍然要遵守C++的类型检测、参数转换规则。
6 \; k: c U v! W- t一开始我不解 extern “C” { 这个语句的意思,原来是用来说明后面的定义都是使用C语言写的。这个 __cplusplus 是指C++来的,4、5句的意思就是说如果用C++编译器的话,它里面是定义有__cplusplus 这个的,而通过 extern “C” { 告知编译器,这段代码是用C编写的,要按照C语言编译。这是因为C++里面有函数重载,编译的时候把参数也编译了,而C的话,编译只编译函数名。6 {# U7 l% }' y" Z) N" w
/** @addtogroup Library_configuration_section
' v: E& x* i+ V * @{8 ~- z& d2 e& u) @& X, Q4 C! h- H
*/
2 k' X9 ?( ^# V$ _5 t6 Q* l1 }- o+ G0 r* ` ?4 p
/* Uncomment the line below according to the target STM32 device used in your
! t8 q( d1 W3 g" l. S+ n/ y application , y6 u9 P; q; N- @! g) x
*/, u4 D( `1 g1 E/ y8 u" P8 `: I
- w& g u2 u+ w3 `, R3 J* K& A#if !defined (STM32F10X_LD) && !defined (STM32F10X_LD_VL) && !defined (STM32F10X_MD) && !defined (STM32F10X_MD_VL) && !defined (STM32F10X_HD) && !defined (STM32F10X_HD_VL) && !defined (STM32F10X_XL) && !defined (STM32F10X_CL)
* s2 B, [% e5 `! T1 O6 h9 `. ~# @9 L /* #define STM32F10X_LD */ /*!< STM32F10X_LD: STM32 Low density devices */8 X( p9 H' m4 x! F& H
/* #define STM32F10X_LD_VL */ /*!< STM32F10X_LD_VL: STM32 Low density Value Line devices */ * B" C$ _7 k- K, q+ n! W/ a
/* #define STM32F10X_MD */ /*!< STM32F10X_MD: STM32 Medium density devices */# {& Z0 g# i8 r
/* #define STM32F10X_MD_VL */ /*!< STM32F10X_MD_VL: STM32 Medium density Value Line devices */ * \. y( q g- V$ u, y+ W' G
/* #define STM32F10X_HD */ /*!< STM32F10X_HD: STM32 High density devices */' L3 ~4 k7 O5 \. J! |( R0 c8 k
/* #define STM32F10X_HD_VL */ /*!< STM32F10X_HD_VL: STM32 High density value line devices */ ( R0 f. x9 f. [3 c3 N! C
/* #define STM32F10X_XL */ /*!< STM32F10X_XL: STM32 XL-density devices */
# r: h; I2 G/ {$ N' U /* #define STM32F10X_CL */ /*!< STM32F10X_CL: STM32 Connectivity line devices */
( m; O" W. Z& K- K6 ?#endif$ R3 e5 q4 w# q( z. G
STM32启动文件选择:. Q6 p+ D# j% c
- startup_stm32f10x_ld_vl.s: for STM32 Low density Value line devices - startup_stm32f10x_ld.s: for STM32 Low density devices - startup_stm32f10x_md_vl.s: for STM32 Medium density Value line devices - startup_stm32f10x_md.s: for STM32 Medium density devices - startup_stm32f10x_hd.s: for STM32 High density devices - startup_stm32f10x_xl.s: for STM32 XL density devices - startup_stm32f10x_cl.s: for STM32 Connectivity line devices
6 q. E. S" ~ ?5 tcl:互联型产品,stm32f105/107系列
H0 w2 }+ N1 H; wvl:超值型产品,stm32f100系列 ' s6 x2 {. t/ c. c6 ]# n" i
xl:超高密度产品,stm32f101/103系列9 m& A2 d" @2 }/ g) ~3 N2 V0 h( N( r
ld:低密度产品,FLASH小于64K
, p0 K8 Q1 B& Z! Imd:中等密度产品,FLASH=64 or 1288 B7 Y3 u- N3 j. u+ ^' ~
hd:高密度产品,FLASH大于128
( v+ h5 y0 o0 v+ c8 ^* L/* Tip: To avoid modifying this file each time you need to switch between these# Z" m8 G0 O! [/ B$ _2 P
devices, you can define the device in your toolchain compiler preprocessor.* x' ^) B/ [; l2 D
提示:为了避免每次编译都要修改这些文件,意思是可以使用编译器的preprocessor选项来定义芯片型号等,免得反复更新这个文件。…
2 F' O5 `- @& s5 r% I" _- Low-density devices are STM32F101xx, STM32F102xx and STM32F103xx microcontrollers
! u: {% D# C( i' v! ^) X' ] where the Flash memory density ranges between 16 and 32 Kbytes.
# G/ F! C- d3 k. S- Low-density value line devices are STM32F100xx microcontrollers where the Flash6 E; M: W$ M: p j# q
memory density ranges between 16 and 32 Kbytes.
0 ^% l7 a" ^" G+ S+ `+ h- Medium-density devices are STM32F101xx, STM32F102xx and STM32F103xx microcontrollers这里定义的是各种产品线的FLASH的大小。
8 ~+ {* `: Q; O/ Y- L V1 Z where the Flash memory density ranges between 64 and 128 Kbytes.( s* u5 a% y x7 {/ c
- Medium-density value line devices are STM32F100xx microcontrollers where the " O9 U" K; q4 B6 |8 s3 c
Flash memory density ranges between 64 and 128 Kbytes.
! r$ r- n4 G1 B" Q! [3 J8 ?0 ^- High-density devices are STM32F101xx and STM32F103xx microcontrollers where
6 [' ~8 d. s' r the Flash memory density ranges between 256 and 512 Kbytes.
! w" B8 P# E0 G, t- z- High-density value line devices are STM32F100xx microcontrollers where the
1 l1 W9 ~* E) C5 I, K) C0 e Flash memory density ranges between 256 and 512 Kbytes.
: x. T1 Z) h) d: r9 p- XL-density devices are STM32F101xx and STM32F103xx microcontrollers where
# W% |8 `7 g% ~/ h/ | the Flash memory density ranges between 512 and 1024 Kbytes.7 s- q+ O" c3 w; u
- Connectivity line devices are STM32F105xx and STM32F107xx microcontrollers., G& p% W. I. b3 K
*/$ G: G2 t2 B$ l4 U& H' r
7 U! {/ w7 j% `$ ]' K" ^" H( u
#if !defined (STM32F10X_LD) && !defined (STM32F10X_LD_VL) && !defined (STM32F10X_MD) && !defined (STM32F10X_MD_VL) && !defined (STM32F10X_HD) && !defined (STM32F10X_HD_VL) && !defined (STM32F10X_XL) && !defined (STM32F10X_CL)
& R' p/ ?/ W A7 h) J3 O#error “Please select first the target STM32F10x device used in your application (in stm32f10x.h file)”5 q; \ ?; b- j( |9 d
#endif 如果设备类型选择不正确,这里会报错的。
4 T& V* c4 H7 I/ Y; Y
& Z7 X: ^8 K' W' U4 k#if !defined USE_STDPERIPH_DRIVER
. W2 j* `- e, x6 o8 ?6 ?+ @3 `/**
% m( ]2 w, C5 j* @brief Comment the line below if you will not use the peripherals drivers.
+ Y/ r5 m( }$ \: |6 g In this case, these drivers will not be included and the application code will 5 s- v; @6 k3 J" l. T* [; v
be based on direct access to peripherals registers
/ h, A) h/ O5 f& j: e3 J8 Y; ^* Z) G% C */' Z( C, |3 q4 ~$ X
/*#define USE_STDPERIPH_DRIVER*/" i, r' c& }9 Y/ u% u; \/ `) ~
#endif! a# }2 F6 [0 ^2 ~7 ?0 p( W2 t
( O, q1 x3 V5 L0 j' H8 K* _- b/**
4 l* V1 y% V( m5 E* @brief In the following line adjust the value of External High Speed oscillator (HSE)
) b' w4 }& _; _ used in your application
- p& O( v0 a0 R" ]' k- E6 E! x7 h% G" I1 @5 N' o
Tip: To avoid modifying this file each time you need to use different HSE, you
1 G3 ^7 b4 M; w; h: d! S. U can define the HSE value in your toolchain compiler preprocessor., ?5 a" W7 @! B% Y, ^; ~: R
这些提示:为了避免每次编译都要修改文件,意思是可以使用编译器的preprocessor选项来定义芯片型号等,免得反复更新这个文件。…
" I- X; t# S$ s */ 1 b7 X( U: l, o1 S) o
#if !defined HSE_VALUE
* s0 O4 x1 e8 K9 X4 V9 ^$ A#ifdef STM32F10X_CL
W0 Z; e( t1 K( y$ j #define HSE_VALUE ((uint32_t)25000000) /*!< Value of the External oscillator in Hz */
; x" m+ U, j4 Z; e6 y$ f$ w#else
6 X# j" S' T8 {6 v% I' | #define HSE_VALUE ((uint32_t)8000000) /*!< Value of the External oscillator in Hz */& t3 `: R* |2 Q/ }+ T. z5 F. P, @) z
#endif /* STM32F10X_CL */
) u, M8 a; ^9 Q" J& ^( z& D( f#endif /* HSE_VALUE */
9 @' S- W& [8 G1 t. d5 K8 [
# B& L" h5 ^! a
" a) b$ v2 Z* O/**
/ ^' T4 Z& t- P; f1 _8 r* @brief In the following line adjust the External High Speed oscillator (HSE) Startup 9 _! _* F! |% h
Timeout value 5 Z$ ?% y) L3 d- D6 }0 t3 v
*/①、HSI是高速内部时钟,RC振荡器,频率为8MHz。 ②、HSE是高速外部时钟,可接石英/陶瓷谐振器,或者接外部时钟源,频率范围为4MHz~16MHz。1 P" Q! f, G: J, q" C1 J3 a
③、LSI是低速内部时钟,RC振荡器,频率为40kHz。
2 f% h4 m8 o2 T# ]' @ ④、LSE是低速外部时钟,接频率为32.768kHz的石英晶体。
3 y) A6 u3 n: ~$ X+ \ ⑤、PLL为锁相环倍频输出,其时钟输入源可选择为HSI/2、HSE或者HSE/2。倍频可选择为2~16倍,但是其输出频率最大不得超过72MHz。
( [0 a3 l5 ?4 s- F | . x+ N/ ~6 d& w0 i% s1 V# {
. g$ f8 G5 M) b. F
#define HSE_STARTUP_TIMEOUT ((uint16_t)0x0500) /*!< Time out for HSE start up */
6 Q2 h) Q- Y6 ]+ u+ {# d7 w6 ?5 `高速外部时钟启动时间
( F7 j& ~& ]% Q* s. }+ f, k9 O#define HSI_VALUE ((uint32_t)8000000) /*!< Value of the Internal oscillator in Hz*/
1 V6 u- p+ Y* R4 O! r$ M外部时钟设置的值
4 s8 o/ K* g% O1 x/**$ g: u: S# ?+ y0 I
* @brief STM32F10x Standard Peripheral Library version number标准外设库版本号的定义
0 k5 n% ^5 \$ D8 z+ b5 G7 J */
2 v+ F: K1 G+ A" X8 O, r#define __STM32F10X_STDPERIPH_VERSION_MAIN (0x03) /*!< [31:24] main version */ I/ r; W& ? \
#define __STM32F10X_STDPERIPH_VERSION_SUB1 (0x05) /*!< [23:16] sub1 version */, ]( U! Q5 l2 ~* k: p2 e' N9 [7 l) `1 ?
#define __STM32F10X_STDPERIPH_VERSION_SUB2 (0x00) /*!< [15:8] sub2 version */
' {1 a6 y/ X4 {; Z# z! y4 ~# \#define __STM32F10X_STDPERIPH_VERSION_RC (0x00) /*!< [7:0] release candidate */
6 R6 q9 H2 M0 H/ m! E% q+ G#define __STM32F10X_STDPERIPH_VERSION ( (__STM32F10X_STDPERIPH_VERSION_MAIN << 24)\% @; q3 j$ |9 ]5 r
|(__STM32F10X_STDPERIPH_VERSION_SUB1 << 16)\
# l0 [' t1 o- d+ s5 {* V |(__STM32F10X_STDPERIPH_VERSION_SUB2 << 8)\2 Q+ @/ a! M! t
|(__STM32F10X_STDPERIPH_VERSION_RC))
% _3 s3 a. N* `( h# Q; m
# D$ w5 P8 [6 b. `/ `* _& i/**2 Y6 P8 {( E) |
* @}
/ Q1 u9 E( W! ~$ Y) f! G */* r2 K# M& z4 K2 r" A' u# Q
, o- _6 B: A3 T- X/** @addtogroup Configuration_section_for_CMSIS
( z/ G: x6 T0 Y6 O4 @# a * @{5 a1 Z! D- c0 |
*/
- R# s6 D# E! p! L# p
/ }4 u% t* G& D7 b* [1 s# H/**7 r8 W8 c c" Q! y. B9 m: Q1 N) }! S" I
* @brief Configuration of the Cortex-M3 Processor and Core Peripherals 配置Cortex-M3处理器和核内外设" i+ y7 Y7 {) n j( U
*/
% R; E" Q$ H7 j; F: ~) p& [#ifdef STM32F10X_XL& m7 w8 [- K# i8 _# ]
#define __MPU_PRESENT 1 /*!< STM32 XL-density devices provide an MPU */
9 `8 S5 B2 v2 I/ b5 O X( m#else0 k$ [1 R& u7 G0 l* m
#define __MPU_PRESENT 0 /*!< Other STM32 devices does not provide an MPU */
$ K. k9 l- `- f* w2 N#endif /* STM32F10X_XL */
& b$ H% |. D' N" v' p4 v% C#define __NVIC_PRIO_BITS 4 /*!< STM32 uses 4 Bits for the Priority Levels */
! `8 q8 Q) L) X1 ^#define __Vendor_SysTickConfig 0 /*!< Set to 1 if different SysTick Config is used */3 {( [1 Q( U }% H+ P8 Z3 R
/ r: @8 Y6 d2 H0 x8 Q
/**! D& A) s! K9 L, C6 x0 `
* @brief STM32F10x Interrupt Number Definition, according to the selected device
) W9 C7 i$ H- G4 d l7 m% R4 f* in @ref Library_configuration_section 中断线定义,前部分对于所有STM32F10x都有相同定义,后部分根据不同器件容量采用条件编译定义不同中断线。$ y. y4 P" a) W3 s; @
*/
: b) M0 J% \4 A0 Y4 e" T- [
+ L" D: a" s; `2 h: H! ~————————————————————————————————————————————– ————————————————————————————————————————————– 这里是STM32比较重要的头文件
* K5 W% b! m8 {/ y1 C" B7 v+ o4 Q
9 y F0 K ~8 L1 f0 N z! q# utypedef enum IRQn typedef enum表示定义了一个枚举型的数据结构,你可以用题目中的 IRQn 去定义变量
% q) X0 @6 ?' s( }; P1 N( v; f( d{系统异常ID: ( i' i3 }9 B+ h
" g$ d O9 U2 D( C+ v8 h M! C7 a! Y
标号 | 中断ID | 描述 | NonMaskableInt_IRQn | -14 | 不可屏蔽中断 | MemoryManagement_IRQn | -12 | Cortex-M3内存管理中断 | BusFault_IRQn | -11 | Cortex-M3 总线Fault中断 | UsageFault_IRQn | -10 | Cortex-M3 用法Fault 中断 | SVCall_IRQn | -5 | Cortex-M3 SV Call中断 | DebugMonitor_IRQn | -4 | Cortex-M3 调试监视中断 | PendSV_IRQn | -2 | Cortex-M3 Pend SV中断 | SysTick_IRQn | -1 | Cortex-M3 系统Tick中断 | : E, i1 {) I' I4 o# Z& c9 p+ ]" P
外设中断ID: 标号 | 中断ID | 描述 | 标号 | 中断ID | 描述 | WDT_IRQn | 0 | 看门狗 | EINT3_IRQn | 21 | 外中断3 | TIMER0_IRQn | 1 | 定时器0 | ADC_IRQn | 22 | AD转换 | TIMER1_IRQn | 2 | 定时器1 | BOD_IRQn | 23 | 欠压检测 | TIMER2_IRQn | 3 | 定时器2 | USB_IRQn | 24 | USB | TIMER3_IRQn | 4 | 定时器3 | CAN_IRQn | 25 | CAN | UART0_IRQn | 5 | UART0 | DMA_IRQn | 26 | 通用DMA | UART1_IRQn | 6 | UART1 | I2S_IRQn | 27 | I2S | UART2_IRQn | 7 | UART2 | ENET_IRQn | 28 | 以太网 | UART3_IRQn | 8 | UART3 | MCI_IRQn | 29 | SD/MMC卡I/F | PWM1_IRQn | 9 | PWM1 | MCPWM_IRQn | 30 | 电机控制PWM | I2C0_IRQn | 10 | I2C0 | QEI_IRQn | 31 | 正交编码接口 | I2C1_IRQn | 11 | I2C1 | PLL1_IRQn | 32 | PLL1锁存 | I2C2_IRQn | 12 | I2C2 | USBActivity_IRQn | 33 | USB活动 | Reserved0_IRQn | 13 | 保留 | CANActivity_IRQn | 34 | CAN活动 | SSP0_IRQn | 14 | SSP0 | UART4_IRQn | 35 | UART4 | SSP1_IRQn | 15 | SSP1 | SSP2_IRQn | 36 | SSP2 | PLL0_IRQn | 16 | PLL0锁存 | LCD_IRQn | 37 | LCD | RTC_IRQn | 17 | RTC | GPIO_IRQn | 38 | GPIO | EINT0_IRQn | 18 | 外中断0 | PWM0_IRQn | 39 | PWM0 | EINT1_IRQn | 19 | 外中断1 | EEPROM_IRQn | 40 | EEPROM | EINT2_IRQn | 20 | 外中断2 | ( t3 |- h. O7 n3 `- Z, D) w
/** Cortex-M3 Processor Exceptions Numbers C$ i! m9 i9 y9 a5 A' {
*****************************************/CMSIS中的中断定义
+ X8 x% x+ M5 E- P4 X3 U' v* `" [1 E3 m
NonMaskableInt_IRQn = -14, /*!<
2 H) U) E+ ~4 Z+ _1 ?8 f2 Non Maskable Interrupt 非屏蔽中断
& g7 W* w- a9 ?0 [' s */! F3 {' T# k+ w$ E# j8 a, ]
! R& S2 S( g5 {6 n MemoryManagement_IRQn = -12, /*!<1 x9 N+ q9 T4 t) o
4 Cortex-M3 Memory Management Interrupt Cortex-M3内存管理中断 ( g1 q; r Q0 C
*/
, {8 b' ?+ _( b2 p9 x, V) B) U( V4 U1 q
BusFault_IRQn = -11, /*!<
' O8 ]/ f' D* i4 q9 o+ N* L( N5 Cortex-M3 Bus Fault Interrupt */
% Z( c- W' P; ^/ j* }4 P+ \% S3 F' J5 ^- h8 Q, j
UsageFault_IRQn = -10, /*!<
, [7 Q6 `; S- z: `; H6 Cortex-M3 Usage Fault Interrupt */2 L, K& o( c Q
) I7 {0 Y. y2 E g3 g
SVCall_IRQn = -5, /*!<
2 M" Q% F8 \8 O) F+ f11 Cortex-M3 SV Call Interrupt */
) J1 {: k7 d3 J5 B. H6 l4 I Y7 |3 j$ J1 c- U5 |( }
DebugMonitor_IRQn = -4, /*!<
' M& S! N( ^0 l+ J* `: A' Q7 r" k* ~12 Cortex-M3 Debug Monitor Interrupt */9 F7 x' \6 v! |
2 L! z1 x& \- W; p: ]
PendSV_IRQn = -2, /*!</ y! i& k" x! f/ P& G- k
14 Cortex-M3 Pend SV Interrupt */ b7 r; t- X" G7 q6 q/ r8 Y, M
9 Z x# Q5 ?8 Q: h" S' n SysTick_IRQn = -1, /*!<3 i' ]) ], E; P9 K; ~
15 Cortex-M3 System Tick Interrupt */. h2 E; s' G% ~7 e( E5 i) i K% z
. n/ z2 n# V6 R2 P2 E+ P3 F& n& X
) T& c5 {/ r: E' R9 q
* @* _) f' \, i: n: r. X, F. ^( y2 i/* STM32 specific Interrupt Numbers ************************************************/+ z- E5 U4 U2 q
" Q* C2 ]* _; K7 g/ c: |
WWDG_IRQn = 0, /*!<
- [7 Z t& _3 {- s/ ]Window WatchDog Interrupt */
+ p8 g4 O8 x3 r8 ^
' u4 D5 Y$ @% d* A PVD_IRQn = 1, /*!<0 b- a# i! q# d% ^& L3 n. B
PVD through EXTI Line detection Interrupt */7 C3 W1 ^ s0 |/ F2 S( p4 t+ C& v& H: D
! C* W& E5 h& T/ G( a
TAMPER_IRQn = 2, /*!<) O$ W- H7 _& K1 I
Tamper Interrupt */
/ ?3 d( S& K& Q+ N& g/ I! k9 `2 i4 I/ x
RTC_IRQn = 3, /*!<
* ?9 ]% a5 Q( lRTC global Interrupt */
! j1 s% @; f; o3 s/ f: N
* V( O" B; c& X+ e FLASH_IRQn = 4, /*!<+ g9 D5 j- {9 d5 h4 ~
FLASH global Interrupt */% i6 \; b: _3 O$ ~' v% k
3 X9 [7 M" ?- C. _) v
RCC_IRQn = 5, /*!<
. j. A( M; Z# x, S9 JRCC global Interrupt */+ e8 ^4 }+ Z+ |
- o \) E m X" d$ V) ~ EXTI0_IRQn = 6, /*!<
& Z* I* R7 ]" d# _ L0 D$ kEXTI Line0 Interrupt */8 d* p- C0 H. v1 D7 @7 l
6 [2 z) t/ _) q% v EXTI1_IRQn = 7, /*!<
$ ~& _9 G: n, C) aEXTI Line1 Interrupt */9 x$ K, F$ G( n9 z
% c1 ^. V+ ~/ [7 T3 ]# d+ G
EXTI2_IRQn = 8, /*!<7 E( T7 ~4 j0 v" G
EXTI Line2 Interrupt */6 a# Q( ~! Q, `" z4 N5 P' ]
% A# I3 q7 t) Q, [0 y% }' w EXTI3_IRQn = 9, /*!<1 |( E: N( x9 w; c+ Y. U3 ~
EXTI Line3 Interrupt */1 e9 {, C7 H4 M! [
! R1 s9 c2 f" j0 y; D6 G EXTI4_IRQn = 10, /*!<
% i6 c3 S K e) FEXTI Line4 Interrupt */4 _, _9 y8 ~7 g% j5 u* o0 f
; H% F4 ^1 g. w% k; [* m DMA1_Channel1_IRQn = 11, /*!<$ J. m( b1 Y% t6 o# M" M; A/ K
DMA1 Channel 1 global Interrupt */
6 \9 t+ A4 ]2 \. X
5 |2 G7 D; m% s0 Y0 `/ p2 Y DMA1_Channel2_IRQn = 12, /*!<
1 j$ P+ t7 a7 \; |! W gDMA1 Channel 2 global Interrupt */
* s+ j. ~& X W! r8 r+ H. c9 {
: x- z2 e$ Q4 V. Q% J; B8 Q, O' d0 r DMA1_Channel3_IRQn = 13, /*!<" u/ N. z3 u& T" a
DMA1 Channel 3 global Interrupt */
2 S* m6 }- p1 o/ E: M5 _7 i
! j$ m1 `# }( ?8 x/ k7 j" g DMA1_Channel4_IRQn = 14, /*!<
6 h8 b# k$ W8 D/ v' C6 [# \DMA1 Channel 4 global Interrupt */- n, t {2 T r+ p% T3 W- E7 p
( a- |/ Y2 @6 e: @; e1 A) F, V DMA1_Channel5_IRQn = 15, /*!<
; v' U1 Z- q7 J/ M3 ?: m' NDMA1 Channel 5 global Interrupt */
( I0 p) t9 A2 |/ B, H U$ v8 q' z5 r9 N' B! |
DMA1_Channel6_IRQn = 16, /*!<1 E+ D# T5 W$ Y) r5 p
DMA1 Channel 6 global Interrupt */. K+ ?4 O3 q: j. Q8 h
6 L6 K: g2 J" a4 w DMA1_Channel7_IRQn = 17, /*!<
9 ^6 H1 }$ }6 ]$ f( |! P) vDMA1 Channel 7 global Interrupt */" b& W' V: ?0 W
7 H8 e; \( S+ V+ b! F4 [) q) d$ V+ W# W
5 M8 X: c) w2 k: }7 ?8 D8 ]* g' {0 H9 R#ifdef STM32F10X_LD
0 H4 j4 ~# U' @- n0 H+ u" @( @' q- [: ?! [% a1 H8 Y2 N
ADC1_2_IRQn = 18, /*!<
7 D1 Z- F( e8 d) J! AADC1 and ADC2 global Interrupt */, p/ |' V9 ]& z: s' W8 a
6 t. F6 v O4 J; j/ C8 G
USB_HP_CAN1_TX_IRQn = 19, /*!<: a0 K9 O$ W( V
USB Device High Priority or CAN1 TX Interrupts */
# G' t) V* m g
" Y9 A) x9 B2 Z0 ~6 d1 M; I) C4 j USB_LP_CAN1_RX0_IRQn = 20, /*!<; G0 E" J! {. n+ `5 v
USB Device Low Priority or CAN1 RX0 Interrupts */- _+ t" ~8 C5 u
( l9 e( g* p& w+ E+ s4 c
CAN1_RX1_IRQn = 21, /*!< H+ e6 H; J7 R3 ?7 x- N9 ~+ @& M$ `
CAN1 RX1 Interrupt */
+ y+ ], O2 K+ n: e2 |. c4 J! S! ~# t; b1 |5 K$ \
CAN1_SCE_IRQn = 22, /*!< j+ u/ r: H. e6 \) j
CAN1 SCE Interrupt */% R- i8 C T2 v# L
- W, q$ k' J. F# d. R! q
EXTI9_5_IRQn = 23, /*!<
( G9 s/ c; V! {# T" d; X) T- r" |$ vExternal Line[9:5] Interrupts */6 m' V+ V" ?* e ^8 }( T& U* W6 n
% c! `1 X8 w; l1 W* p0 J- X
TIM1_BRK_IRQn = 24, /*!<
% `6 t, w! D5 M! o* [4 q8 j& YTIM1 Break Interrupt */
$ [5 F1 G! {1 A2 v+ r- ~* x* n& H
TIM1_UP_IRQn = 25, /*!< _+ M7 L) ?8 p1 F
TIM1 Update Interrupt */: x. _6 b: @# [' d( l+ J* _- \
% E$ f7 b# y. o% d/ ^
TIM1_TRG_COM_IRQn = 26, /*!</ |7 }. W0 {# s
TIM1 Trigger and Commutation Interrupt */* H% k2 Q# x! _( E- r; y6 [0 v
3 d- r$ D O: Q# o! v7 T w- |
TIM1_CC_IRQn = 27, /*!<
5 m6 n! |: h' O$ jTIM1 Capture Compare Interrupt */
$ \# w$ r" T: g* w9 H6 j' D! I6 {' {1 O+ E% E/ O
TIM2_IRQn = 28, /*!<+ O- Z+ Q+ }, K1 `7 x* q: L
TIM2 global Interrupt */7 d. i5 s q' B! S/ Y9 H
1 y( }4 L1 m: p
TIM3_IRQn = 29, /*!<
7 D& l' M1 R5 XTIM3 global Interrupt */
) A6 Z$ e3 s) G( {- P% R& x) @: m" G d( D. t: w7 B3 _5 h
I2C1_EV_IRQn = 31, /*!<2 ~6 z$ w5 M' ?& a Q: D
I2C1 Event Interrupt */2 j3 X* c3 M9 i4 p! I1 x
/ H1 X# O) }# q4 `
I2C1_ER_IRQn = 32, /*!<
9 r2 a/ B9 V: L7 r8 `9 c7 {I2C1 Error Interrupt */$ b0 e1 H% t, z+ n" u
2 H9 P. T% }0 e. ^/ V SPI1_IRQn = 35, /*!<# N, S- j" l7 K& }# K
SPI1 global Interrupt */& k; l6 z( O( O* N' y$ N8 [: E1 Y
2 ]& x1 n& B1 Y Z- I USART1_IRQn = 37, /*!<
* G0 `$ X5 `* JUSART1 global Interrupt */4 z9 k/ K! a+ R1 e4 | F+ z2 O
6 h# F9 C" ~/ X. ` USART2_IRQn = 38, /*!<
' k( E+ u. h3 m0 v' zUSART2 global Interrupt */5 ^3 G' k$ y2 u9 N
) z/ G3 G- Z! O/ f r, x0 x EXTI15_10_IRQn = 40, /*!<
( i( s, { J3 `' P0 l& {) E! @External Line[15:10] Interrupts */; D' J1 W* y4 `6 e0 l# ~ ], T. Y
6 ?2 C( p# C* }) } RTCAlarm_IRQn = 41, /*!<
5 w3 a/ O: T' G1 ^* wRTC Alarm through EXTI Line Interrupt */: G- n' A8 V/ p' \2 j# d" c
7 ^/ b4 d- T1 u) P& F9 ^/ R$ a& f) `, x" b USBWakeUp_IRQn = 42 /*!<6 a: B8 t% h% g% e$ e; d
USB Device WakeUp from suspend through EXTI Line Interrupt */
4 [* | i7 V6 M4 m
3 H4 u$ J* L6 y#endif /* STM32F10X_LD */ / T- t- d% l4 R+ ~' `+ |- b" v
* H4 M+ I2 [! z! f9 V4 i7 I; C3 Q) y
& k& N7 M/ \# Z( u6 d) d3 H3 X* A& q! d0 K2 C# @
#ifdef STM32F10X_LD_VL/ x+ ?. A4 X, n
8 Y/ A, f) c9 [+ E4 w/ {8 h ADC1_IRQn = 18, /*!<4 k# C3 ]" `, l' n% w
ADC1 global Interrupt */1 j, C/ n: T$ u$ h
4 p# I ~) m2 P
EXTI9_5_IRQn = 23, /*!<
) o, b) p! \: p8 N0 E' Q QExternal Line[9:5] Interrupts */; Z! @2 G1 f8 E; n' Y/ a* s, u J
; Q& O6 p$ ]$ {$ A TIM1_BRK_TIM15_IRQn = 24, /*!<
* D- Y* E) J; X. `TIM1 Break and TIM15 Interrupts */: u: l9 l5 E9 @( F8 p2 W5 _# `# V: d
2 u! R3 x. ?) b" `' r7 v* n
TIM1_UP_TIM16_IRQn = 25, /*!<
9 M m, D: X, G4 m9 b/ ]3 V' ZTIM1 Update and TIM16 Interrupts */
6 _! }6 g6 L- }* x* j0 E x" M6 N' `( b1 l
TIM1_TRG_COM_TIM17_IRQn = 26, /*!<8 a: E: _" z" G. p
TIM1 Trigger and Commutation and TIM17 Interrupt */2 \; v. T( ]$ z/ F) X
, i l8 f' D& n; _ TIM1_CC_IRQn = 27, /*!<, O! h$ m8 e) t( J3 I. i% _" ], N
TIM1 Capture Compare Interrupt */2 b M# J$ p7 T/ F* x+ f
% I9 `9 _5 A3 a6 j# _
TIM2_IRQn = 28, /*!<! T+ P, a8 q& U" G+ `1 p
TIM2 global Interrupt */1 f7 @. n' P/ a, _' b1 B" K
/ |; I: H" A) J( i4 R. N
TIM3_IRQn = 29, /*!<
& P& v- m0 }, p4 v/ M1 h) STIM3 global Interrupt */
a" E4 p% |1 D+ I( Y; p s& A+ L, Q, I1 _
I2C1_EV_IRQn = 31, /*!<1 _9 g) [- \" s; f" v
I2C1 Event Interrupt */8 i% Q# Z: `# ^
; b5 k: u) l; i+ w. q# M I2C1_ER_IRQn = 32, /*!<2 q, a' {3 {% S& |! s! v
I2C1 Error Interrupt */" a) V. O, u: ~9 _- k0 p; V3 o; Q
) Z+ Q6 }: i* f c& u. I
SPI1_IRQn = 35, /*!<
+ @$ ^$ U/ P& V/ O n9 ~SPI1 global Interrupt */
/ K6 \3 g0 Q& e" H( T. p3 ?8 o( h! g G3 N% t6 U# v' C. G
USART1_IRQn = 37, /*!<1 k/ [; T$ N5 m! | U# y
USART1 global Interrupt */7 ~% T: h, a4 y* |: u
2 S6 s0 ?/ _! Q" d+ n! O USART2_IRQn = 38, /*!<
$ v! x/ S6 F; q, b& J' aUSART2 global Interrupt */
/ W( ^4 M! h% x$ K2 e( m: g! D- q( X- I" }9 D1 s1 ` o
EXTI15_10_IRQn = 40, /*!<: _: g: }; M4 A4 @# x
External Line[15:10] Interrupts */' j8 K5 x* z; }
1 _. j t; V% \) M1 Q$ Q RTCAlarm_IRQn = 41, /*!<
( }# }1 v7 V9 \8 uRTC Alarm through EXTI Line Interrupt */! E( \- d1 Y6 i( @) y
. K' I7 F# F7 [8 v CEC_IRQn = 42, /*!<+ r: R) g- }# U3 o2 v% x' _1 J
HDMI-CEC Interrupt */, n7 w8 Y7 \! H. ^
; }; e! M+ n* d: y3 @3 [+ V
TIM6_DAC_IRQn = 54, /*!<
1 b/ X+ t$ [( A h7 L) X& nTIM6 and DAC underrun Interrupt */
" X: X& t% p' X) x' A
% Q" r0 f; ~ x/ V0 _3 q TIM7_IRQn = 55 /*!<
7 ]$ A7 }+ j. dTIM7 Interrupt */ $ y, H, e# U8 u1 l$ z f$ z" w
6 h1 S9 [. l! t9 B) z#endif /* STM32F10X_LD_VL */
2 C! }3 {; A7 ~7 I5 v H0 C# t0 G! B$ A: D, z: a
/ [0 h4 Q6 B8 L) ?& z& v
! [: p* t: V: Z f! n& H3 R
——————————————————————————————————————————-$ p, V/ B0 Y% u- x
——————————————————————————————————————————- 这里是STM32比较重要的头文件& {* U4 B! s: [& L: p, E. l3 d
系统异常ID:
: ^3 K) h3 g' E9 m. z
) V' R3 i# S/ Z( C; s# m5 `
' J( d: y) Y9 O" s标号 | 中断ID | 描述 | NonMaskableInt_IRQn | -14 | 不可屏蔽中断 | MemoryManagement_IRQn | -12 | Cortex-M3内存管理中断 | BusFault_IRQn | -11 | Cortex-M3 总线Fault中断 | UsageFault_IRQn | -10 | Cortex-M3 用法Fault 中断 | SVCall_IRQn | -5 | Cortex-M3 SV Call中断 | DebugMonitor_IRQn | -4 | Cortex-M3 调试监视中断 | PendSV_IRQn | -2 | Cortex-M3 Pend SV中断 | SysTick_IRQn | -1 | Cortex-M3 系统Tick中断 | 2 ?, h+ T0 I% K6 @4 X$ `. D
外设中断ID: 标号 | 中断ID | 描述 | 标号 | 中断ID | 描述 | WDT_IRQn | 0 | 看门狗 | EINT3_IRQn | 21 | 外中断3 | TIMER0_IRQn | 1 | 定时器0 | ADC_IRQn | 22 | AD转换 | TIMER1_IRQn | 2 | 定时器1 | BOD_IRQn | 23 | 欠压检测 | TIMER2_IRQn | 3 | 定时器2 | USB_IRQn | 24 | USB | TIMER3_IRQn | 4 | 定时器3 | CAN_IRQn | 25 | CAN | UART0_IRQn | 5 | UART0 | DMA_IRQn | 26 | 通用DMA | UART1_IRQn | 6 | UART1 | I2S_IRQn | 27 | I2S | UART2_IRQn | 7 | UART2 | ENET_IRQn | 28 | 以太网 | UART3_IRQn | 8 | UART3 | MCI_IRQn | 29 | SD/MMC卡I/F | PWM1_IRQn | 9 | PWM1 | MCPWM_IRQn | 30 | 电机控制PWM | I2C0_IRQn | 10 | I2C0 | QEI_IRQn | 31 | 正交编码接口 | I2C1_IRQn | 11 | I2C1 | PLL1_IRQn | 32 | PLL1锁存 | I2C2_IRQn | 12 | I2C2 | USBActivity_IRQn | 33 | USB活动 | Reserved0_IRQn | 13 | 保留 | CANActivity_IRQn | 34 | CAN活动 | SSP0_IRQn | 14 | SSP0 | UART4_IRQn | 35 | UART4 | SSP1_IRQn | 15 | SSP1 | SSP2_IRQn | 36 | SSP2 | PLL0_IRQn | 16 | PLL0锁存 | LCD_IRQn | 37 | LCD | RTC_IRQn | 17 | RTC | GPIO_IRQn | 38 | GPIO | EINT0_IRQn | 18 | 外中断0 | PWM0_IRQn | 39 | PWM0 | EINT1_IRQn | 19 | 外中断1 | EEPROM_IRQn | 40 | EEPROM | EINT2_IRQn | 20 | 外中断2 | 9 o ]- j( V8 p' {0 X
#ifdef STM32F10X_MD這是我們前面講過的不同的芯片型號,對應
, n1 ]; p, N& o! D4 T8 V% }著不同的中斷級別。請大家自行研究! * v. ^ D& R. `! L: v( f
/ |$ U. Y9 d y
ADC1_2_IRQn = 18, /*!<
. O9 j9 G- d3 i( y7 RADC1 and ADC2 global Interrupt */
/ g* b9 s8 ~+ }$ }5 R: e6 T* N. n S3 t2 m m" s
USB_HP_CAN1_TX_IRQn = 19, /*!<4 {2 T. M( H+ E% q5 _& R
USB Device High Priority or CAN1 TX Interrupts */
$ {5 }9 u/ p+ k) k Y% s |# ^! u
; q! U8 ^. y( M! |1 B4 I USB_LP_CAN1_RX0_IRQn = 20, /*!<
8 b9 P; H; C# \2 TUSB Device Low Priority or CAN1 RX0 Interrupts */
" c4 T1 S3 r2 {- u! A- q- s0 h7 n3 Z9 B) k K
CAN1_RX1_IRQn = 21, /*!<
3 n" \1 B F- c6 Y( c- ^CAN1 RX1 Interrupt */
; | L2 z- q- n
$ t0 q# K1 a: c! _+ ?8 ] CAN1_SCE_IRQn = 22, /*!<3 ^" V( e, Z X8 P
CAN1 SCE Interrupt */
0 x f" S& @. H3 m% j- B2 @9 @) _' Z1 o5 b% G. S
EXTI9_5_IRQn = 23, /*!<0 x4 e; u5 {& a1 \5 l
External Line[9:5] Interrupts */8 B) G1 @2 U. x
- T+ y) F3 T; A$ H TIM1_BRK_IRQn = 24, /*!<$ N( v: j! F S2 |
TIM1 Break Interrupt */( v' v z$ G! B/ O! h7 s
3 l8 x8 z2 H4 b) X& Z; U
TIM1_UP_IRQn = 25, /*!<: v% ^3 U2 N) t6 C5 U. X
TIM1 Update Interrupt */4 `8 O. U& k5 {3 S! h3 b3 {
2 R ^/ j8 A6 t
TIM1_TRG_COM_IRQn = 26, /*!<1 T6 ]. z6 I5 c1 P+ g
TIM1 Trigger and Commutation Interrupt */( M" b) `% B9 m1 b2 y) V0 F
2 K* x% I9 s' u( U/ T+ ~
TIM1_CC_IRQn = 27, /*!<0 y2 z( I1 y* u3 X1 R: _
TIM1 Capture Compare Interrupt */
; Y6 [& n* o) J2 b' r! y5 g
; _0 i2 u6 j' D6 T+ k! y- [' A; H/ p TIM2_IRQn = 28, /*!<
* ~% D$ U+ f: O" ] TTIM2 global Interrupt */; M* s9 z6 y! {' Y* u5 f. W
0 _7 s# d. w; }
TIM3_IRQn = 29, /*!<2 ~: {' [- T6 l( ?- v4 ]7 C
TIM3 global Interrupt */
$ L3 A' i$ \. w0 O& _$ ]2 b: K" P
TIM4_IRQn = 30, /*!<
$ m) D. {# m6 L) @' lTIM4 global Interrupt */
% y# X' ^% `( J. ? e) I
: y/ a) t0 y2 f: G" ?& n# s I2C1_EV_IRQn = 31, /*!</ k: a9 y9 g- a9 Y
I2C1 Event Interrupt */3 l% d. ~6 a& W g; B, e' i1 k
1 p" z" L! j' b9 ]; Y I2C1_ER_IRQn = 32, /*!<, w) D$ q. v/ {! l8 [" S2 i
I2C1 Error Interrupt */
, B1 E" o& X/ j& q8 }% U9 w2 {
* A8 a1 S$ A( z" s( D+ W I2C2_EV_IRQn = 33, /*!<5 h+ T' N5 N! h8 }, v, _
I2C2 Event Interrupt */6 X$ i/ T+ Q! p& G/ G
! J9 ^) m# ~, c6 \" P& r I2C2_ER_IRQn = 34, /*!<: S: X; r# W+ n/ a% O2 `$ J
I2C2 Error Interrupt */
6 G; J3 T) N& {- k8 x* s1 }: A4 z) X# A$ E
SPI1_IRQn = 35, /*!<! r, Q4 H$ c" M8 C" ~
SPI1 global Interrupt */3 Z- V- p! l% H1 T1 ]' N, ]. ~
' F* u- p G' j& u) p) j/ p) r SPI2_IRQn = 36, /*!<! R0 _& _4 B( U3 {; o+ N
SPI2 global Interrupt */
( ?3 v9 `& d5 N0 T6 c8 d3 t8 g2 i, q7 `( h, w
USART1_IRQn = 37, /*!<
5 m; O- Q2 o0 i2 T) wUSART1 global Interrupt */6 R5 l2 W& k# C
: Z6 [0 |) ?9 Z4 [7 k/ ]9 x
USART2_IRQn = 38, /*!<
7 u' j- Q/ h2 RUSART2 global Interrupt */
# e, R3 D1 I# A+ J c3 \4 N
6 F- e1 D" @5 ? s0 V# D7 } USART3_IRQn = 39, /*!<6 i( r1 ]6 I/ X& r, P- \/ G! i% F
USART3 global Interrupt */
! V/ s0 ?4 @" ~1 g% I$ X3 G
& c) q5 M7 }+ w( z4 e/ d* X7 L EXTI15_10_IRQn = 40, /*!<
$ D% a3 B" `& S" H" K/ IExternal Line[15:10] Interrupts */
- N4 S6 F" y) c K
, o6 P" p3 j# }4 m% C8 Q1 J' P+ f RTCAlarm_IRQn = 41, /*!<
4 K% Y* b. A2 t' a( [3 qRTC Alarm through EXTI Line Interrupt *// R$ g) p2 U: b
: C) a* {# U' q USBWakeUp_IRQn = 42 /*!<) s. r3 Z ?$ h) h
USB Device WakeUp from suspend through EXTI Line Interrupt */
- \* M d3 _' N5 W
( o7 \* Y# o1 u; }& ]7 T9 `#endif /* STM32F10X_MD */ % k* ^8 q* G, {9 \6 _* ]
* `% I* N( I2 N8 `0 B8 m. h
, I, o6 d8 y t
?! \) q$ y9 V8 X2 T" Z#ifdef STM32F10X_MD_VL這是我們前面講過的不同的芯片型號,對應2 p1 e: G+ n# W* j+ |% H b
著不同的中斷級別。請大家自行研究!
9 a& w, k* M( U1 m1 X4 A/ N6 z# X
ADC1_IRQn = 18, /*!<
1 i8 h+ v+ z% O# n+ h8 R5 l S+ MADC1 global Interrupt */
' s6 N/ l8 `" L9 r1 ~7 G( `5 }$ h$ W \4 w
EXTI9_5_IRQn = 23, /*!<
% o8 ^; |; X7 U0 d. Q5 I$ X* pExternal Line[9:5] Interrupts */
' `3 o z% h) I( ]' V5 ]. P1 G5 i v7 s6 M
TIM1_BRK_TIM15_IRQn = 24, /*!<
6 c6 E0 C' o1 a# R) P2 S8 l0 v! aTIM1 Break and TIM15 Interrupts */; o; [9 y! @. g0 E$ Z
$ U9 `2 ^$ U0 k/ } TIM1_UP_TIM16_IRQn = 25, /*!<* X! Z7 d7 e/ t6 Q! Z) \! d
TIM1 Update and TIM16 Interrupts */: ~& `" i1 J$ Z2 A& G/ ]1 i6 \
# G- P% L k* M' k# M TIM1_TRG_COM_TIM17_IRQn = 26, /*!<
6 O3 @: _( e4 W0 U" J; DTIM1 Trigger and Commutation and TIM17 Interrupt */
5 W3 N7 W v" q) q$ t) k/ B9 V$ F6 ~' F. D
TIM1_CC_IRQn = 27, /*!<
( U! x2 P6 c/ N4 B4 e1 t5 D+ c0 cTIM1 Capture Compare Interrupt */$ c0 |# T8 [" y
$ d5 [$ G: g- K0 y# v2 L TIM2_IRQn = 28, /*!<
0 K5 k, m* W( m. R- [6 l+ u$ t0 GTIM2 global Interrupt */
( ^5 S( p% o( {
& i; I9 p. H( o# F& \, C6 U TIM3_IRQn = 29, /*!<
0 y2 `6 I6 e! a+ g( `# \TIM3 global Interrupt */
# t, t2 f7 ]/ [0 I( F4 H. W. T! H2 F4 V& [. a$ G, s5 \5 \; D1 `
TIM4_IRQn = 30, /*!<6 ?* J3 Y( X# t3 s% c' `
TIM4 global Interrupt */
8 ]) T2 a! y; {8 ^
' l7 _$ ^/ Y2 E I2C1_EV_IRQn = 31, /*!<8 C9 p# E" I5 W
I2C1 Event Interrupt */: L: f/ {9 c4 j" t1 n
' x8 g$ h$ \* T, N I2C1_ER_IRQn = 32, /*!<# R" F+ S7 [ w: D" x3 A
I2C1 Error Interrupt */
# z4 b( E: A; u: K
) l4 H- r. d( n( C3 v( i I2C2_EV_IRQn = 33, /*!<* m: ~* B4 C; F! J
I2C2 Event Interrupt */, v. ?- u) V# i1 K9 A0 J! P) ^& s
9 M- X6 c% X, Y, ~2 H' `2 G# r I2C2_ER_IRQn = 34, /*!<
& P5 n( g( E- qI2C2 Error Interrupt */
* |; t5 ~' p8 a( d( [1 a$ S. z, U: s
0 X& N& l9 |8 W1 |3 p8 o SPI1_IRQn = 35, /*!<, X, R! h' |7 t" A: X, g
SPI1 global Interrupt */. K% c) _. b% u ?! k* {
0 ?) [4 I3 M: w9 K1 r ? SPI2_IRQn = 36, /*!<
7 S* b" [0 w8 x0 W; p K9 ] wSPI2 global Interrupt */
# w1 O! r W* A6 c
* z, f3 B( r; t7 \) V4 V USART1_IRQn = 37, /*!<
' B% z6 b8 ~% } a1 D zUSART1 global Interrupt */3 z! t) h2 O$ R4 t4 M! k
, M1 O' x4 J" S$ R" y! f' A" Z% J USART2_IRQn = 38, /*!<; m/ f2 |# [# `% d
USART2 global Interrupt */5 Z1 g2 L$ t& W% e. U( w! V$ S, m
& s; w/ q6 q7 q! w# ^ X5 a
USART3_IRQn = 39, /*!<
* J' t7 `3 b m. `: x* a* xUSART3 global Interrupt */8 \, S( Q. e/ b5 \/ ]
: }# K2 \. C$ r6 I
EXTI15_10_IRQn = 40, /*!<5 p6 L4 E5 `* j
External Line[15:10] Interrupts */; v9 m" D' U1 r( S) V
* \' E6 v: ^( t9 n RTCAlarm_IRQn = 41, /*!<0 b& c0 i( g6 H6 N
RTC Alarm through EXTI Line Interrupt */, m" W! `- \, E# C+ L, d9 \
8 v3 |" s, z( m: Q( Z
CEC_IRQn = 42, /*!<, X3 K8 @8 D. \9 ~
HDMI-CEC Interrupt */' d" x/ y- [ ]
( U, E& R* g u0 X4 y9 j+ U TIM6_DAC_IRQn = 54, /*!<$ F- ~* j2 G5 x5 o) T! Y0 |
TIM6 and DAC underrun Interrupt */7 y s- ?4 F1 ^: F/ \9 b3 `
# z8 m3 d z f- b- { TIM7_IRQn = 55 /*!<
& u' h( `* K7 ITIM7 Interrupt */
+ z q1 H- |7 ?& P0 J0 E; F* Q4 a$ i7 C9 _+ s3 r
#endif /* STM32F10X_MD_VL */
# g: X" v2 h( D8 s/ I: b: T2 A J0 V7 A" N& u
! s. ^5 D: T% \- ~6 l; x6 F+ U/ L/ F2 r
我們通過這個枚舉類型,可以知道系統所有的中斷都在里面,而且可以了解它們的ID,這就代表了它們的中斷級別。
' ]# b( v- r* Z" b8 d
* V- o- P$ Q/ M3 p/ i1 ]6 }8 n) g/ Q4 [/ ]
& `: ?7 y$ n) s: [———————————————————————————– ———————————————————————————– #include “core_cm3.h”STM32的内核是ARM CORTEX-M3,这个core_cm3.h包含的是一些内核相关的函数和宏定义,例如核内寄存器定义、部分核内外设的地址等等,其对应的是core_cm3.c文件。初学可以不管他,只要把它包含进工程里就行了,这里都是非常底层的函数,上层的一些函数直接调用它们了。如果对CORTEX-M3内核有兴趣或者基础较高,想深入了解这些函数,可以仔细研读一下,我们在后续的开讲中会仔细讲解这一个文件的内容。
0 Y/ N# d: {/ I+ ~4 w8 M1 ^#include “system_stm32f10x.h”这个文件就是我们现在所讲的文件了。
l' E K% u" u2 d9 g1 Q0 j& @5 n#include <stdint.h><stdint.h> 定义了 int16_t 、 uint32_t 、 int64_t 等整型,在需要确定大小的整型时可以使用它们代替 short 、 unsigned long long 等,在 C 整型中,只使用 int 。- W; F1 s9 q: M
0 N9 A' ]1 N2 V r# d) N5 ~/** @addtogroup Exported_types
, _ x, y/ z* S/ C* k" w. T * @{
1 c& l; t$ |' }. v" [ */ 6 M- @4 i3 @3 Y0 N$ X$ Z; `$ L
' K8 ?# `. u- x* A, h/*!< STM32F10x Standard Peripheral Library old types (maintained for legacy purpose) */由于新的文件与老的文件会有不兼容问题,所以要转换变量类型。
6 N- b. f' b1 G: Z$ i1 U/ s R& Etypedef int32_t s32; typedef 在计算机编程语言中用来为复杂的声明定义简单的别名,与宏定义有些差异。它本身是一种存储类的关键字,与auto、extern、mutable、static、register等关键字不能出现在同一个表达式中。
- x3 ~# [- V& I; z- i4 G- V《变量类型》,3.0以后的版本中使用了CMSIS数据类型,变量的定义有所不同,但是出于兼容旧版本的目的,以上的数据类型仍然兼容。
" B, T9 I! p1 |4 O2 {CMSIS IO类型限定词 IO类限定词
6 i7 R4 ]# e& n; }9 E! G | #define
2 h6 @. l8 V6 [/ a0 K b | 描述6 r W# e3 p$ h" w! }: \6 r
| _I
( y% ~4 k0 j9 _$ k4 Y | volatile const; _( k. C& [9 F9 ~$ ^! U3 G
| 只读访问0 Q! g+ l0 K- G+ l9 P3 |6 f
| _O
% g% {$ c3 ]8 o; |. B, I) D- k) I | volatile2 ?2 P9 \" C* A; N9 u: r3 Y z
| 只写访问
& n( l5 l+ ?" m) K: S7 J& f1 Z" j | _IO8 h. ?' V, C5 a! {
| volatile" l/ d& J- F# j! {' H
| 读和写访问4 w$ F/ W/ e7 M" u _3 L
|
& b6 a3 e. p( @件库与CMSIS数据类型对比固件库类型
- _) Z, m1 Q$ S& E9 u | CMSIS类型 {$ ]. @' J h7 A8 e( r
| 描述3 d6 G8 X; I# b' x" Z# _
| s32( s$ q& w. B8 ^* C8 R
| int32_t* T1 }& M3 M: d5 a8 f' o" T
| 易挥发只读有符号32位数据
) P9 r E7 A: w9 b7 S | s16
/ r7 e$ c+ f/ o1 x4 B | int16_t
9 N6 p* c. J* e" i/ y' u% H% R | 易挥发只读有符号16位数据
9 W8 o/ B u9 o | s8+ w, M. o$ b# M! g) ~4 ]
| int8_t
) {. B9 g& D- E, L | 易挥发只读有符号8位数据, E7 z$ \9 m, {$ f0 R# ^* i
| sc326 o* y. `6 q) ]# U* m: W: ^/ s
| const int32_t
* V6 \; l; i* x* U! @( e3 j | 只读有符号32位数据
$ k5 ?+ t( ?, Z/ H, q }" c | sc16+ P% w. L2 W! U; U. a7 w
| const int16_t; P& F$ q; \0 |. K9 ^
| 只读有符号16位数据
* K/ v% S. J2 M$ Y( U) x | sc8& c6 L2 }. v. Z t- a7 X& p) k
| const int8_t
4 ^ L% }$ n# I$ }6 u2 b! _ | 只读有符号8位数据
i8 |& S9 B; O, w. f) { | vs32
2 q+ W4 L4 w5 y, S- s | _IO int32_t
( z; a, C. Y* Z+ a3 T* m | 易挥发读写访问有符号32位数据
f1 O5 d0 ]8 b9 f* y | vs161 A4 Q G7 q' [3 b {9 j2 h
| _IO int16_t
% Z0 h; [! _4 b% w4 [ L6 F | 易挥发读写访问有符号16位数据
2 f9 Q3 j* M$ J( ~; U | vs8+ C! F" |8 x6 y/ M; G
| _IO int8_t
0 m8 {) ~' }- ^" Z | 易挥发读写访问有符号8位数据* b0 I' O. Z7 P' u, X7 A2 k4 A* Y
| vsc32
, w) U4 m0 Y) m3 v | _I int32_t; h1 P G4 M/ c: i, Y; I S( n: K1 U
| 易挥发只读有符号32位数据
8 `$ P5 d* f2 _, ^- w- [" K: o | vsc162 Z! o- s( ~" |0 t- T
| _I int16_t' T3 k7 h8 I" x r5 R/ J
| 易挥发只读有符号16位数据! G [: B, U3 D( U7 g. c& b0 i
| vsc89 [2 m2 x) }4 I2 `: W
| _I int8_t
# ?0 Q3 Y8 I, C2 X8 I t | 易挥发只读有符号8位数据4 w, k1 H! X, i0 @# |
| u32
6 c H; V. Y1 d+ K, G) F6 A | uint32_t
: `' }0 s {8 T2 D | 无符号32位数据9 x8 t* t5 g7 ]! T/ h. H/ n- m- M
| u16 m: c8 T4 [0 g5 w" o" s4 i( `+ o
| uint16_t
% \4 i/ R/ u! I2 C) r& B( O7 [4 V2 G | 无符号16位数据& P' P1 a1 F, y
| u8) Q) U% w( i" ]+ L
| uint8_t* a+ t$ `7 A0 l; H7 d
| 无符号8位数据
- Y" `. U- K$ ^) f1 C! u7 f | uc32! R# p# m* b* ?, i4 D
| const uint32_t
+ V }7 U) W& H | 只读无符号32位数据
9 Z1 h' \ ~" T& F | uc16
; A) I1 j" D5 a) y0 L( k | const uint16_t
. l( O, H. s1 H* M/ q2 T) l- o5 Z | 只读无符号16位数据: ^+ S9 \" G* C0 G- c7 o
| uc82 H1 W2 s8 S" M9 g8 l
| const uint8_t
' E! R* [2 K1 j: x' X | 只读无符号8位数据
; ]; [& a' Y8 N6 Y; J" P- ^# F; {# L! t0 Q0 g | vu32
: n( l X! K" E | _IO uint32_t* |# b/ r0 z# V; T( Z7 C! Y
| 易挥发读写访问无符号32位数据
2 ^" i J$ y6 q6 t4 [/ f | vu16
2 J; a+ X, r; l- {, ] | _IO uint16_t. A$ c+ A, f7 G: ^$ r
| 易挥发读写访问无符号16位数据' F9 J" L* r6 @
| vu8
1 D, @9 |' `! j% n# V | _IO uint8_t% C5 \# N$ _" y' y, U& Q
| 易挥发读写访问无符号8位数据8 Q. E+ u2 q E7 N6 G. v. _, m
| vuc32( d _6 v8 E1 s+ u$ C
| _I uint32_t1 d( M9 ]6 ` G6 e- Z! s" N
| 易挥发只读无符号32位数据7 J4 E8 P" R: e' h0 q J
| vuc16
: U, a- O$ Q- f" F5 r1 f | _I uint16_t
6 _# G$ B2 S5 a: A1 B | 易挥发只读无符号16位数据
$ X& A3 Y; q- u0 J | vuc83 _$ h$ q& c' f# `0 |' @* Q, `$ j1 x
| _I uint8_t) b5 l; f& n8 F8 u4 M: M! p5 Q- R
| 易挥发只读无符号8位数据( }; e9 M/ b8 _* y; K# W
| ( Z# H$ t- ^1 v! `( z6 k
" T }$ z- \( `. W! O $ @* L4 O6 N3 p
stm32f10x.h文件中还包含了常用的布尔形变量定义,如:
0 q# m+ c" r$ x H* {1 typedef enum {RESET = 0, SET = !RESET} FlagStatus, ITStatus;
; N& B* P i# u# U3 S2 0 u& A3 |( M! _( J
3 typedef enum {DISABLE = 0, ENABLE = !DISABLE} FunctionalState;
6 E- Z* v9 _1 U7 { U$ F( J3 L& ]/ C4 k4 # g, L- f( v4 g% b# d3 V
5 #define IS_FUNCTIONAL_STATE(STATE) (((STATE) == DISABLE) || ((STATE) == ENABLE))9 U( v5 H, u* [# @- q, s2 t
6
$ }# P- \) Q: b# I7 typedef enum {ERROR = 0, SUCCESS = !ERROR} ErrorStatus;
. W! M' K5 h) } S! w
不同版本的标准外设库的变量定义略有不同,如3.4版本中就没有之前版本的TRUE和FALSE的定义,用户也可以根据自己的需求按照上面的格式定义自己的布尔形变量。在使用标准外设库进行开发遇到相关的定义问题时应首先找到对应的头文件定义 。
( |) C' a/ s7 S0 e5 K0 W
! W/ i! D @; x& V" M0 A4 _
5 o% h! r. \7 ~8 n. z$ R$ b4 a5 Mtypedef int16_t s16;' ?9 \5 v, X9 @3 n I& x
typedef int8_t s8;
: s1 l5 ] h9 l- [8 L8 itypedef const int32_t sc32; /*!< Read Only *// @6 K# G3 \/ q' y
const是一个C语言的关键字,它限定一个变量不允许被改变。使用const在一定程度上可以提高程序的安全性和可靠性。另外,在观看别人代码的时候,清晰理解const所起的作用,对理解对方的程序也有一些帮助。另外CONST在其他编程语言中也有出现,如C++、PHP5、C#.net、HC08 C。 ( J5 J. x5 U& I e6 a8 w. X
typedef const int16_t sc16; /*!< Read Only */8 Q2 y- H U1 J. Q( a
typedef const int8_t sc8; /*!< Read Only */
+ _# o3 d) q3 p1 ?
" D' y% L/ C3 {: |) Otypedef __IO int32_t vs32;- u; e! W0 p* U0 ?% v Z7 f
typedef __IO int16_t vs16;
9 k) E8 }, o( `5 U2 z+ Utypedef __IO int8_t vs8;
1 l1 `. y2 d+ X/ f' K& ~1 e- f! ]
typedef __I int32_t vsc32; /*!< Read Only */6 G3 `- @" ?7 G0 r& l& ~
typedef __I int16_t vsc16; /*!< Read Only */; r: c' m, h7 o' `$ f0 ^% m# A, S
typedef __I int8_t vsc8; /*!< Read Only */
& V( J% _1 {4 I9 d7 l
# B) |0 g% z# j+ y8 s7 b/ [typedef uint32_t u32;
7 k- E: N% Z6 y: j$ o* ktypedef uint16_t u16; D9 r7 p2 m" Z) z: B) x! U/ o
typedef uint8_t u8;% a0 ]& j C. Y3 _- G
8 A3 i! j1 ^& {, p0 \typedef const uint32_t uc32; /*!< Read Only */
. ?+ A) K+ z2 ]6 P8 z( `$ gtypedef const uint16_t uc16; /*!< Read Only */
. B& H: a% S7 }) y6 Ttypedef const uint8_t uc8; /*!< Read Only */
# u2 H3 h7 B" a/ Q: c; @9 y# l! _& s+ Y5 `1 B8 I
typedef __IO uint32_t vu32;
/ @1 u' O8 y) ?! w Y Ptypedef __IO uint16_t vu16;4 L+ I0 u3 X" B& m0 G6 H9 x
typedef __IO uint8_t vu8;+ I" P3 m/ I2 O) G8 }0 y6 _
$ }9 n5 z$ g( g# n# ?7 v' {
typedef __I uint32_t vuc32; /*!< Read Only */
/ p8 k$ r7 J6 T) J& |, N7 e1 l0 Xtypedef __I uint16_t vuc16; /*!< Read Only */
* ^# g `8 t P# X& L+ j" p; ntypedef __I uint8_t vuc8; /*!< Read Only */
+ O) y3 y4 b2 N H4 L, ]4 C" S
5 e! J9 o- X1 k; R0 Qtypedef enum {RESET = 0, SET = !RESET} FlagStatus, ITStatus;! O$ a$ O9 p5 S1 j6 ~; P, v
9 u5 m) h% z" \9 |
typedef enum {DISABLE = 0, ENABLE = !DISABLE} FunctionalState; s8 z; D2 y; p
#define IS_FUNCTIONAL_STATE(STATE) (((STATE) == DISABLE) || ((STATE) == ENABLE))
) F9 S# Y+ [) P/ l# E$ ^
: ]1 Q- q* x2 E1 Ctypedef enum {ERROR = 0, SUCCESS = !ERROR} ErrorStatus;
9 n+ D9 v, A* D( l+ M: X* E& x; F; c' A- T" g1 z: ]" O5 }
/*!< STM32F10x Standard Peripheral Library old definitions (maintained for legacy purpose) */# t+ ^ K; z4 f. f5 y* H2 L
由于新的文件与老的文件会有不兼容问题,所以要转换变量类型。
% a. w6 F) x. r: `9 o3 O#define HSEStartUp_TimeOut HSE_STARTUP_TIMEOUT 请大家注意这里的定义,高速外设时钟的启动时间。: B+ f3 F' q# o T% j
#define HSE_Value HSE_VALUE
' c1 A: l! h% o+ a1 x! E) H/ w#define HSI_Value HSI_VALUE3 Q0 U6 o. b* ^8 X' V$ G
/**4 z, C7 A+ e( Y
* @}# F+ g# {9 { v8 i* Z3 d. Z
*/
8 u! B' a; F( Z- n5 C; k) y% T$ Q7 l3 a% h# d3 p4 v
/** @addtogroup Peripheral_registers_structures6 i/ P* h! ~$ Q- T, g
* @{
! H0 ~* \1 n% M* m$ ~' Z7 \8 t */
7 C8 \ k" H9 G. O& b2 E2 e, q
- ^7 v, K1 \' u2 J* t- u9 m/** 9 ?' S) N+ ~; D/ E" @. ]
* @brief Analog to Digital Converter
. r G# o% N+ H+ T! E( s& N */( {% I. F: w+ {) K) v; C1 }5 w
0 o' x& c% t; G: M. @5 T) ^typedef struct ADC_TypeDef结构体的声名,看看它内部都有哪些内容。请读者注意。# n( Q" v9 X) w9 [ k+ d& g# O0 ~
ADC_TypeDef,看起来是一个结构类型,是对ADC寄存器各地址的一个定义。 W O* n6 I1 {* U: e: E
{ __IO就是volatile uint32_t就是32位无符号整形数。
) i4 c( u# R/ x" P& ]& Q) d这都是ARM公司无聊滴在CMSIS库里面定义的。STM32库1.x 2.x都没有这玩意,到了3.0以后引入了CMSIS就有了。 __IO uint32_t SR; T$ j) l6 ?+ s7 e9 {: T
__IO uint32_t CR1;
+ d- M6 V! A$ m2 X s __IO uint32_t CR2;
% m, F2 b P: d1 }& U" O8 N __IO uint32_t SMPR1;' c; m% T* @: [6 v
__IO uint32_t SMPR2;
' {3 f- D; M% r# u( E8 S0 o __IO uint32_t JOFR1;
, }* F' w: w: y5 O* `- e __IO uint32_t JOFR2;
- ] s1 K+ _0 [6 g4 G$ f; h; { __IO uint32_t JOFR3;
, v% h8 |' ?# V, \* f2 V __IO uint32_t JOFR4;
! `+ F4 u9 M: a3 d) @7 r- k( s __IO uint32_t HTR;
# _1 S0 X/ h( |6 p c0 L __IO uint32_t LTR;
% g0 o( L7 c4 H, o9 U __IO uint32_t SQR1;5 q7 S: j+ c* V7 {
__IO uint32_t SQR2;& C$ G% M' y( ?
__IO uint32_t SQR3;3 m. ]6 S+ M4 S& r t
__IO uint32_t JSQR;
1 W: [5 J8 C! G% B __IO uint32_t JDR1;
/ f: ~) l) M9 ~3 d4 q __IO uint32_t JDR2;) Z; v6 N% V2 J8 C
__IO uint32_t JDR3;, A$ ?, V4 U8 o1 Y U) e9 a% A
__IO uint32_t JDR4;' E; G- r. }! D7 \. u% H
__IO uint32_t DR;6 J* g" x8 ~2 K5 v8 J
} ADC_TypeDef;% e- d5 X9 Z$ r, @
9 e9 E8 [8 l- q1 H$ f
/** 7 Y. s3 [8 m) [ ~* s$ b
* @brief Backup Registers
% q% a' |' Z) v& `, v( u, ` */$ j5 a$ a( M$ J
9 k" K8 o. x T0 Qtypedef struct 这个结构体声明的是数据备份寄存器,它们是16位的。它可以管理防范入侵,可以存储RTC检验值,可以做数据备份。
9 y1 Y( U! b3 r* K: g{
7 n& l# d! H) Y$ _" h5 o: l, W, l" { uint32_t RESERVED0;) j' m. p; t9 C! |( D
__IO uint16_t DR1; DR代表数据备份1—45
1 @( y: c7 V9 D% d) C5 { uint16_t RESERVED1;* u+ Y- l2 T7 c4 Q+ j* {% X
__IO uint16_t DR2;
4 {; N) E' }4 E& ? uint16_t RESERVED2;
, ], L8 q. W8 A: C __IO uint16_t DR3;
- ^5 N, p, G, Z$ c+ N uint16_t RESERVED3;
0 P, ?/ _9 k% k/ X __IO uint16_t DR4;
' H2 Q2 ~+ F& p uint16_t RESERVED4;5 b6 J0 N# ~# ^. Y' g* B+ s" x
__IO uint16_t DR5;
# [2 Y" p* t% Z$ G9 E7 } uint16_t RESERVED5;) K" ?& p2 B( s9 _0 i( R. N
__IO uint16_t DR6;
8 I% W( G6 d7 t uint16_t RESERVED6;
" I+ D* ~3 d2 v. I __IO uint16_t DR7;
3 a1 }$ R q3 |' l uint16_t RESERVED7;
' u& ?. f% K: {5 D% K2 D __IO uint16_t DR8;" k5 `1 _! v% {: u. c& t5 v! P
uint16_t RESERVED8;3 g+ d8 L' x b
__IO uint16_t DR9;
" a! X+ s2 m, I7 A2 K uint16_t RESERVED9;
$ l& r9 }% l2 D) K/ l __IO uint16_t DR10;) j7 ?& B/ L0 C
uint16_t RESERVED10; ' v& S+ T9 p: f+ j
__IO uint16_t RTCCR; RTC时钟校准寄存器
/ i2 [5 R- L$ f4 z% t% i uint16_t RESERVED11;
! [/ e6 Y' M4 V2 y1 V3 ~, F1 z __IO uint16_t CR; CR备份控制寄存器
4 N7 D" W8 T# ^6 I5 V" k uint16_t RESERVED12;+ [ p: e' ^1 J3 U; @5 H9 t% F* k, X! D
__IO uint16_t CSR; CSR 备份控制状态寄存器 5 l9 U3 M) F4 s
uint16_t RESERVED13[5];4 c F" p4 }- g0 ?) W+ N
__IO uint16_t DR11;2 [* t2 F g0 \* A% S1 S
uint16_t RESERVED14;
2 H# @7 a9 }! U0 @: R __IO uint16_t DR12;
j* m; E7 s$ c& C5 M4 ]3 z, ]) M uint16_t RESERVED15;
! o* u. R9 v& x& X2 d1 a1 j, \ __IO uint16_t DR13;: u8 [, @/ T7 _& T) K
uint16_t RESERVED16;
$ \& V& j; P) b __IO uint16_t DR14;
+ A7 N5 I! ^9 u1 T% ~) |/ W& ` uint16_t RESERVED17;
4 K/ X4 ^. j7 A2 E; y __IO uint16_t DR15;
9 h' A9 \ Y5 p5 s- B uint16_t RESERVED18;9 j& r" J8 j2 g4 L; x
__IO uint16_t DR16;
' c7 p4 }! D+ ^" f2 [. \ uint16_t RESERVED19;# l9 _2 \+ I/ Y9 n
__IO uint16_t DR17;
( S+ q' N P* q l uint16_t RESERVED20;
1 w) C4 k5 g7 g) u# y8 ` __IO uint16_t DR18;0 L( B/ s k9 Y Y8 A
uint16_t RESERVED21;8 @: j, v6 h2 z6 V
__IO uint16_t DR19;
% y& c7 a' t3 \+ M( c' q% q1 C uint16_t RESERVED22;
7 `3 |# P0 O7 |1 E9 g __IO uint16_t DR20;
1 I5 s) F3 L7 j uint16_t RESERVED23;) B5 ~& e& N2 O5 x! E$ D5 o
__IO uint16_t DR21;
# s+ S I6 t5 \0 n' a W uint16_t RESERVED24;- I$ C) j) o& ?, V5 S
__IO uint16_t DR22;6 n' q8 F' s& J) S
uint16_t RESERVED25;/ m) ~% C8 Z! X s2 c; e. y7 D
__IO uint16_t DR23;
0 ^/ L S4 V& w9 s- U7 N; m uint16_t RESERVED26;
1 r: x6 N: F3 X j8 o& W __IO uint16_t DR24;, u- n I6 b2 p4 r
uint16_t RESERVED27;
2 E8 ~3 e+ z; t" W b4 f k/ [ __IO uint16_t DR25;8 ?+ }) D* q$ V' ?9 v( r
uint16_t RESERVED28;8 x! Q: p* _1 ?7 ^) @
__IO uint16_t DR26;; {1 t& l+ |4 @; E1 V3 x
uint16_t RESERVED29;
" L+ K' O+ Q- Z+ M, ]( v __IO uint16_t DR27;
5 c4 \6 R/ a0 B2 ~9 T0 A uint16_t RESERVED30;
! Q. M: ] w/ p9 h __IO uint16_t DR28;
2 \/ h9 s' W* W1 } uint16_t RESERVED31;
P- Y) B a B. `# I( _6 M2 N" v __IO uint16_t DR29;2 p+ L" x. }1 B3 b! [) F
uint16_t RESERVED32;
2 m- h; e3 j' Q1 o" e9 w0 h __IO uint16_t DR30;
9 @( z" K0 j: x+ j3 P" g uint16_t RESERVED33;
* Z$ S3 y3 N2 l/ D+ ~& d __IO uint16_t DR31;
9 W8 U2 l* g+ ]/ v0 { uint16_t RESERVED34;
' H7 z* [9 u4 _0 [8 i+ h8 R2 a __IO uint16_t DR32;
) O' {7 p" Q( e; i# S; [ uint16_t RESERVED35;
2 v2 X8 S+ }% \2 U! |. e/ k9 N/ p __IO uint16_t DR33;5 w) i% u8 f) H4 _' V$ f
uint16_t RESERVED36;
2 W2 d1 G5 a; P* J$ g __IO uint16_t DR34;
9 Y% `2 N( p/ O1 p2 {; ^0 X) f7 {$ g uint16_t RESERVED37;9 o# i# m1 w6 S, V
__IO uint16_t DR35;
% m% b. Y; B& ^# U uint16_t RESERVED38;* l5 u8 e# q# B/ s: C
__IO uint16_t DR36;
" x3 z9 H, ~" A4 X" c uint16_t RESERVED39;
; }4 @) s1 t) \; G# @ __IO uint16_t DR37;
5 U4 ]: \9 K3 F5 y1 S0 i, I. P! \ uint16_t RESERVED40;
( B) m3 [/ G; ]. o; [* H __IO uint16_t DR38;
j [. {4 s0 }; d uint16_t RESERVED41;
& u7 ?, Q# e( m# g2 s' v" g# k __IO uint16_t DR39;
+ ]+ |3 E+ m! l uint16_t RESERVED42;
3 P# R3 V5 t& F% U4 n __IO uint16_t DR40;& p5 g7 I8 y3 `" Y6 x4 f
uint16_t RESERVED43;# e; s* O5 K% j" V7 W) n
__IO uint16_t DR41;5 a5 o5 j3 Q7 Z3 {: ?1 \! H
uint16_t RESERVED44;
$ ~6 u9 i+ S% R* i! m% _ __IO uint16_t DR42;
+ C) _+ X0 O! X. P+ F4 m) k$ a1 D uint16_t RESERVED45; 3 ]7 l# t1 }+ B5 J4 P; j6 p
} BKP_TypeDef;. b& w9 o/ z m+ [' x1 w
' e# x' s4 W- q/** ; v5 h8 }4 g1 T2 }9 X
* @brief Controller Area Network TxMailBox
2 k$ c1 M, X% z% H- Q */
) d6 d( T" g r7 q+ q) W9 R; g
& r9 V5 B7 |# I+ xtypedef struct
: K1 B+ e! b) V# p% X% [{) G6 \8 N2 G( w, q# ~ ^
__IO uint32_t TIR;+ F4 F5 R0 w$ V
__IO uint32_t TDTR;' V& \1 |3 M( Q
__IO uint32_t TDLR;
+ g2 X/ n8 s, t" z0 P' W __IO uint32_t TDHR;* W1 |5 x- R$ p6 V
} CAN_TxMailBox_TypeDef; CAN的发送邮箱寄存器的结构体定义。
- x5 a1 ?! m, A8 p) e8 q, {# J1 `! ]/ z. p8 G
/**
& [5 P8 J0 U* e& C5 ]. _ * @brief Controller Area Network FIFOMailBox
h6 d/ D5 t1 {5 f& K( @0 p */, C Z- c# y) h3 f2 y$ h# @
& y) B9 u2 ~, B5 o+ Z7 ctypedef struct* M7 }( z( e: }% w4 j8 [/ D1 E
{; h' X3 {0 C. q
__IO uint32_t RIR;
3 Y M0 `& u- } __IO uint32_t RDTR;
+ n7 o+ W( P$ w& ~% { __IO uint32_t RDLR;4 \$ Q) q! r0 K3 V& ]% {: ?
__IO uint32_t RDHR;
0 C7 |6 D0 P6 V. {5 B5 S) M} CAN_FIFOMailBox_TypeDef; 先进先出(FIFO)缓冲器,是一种寄存器。在这个头文件里定义了它的结构体类型。. g6 W- l3 r# O3 n* p8 d
6 [1 v6 C5 M8 v; K j3 S
/** 9 m! J5 G! J3 E8 T
* @brief Controller Area Network FilterRegister
1 D2 E0 R' ^& O: ^+ D y */
( R7 n% ]4 F( L3 @9 b
. @- s) q( r& ?8 \, v! dtypedef struct0 f# W5 w+ n. I/ A. g( t
{
( ]& _' ~ L! V8 ]$ ?% n7 ]& A __IO uint32_t FR1;7 E& U& K7 i# d" ~6 U
__IO uint32_t FR2;
; \7 C- V9 b6 L V}CAN_Filter Register_TypeDef; CAN硬件过滤器工作模式、访问码和访问码掩码。通过设置CAN过滤器,可以使CAN端口只接收符合规定的的CAN数据包,这样就能将CAN总线划分成若干网段用于支持不同应用。
# V* v! ?) R# N8 K/** ) [3 n7 X5 z$ i& a
* @brief Controller Area Network
|1 I, J! {, D/ f" @* N2 b */
9 m$ D7 [ a2 h- d5 j% B" R' ^1 k3 l) ^& { @3 p2 I: r
typedef struct+ ]: D; O F' U& E( N8 }
{
3 R9 z, z2 m/ g __IO uint32_t MCR;2 V5 [0 M/ S( o Y1 P4 S
__IO uint32_t MSR;
/ [5 W9 Q& v& Y5 z# W; ?4 I __IO uint32_t TSR;, c2 g7 W# N- _- j7 r
__IO uint32_t RF0R;
3 x/ D% J: K, e __IO uint32_t RF1R;# ^ M5 S! R2 O* N
__IO uint32_t IER;/ R7 T7 ~% c1 L6 P* x0 z
__IO uint32_t ESR;( x v, d" E* `9 R6 ~+ A3 H
__IO uint32_t BTR;
. o. h/ M1 a3 _6 w+ b uint32_t RESERVED0[88];
3 a# e: i# L7 m( \( U, V' q CAN_TxMailBox_TypeDef sTxMailBox[3];
2 ^! m% p9 [* M CAN_FIFOMailBox_TypeDef sFIFOMailBox[2];+ O- M. ^' ?# {' g0 J; o+ I
uint32_t RESERVED1[12];9 k& ]7 b4 S* [5 ~, n3 w/ L
__IO uint32_t FMR;- T4 J! l( C# f
__IO uint32_t FM1R;, a' s# b* o l" V3 n9 x$ R
uint32_t RESERVED2;, Y3 m9 C; Y: e: g
__IO uint32_t FS1R;& w: V) Q6 Y" C
uint32_t RESERVED3;
' {7 Y) y% W! K2 q4 m1 r) h* x __IO uint32_t FFA1R;4 a5 n* \7 {( k( G% ~& X$ @
uint32_t RESERVED4;0 c! Q2 R# Q. w ?% H4 n/ ^1 Z2 u# i
__IO uint32_t FA1R;6 u, z8 o% Y7 \% A/ N
uint32_t RESERVED5[8];
5 n/ |$ ~& v/ z) a6 G- Y#ifndef STM32F10X_CL: o; _+ O0 ^, l* {
CAN_FilterRegister_TypeDef sFilterRegister[14];0 P, X4 y" B. W0 S
#else6 e+ t9 D/ k: F; ]4 P" R7 m7 ~) V5 l
CAN_FilterRegister_TypeDef sFilterRegister[28];% Y' d5 y! W5 f0 s9 t
#endif /* STM32F10X_CL */ `' L" t# ]3 ~4 d2 j) y
} CAN_TypeDef;; b, K; I: t0 P7 \$ Y7 H
# _2 M+ V9 _! G& n0 y6 [
/** % l: ]9 e* k, e* ^% ?$ E1 h4 v
* @brief Consumer Electronics Control (CEC)( Z6 x+ ~) ~7 q5 v
*/
4 {# w: {( x4 x! Jtypedef struct
8 _; j( _. S& B& y$ x8 }" `% b{
/ c! f8 r) c( L1 `$ o& e" ~- I __IO uint32_t CFGR;+ @, Z' G% u8 U" u @
__IO uint32_t OAR;7 A$ Y$ o) ]3 J. h
__IO uint32_t PRES;
: J2 T4 p: {) t$ `% _ __IO uint32_t ESR;/ l+ j' d0 S# v5 _
__IO uint32_t CSR;2 p I! ~) {+ L1 ^* k! \8 F) u
__IO uint32_t TXD;
5 U- y( K* [$ Y! z3 s6 s __IO uint32_t RXD;
. Y- N, }( c2 h} CEC_TypeDef; CEC用于记录CAN总线发送数据错误的计数器/ v: ~) {/ ^* z: S v7 D
9 N8 Z9 @; ^, S2 N4 ]/ p" X8 W' H/**
: j* v7 S3 P5 v- z6 l1 _% I7 C * @brief CRC calculation unit
) v$ v/ J9 x$ R- } */
, V& [9 U; D' D7 v) ~" T" ]6 V1 f1 ? f; Q4 m" I! C
typedef struct
. w1 u. p: @0 B3 I( O{- w( d$ @) d) M: Z& ^; p
__IO uint32_t DR;
- Q- {4 B1 v3 k. z& I# i+ b __IO uint8_t IDR;" R3 M- L9 r" h; I* A( H7 D* p
uint8_t RESERVED0;
, b P+ t( i! v* G; d& ^( G' P" } uint16_t RESERVED1;
$ C" f5 S0 W ~; A& b, o __IO uint32_t CR;
# U4 F5 O, K) C1 ^( ~} CRC_TypeDe CRC校验) m" s3 I. B! j2 b
/ M! _' ~) y% E6 G* U! E
/** 7 L, Z$ a$ h7 o. V
* @brief Digital to Analog Converter 数模转换相应的结构体,DAC相关寄存器啊! ~) F+ M: p. G. W+ ~7 X
*/
. ?! K$ L- R% A* m/ Q# x3 i Y) _/ K
, g+ w) @" _; j: s, z; X1 vtypedef struct
! b5 ^: f+ e3 R' B% h{5 B. o/ ~, m1 @; N5 C+ V
__IO uint32_t CR;
" h( H$ ?' A2 j& @1 P' Z9 ` __IO uint32_t SWTRIGR; SWTRIGR 这个DAC软件触发寄存器
O5 s/ j% B& z0 l6 i __IO uint32_t DHR12R1; DAC 通道 1 的 12 位右对 齐数据保持寄存器:DAC_DHR12R1。这个我只讲一个,这里面全部是关于DAC转换的相关寄存器。请大家自行对照硬件手册查找。0 ^% U- C7 N* U. w: H
__IO uint32_t DHR12L1;! J3 \! ~1 s. q/ g4 g# X+ q
__IO uint32_t DHR8R1;6 b/ q/ h/ O) `2 ^9 M2 U
__IO uint32_t DHR12R2;
) g4 O6 W! p' q& N; y3 c K __IO uint32_t DHR12L2;9 z2 O; C9 y" a1 K
__IO uint32_t DHR8R2;, k% c! L0 b4 C- n5 Z/ I3 c: J
__IO uint32_t DHR12RD;
, A% g/ s8 Z) q- D1 M; v __IO uint32_t DHR12LD;
# G' Q2 [2 a' [ k __IO uint32_t DHR8RD;/ k' u0 G7 s; X5 W
__IO uint32_t DOR1;
* L/ P. h' @5 Q. n- e __IO uint32_t DOR2;
- x& j5 ]9 Z0 R$ H#if defined (STM32F10X_LD_VL) || defined (STM32F10X_MD_VL) || defined (STM32F10X_HD_VL)! N' l5 B5 t% K7 r0 w6 ?9 i: {" x
__IO uint32_t SR;
$ B# P0 F% @! F* c3 J0 \#endif. h0 }4 O0 ^2 D9 `- P- T
} DAC_TypeDef;
# I; Q9 e v& q" C$ @" W# R W. x4 M/ W
0 M9 w A. }- O$ U3 W [————————————————————————————- ————————————————————————————-
! g7 S! O; ]; S: I4 S. R/** ! i9 K8 M8 H" W; T6 I( U m, A( }
* @brief DMA Controller DMA 传输将数据从一个地址空间复制到另外一个地址空间。当CPU 初始化这个传输动作,传输动作本身是由 DMA 控制器来实行和完成。典型的例子就是移动一个外部内存的区块到芯片内部更快的内存区。像是这样的操作并没有让 处理器工作拖延,反而可以被重新排程去处理其他的工作。DMA 传输对于高效能 嵌入式系统算法和网络是很重要的。
7 Y4 b' y7 }6 I; s) A4 dDMA 在实现DMA传输时,是由DMA控制器直接掌管总线,因此,存在着一个总线控制权转移问题。即DMA传输前,CPU要把总线控制权交给DMA控制器,而在结束DMA传输后,DMA控制器应立即把总线控制权再交回给CPU。一个完整的DMA传输过程必须经过DMA请求、DMA响应、DMA传输、DMA结束4个步骤。 */ & f) {( v2 B/ e! M. d7 F' Y6 o
7 n# v4 N7 W$ Dtypedef struct 这里就是直接内存寻址寄存器相关定义,我想DMA大家应该不是太陌生。
6 z5 v" a. z5 _+ j P# b! C{ : X2 K. V& Q _1 X9 U9 \
__IO uint32_t CCR;
. [+ i+ |( p8 z; E& z# D __IO uint32_t CNDTR;
* x8 I* q2 i6 R* {4 v: ?) S __IO uint32_t CPAR;
6 n1 L4 N/ i$ J7 D) ~ __IO uint32_t CMAR;
6 K, o8 [2 L$ `7 Q! h0 _' |} DMA_Channel_TypeDef; ( \+ W' p9 g, l3 l' \
' Z, u" f9 R. ^
typedef struct
$ B' \, ]- u4 F* o" e{
' i; I) U( r& r' l" O& @- w; H, a __IO uint32_t ISR; * W; W+ p) C0 A6 r1 `$ `
__IO uint32_t IFCR; 5 l* X) b2 l5 R& j
} DMA_TypeDef; , M" N) `4 t) @3 X$ ^8 k+ L) |
+ D& o+ n" O4 S/**
; ? P* y2 L4 U9 |$ ]) @ * @brief Ethernet MAC
8 r M& V' w$ b */ MAC(Medium Access Control)模块,实现符合 IEEE 802.3 标准的 MAC 逻辑。 这个结构体是网络模块的相关定义。 " _; r3 D+ R; f# o" Z% c. ^9 P
8 T9 B, v( e" g* d$ @
typedef struct
6 P5 ]% i1 {& o3 w* L" Y0 ]' d; S! @# L{
8 Q3 D- Y' O' Q2 t& v+ M __IO uint32_t MACCR;
7 r' u; W* } I. h __IO uint32_t MACFFR; : f5 Y. a; z5 s( a, M2 m' S
__IO uint32_t MACHTHR; " N) Z! m9 l K4 N
__IO uint32_t MACHTLR; E6 N! k+ K0 I: M! ]% U
__IO uint32_t MACMIIAR; 6 p% Z8 @4 V! {# T8 |8 ?8 A
__IO uint32_t MACMIIDR; " k2 s( I9 m. O5 P* N# W
__IO uint32_t MACFCR; $ Y- ?9 L, w4 }
__IO uint32_t MACVLANTR; /* 8 */ " g! n3 Y# Z! T- D
uint32_t RESERVED0[2]; . _. S3 V# i# L Y- ^# [
__IO uint32_t MACRWUFFR; /* 11 */ / U% n1 ^0 H" ]+ S% q: e
__IO uint32_t MACPMTCSR;
( U3 X1 j2 H* c) S! [' W- b% n3 v0 l uint32_t RESERVED1[2];
9 a" i* n- j: g3 g __IO uint32_t MACSR; /* 15 */ / @- J! T H5 C8 f0 R0 t6 L
__IO uint32_t MACIMR; 0 e) g7 g1 Y8 S
__IO uint32_t MACA0HR; * R0 M. Q5 ` m {
__IO uint32_t MACA0LR; $ O$ N: ]7 L3 d1 u
__IO uint32_t MACA1HR; - B1 Z0 N4 m' b g! _; C
__IO uint32_t MACA1LR; * v1 [! \) Y7 U) E
__IO uint32_t MACA2HR; ; W2 P" w c5 V/ t! \% r& G
__IO uint32_t MACA2LR; % w0 Z4 ^* B! Z' F
__IO uint32_t MACA3HR;
( ~% v G2 I& D7 Y. n( l" q __IO uint32_t MACA3LR; /* 24 */
3 x% M9 C( |) F0 R# U uint32_t RESERVED2[40]; ( U) T) F' f9 i2 A* _
__IO uint32_t MMCCR; /* 65 */ ( j1 g. {/ A, y% v# K9 R
__IO uint32_t MMCRIR; " q! A/ w9 i! H+ u* r
__IO uint32_t MMCTIR; 9 H$ W2 o; _% ?0 w, X
__IO uint32_t MMCRIMR; % S, D4 V7 V0 y6 S4 T" x
__IO uint32_t MMCTIMR; /* 69 */
4 _ h4 k/ R0 ]) `0 V" y uint32_t RESERVED3[14];
. p& N4 \5 B* s+ Y1 j+ W: ] p7 N __IO uint32_t MMCTGFSCCR; /* 84 */
8 J! z/ Q% r5 ^( ]% |8 \5 } __IO uint32_t MMCTGFMSCCR; 8 a) I5 T+ x3 g
uint32_t RESERVED4[5];
1 [) m' r! C# B$ \: u7 m __IO uint32_t MMCTGFCR; % Q. N- Y0 q7 I3 _8 l9 X6 i8 W- O- _/ t
uint32_t RESERVED5[10];
& m( A* P/ ^/ V8 ~ __IO uint32_t MMCRFCECR; ( `2 y' y' J& ]) R- I+ c
__IO uint32_t MMCRFAECR;
* R+ u. v3 h* m5 V( \/ A) \7 k uint32_t RESERVED6[10];
+ ^) i" s$ o# Q Y0 U3 ~0 f& n __IO uint32_t MMCRGUFCR;
; L& ^$ R4 b6 C6 ~: M& d% w uint32_t RESERVED7[334];
7 K: ~! A; t- @9 X% @( I __IO uint32_t PTPTSCR; ' D" k4 R0 A. m; g
__IO uint32_t PTPSSIR;
( L2 v( {1 t3 m5 o+ g8 C+ K __IO uint32_t PTPTSHR;
* f# c+ ], L3 x) k$ [( _+ d __IO uint32_t PTPTSLR;
" o( K) W" D) y+ W5 x- c; Z* M __IO uint32_t PTPTSHUR;
0 T0 u3 b7 M2 U! m3 O5 r' [ __IO uint32_t PTPTSLUR;
/ n9 A1 l: D& Z- d __IO uint32_t PTPTSAR; , |) ?- f! E( K
__IO uint32_t PTPTTHR; 0 C% K3 t, \& \ @+ b" B
__IO uint32_t PTPTTLR; . [' A$ H8 l$ l, Z
uint32_t RESERVED8[567];
" n! d' H+ W5 z7 E% v __IO uint32_t DMABMR; ( B$ [. H; N$ d
__IO uint32_t DMATPDR; 0 E" a5 E1 F# K2 U8 p
__IO uint32_t DMARPDR;
2 v# A; [' H$ F$ {. l$ Z __IO uint32_t DMARDLAR; 0 l8 l" v4 |5 m8 r O+ Y& ~5 E
__IO uint32_t DMATDLAR; & O+ w4 V# w1 |, a
__IO uint32_t DMASR; , ^& g% s0 K/ G M7 K0 B+ y
__IO uint32_t DMAOMR;
) h& a* Y2 l& _4 n4 F2 [2 K __IO uint32_t DMAIER;
; p# s; D* j# d0 h- Q __IO uint32_t DMAMFBOCR; w; ]8 ]. }' E: Z
uint32_t RESERVED9[9]; ; I7 q1 {1 o9 A
__IO uint32_t DMACHTDR;
2 M! \* G H% D- `9 y __IO uint32_t DMACHRDR; * V4 K( N0 y/ Z
__IO uint32_t DMACHTBAR; 1 P% l/ q4 n/ U1 @
__IO uint32_t DMACHRBAR; , s7 F. T6 e& N! X
} ETH_TypeDef;
( R. j$ ]5 F, I
' y9 L9 m3 C6 h) w5 W1 ]/**
% x' Y. O# F, ]1 P * @brief External Interrupt/Event Controller
! \; K2 @1 W6 Q, @ @ */ EXTI寄存器结构
1 d6 e/ L5 ~" A$ t3 `EXTI 寄存器结构,EXTI_TypeDef,在文件stm2f10x_map.h中定义如下: typedef struct { vu32 IMR; vu32 EMR; vu32 RTSR; vu32 FTSR; vu32 SWIER; vu32 PR; }EXTI_TypeDef; Table 128. 例举了EXTI 所有寄存器 Table 128. EXTI寄存器 寄存器 描述 IMR 中断屏蔽寄存器 EMR 事件屏蔽寄存器 RTSR 上升沿触发选择寄存器 FTSR 下降沿触发选择寄存器 SWIR 软件中断事件寄存器 PR 挂起寄存器
! M# _: I/ Z" N3 E9 I2 Ctypedef struct
8 T4 J4 R- j; }9 B8 e{ 2 [ @, V5 {9 o# w- v/ |- |
__IO uint32_t IMR;
' u0 ]; j2 r2 l' i __IO uint32_t EMR;' f! O8 t8 {8 S" @% x
__IO uint32_t RTSR;3 S6 }/ Q! x1 o. d0 C
__IO uint32_t FTSR;6 D# D9 v# ]' m5 I5 R
__IO uint32_t SWIER;
/ |3 p* I" k" o! f& g" }* ^ N __IO uint32_t PR;
5 S5 I$ g! U" ^1 F9 o) E* V* P Q2 g} EXTI_TypeDef;$ V6 W- G; ~) _3 q; h
( ?& U" i/ ]0 k8 l5 o. z% G
/**
' ?$ y Y$ L y * @brief FLASH Registers s- F2 V0 D, u* _ N0 ~8 h9 M3 c
*/ FLASH寄存器 寄存器 描述 ACR FLASH访问控制寄存器 KEYR FPEC密钥寄存器 OPTKEYR 选择字节密钥寄存器 SR FLASH状态寄存器 CR FLASH控制寄存器 AR FLASH地址寄存器 OBR 选择字节和状态寄存器 WRPR 选择字节写保护寄存器 typedef struct
" b: Y" d5 E& C$ F6 A! [( b- y+ h{
J: K! a7 e2 f0 H9 F4 W/ ~5 H k __IO uint32_t ACR;
8 x. s6 \: w* s* T4 \& k __IO uint32_t KEYR;
9 k$ x' |' A) F' t9 Q __IO uint32_t OPTKEYR;4 H4 W0 I( A) A3 `$ C# w
__IO uint32_t SR;7 Z! \6 ]( ~- h0 E4 R6 s* q
__IO uint32_t CR;; G9 ?8 D3 W8 B5 s& G
__IO uint32_t AR;( q/ c, y; T N& D
__IO uint32_t RESERVED;
) q) B( f" r8 S- u' t0 M __IO uint32_t OBR;1 h/ B, m% z" {: V* L: F% O# J
__IO uint32_t WRPR;' F6 ?/ M1 R$ G! T" A$ z
#ifdef STM32F10X_XL% |; w8 j4 I M
uint32_t RESERVED1[8]; 2 k% s# c& `. D. p) @
__IO uint32_t KEYR2;
% u" t) U9 R5 I# l/ Y. p) P$ S uint32_t RESERVED2;
! r' e1 }/ Z/ R5 B __IO uint32_t SR2;7 V9 h, W0 @* o) H4 {
__IO uint32_t CR2;# V: s! ?* o2 {3 V" _0 u' M* }) I; z
__IO uint32_t AR2;
" q$ M3 z; P( @/ O#endif /* STM32F10X_XL */ ' {% P1 q& p7 t C! B9 Y
} FLASH_TypeDef;
( N7 F7 _* n# w# H
* G9 {% b& X6 C ?————————————————————————————% t+ O/ n. i7 ?9 L4 e, b8 Z
———————————————————————————— //本程序只供学习使用,如果用于工程应用,请仔细检查
+ L9 k' ^! I. a- a- _9 L' O/ ?//主要对于ST公司的库存文件stm32f10x.h进行解析
6 h6 l: z* Z; Z//修改日期:2014/6
4 k0 Q8 \; g2 I9 t//Copyright(C) 2014-2025
, D- S( a _' h! |% g& C7 Y//All rights reserved
* J( T% e, \5 `//******************************************************************************** */
4 g; t" ?# u( c) j/ w/ k" [: z0 `* d2 `% s" v3 R; v9 t
/** % h1 L6 n. J6 g" _1 |7 w, x
* @brief Option Bytes Registers3 @" v; b$ E9 [- A
*/选项字节寄存器
( I. \, [) b* L2 ]' y0 b0 |: F9 V
8 Y, K; i1 \! O: S6 S$ jtypedef struct
, z w, i& X4 o: g% F{
& l" n8 g) a$ @: s __IO uint16_t RDP;RDP 为 读出选项字节 ,USER 为 用户选项字节 , Data0 为 数据 0 选项字节,Data1 为 数据 1 选项字节,WRP0 为 写保护 0的先项字节。依此类推
4 q0 S0 q M% k2 h+ v __IO uint16_t USER;
1 o( M4 b* C. ?2 Q' W* |- _ __IO uint16_t Data0;
3 t4 \! @0 k' x" s __IO uint16_t Data1;, N1 R, g; |7 `; a u4 f, U* S
__IO uint16_t WRP0; Y3 B- Y0 ?3 Y! B. Q6 P
__IO uint16_t WRP1;2 I1 E: K# J ~ N2 t& n
__IO uint16_t WRP2;: B: i! D W2 B/ B
__IO uint16_t WRP3;
: `+ L: H0 Q0 H} OB_TypeDef;$ L* @4 ~3 K! A8 |3 S: W& F# L
( H' g1 ~/ ~2 E/ w& I2 c- R
/**
* F: |1 b8 s. u+ @( e/ T7 l0 x * @brief Flexible Static Memory Controller
% n0 b; v3 p* F( n. E */灵活的静态存储器控制器
+ f5 A$ B7 e, D! b3 S0 NFSMC(Flexible Static Memory Controller,可变静态存储控制器)是STM32系列采用一种新型的存储器扩展技术。在外部存储器扩展方面具有独特的优势,可根据系统的应用需要,方便地进行不同类型大容量静态存储器的扩展。. c8 ^: z. C1 m4 x- s V6 ~0 O
7 O' h$ T/ [' P( ^3 f& c- UFSMC技术优势①支持多种静态存储器类型。STM32通过FSMC可以与SRAM、ROM、PSRAM、NOR Flash和NANDFlash存储器的引脚直接相连。9 P8 W x k4 j& i5 U; q7 `
②支持丰富的存储操作方法。FSMC不仅支持多种数据宽度的异步读/写操作,而且支持对NOR/PSRAM/NAND存储器的同步突发访问方式。, R* |& R9 Z! G9 X: J
③支持同时扩展多种存储器。FSMC的映射地址空间中,不同的BANK是独立的,可用于扩展不同类型的存储器。当系统中扩展和使用多个外部存储器时,FSMC会通过总线悬空延迟时间参数的设置,防止各存储器对总线的访问冲突。 a# @# z0 L0 a
④支持更为广泛的存储器型号。通过对FSMC的时间参数设置,扩大了系统中可用存储器的速度范围,为用户提供了灵活的存储芯片选择空间。
6 j# s" o- n$ `! M. A⑤支持代码从FSMC扩展的外部存储器中直接运行,而不需要首先调入内部SRAM。. O' t) M {+ m2 Z
6 |4 ]( ~& H% f8 A, a8 R" z2 h
/ H/ `) Q e* [) y0 x" C; c: l8 O4 z0 @$ H% H* _" z
typedef struct7 r: k7 g' V6 F
{
) |. l7 J) j# M3 ^9 L- g __IO uint32_t BTCR[8];
# P4 P$ u7 [8 Y; h} FSMC_Bank1_TypeDef;
, {5 m9 S( A7 F3 Q* F. X- T; B% b- A
) S7 h+ Q7 r( }. f3 S/**
" h' \* C, A6 a" p4 I * @brief Flexible Static Memory Controller Bank1E' t' }- o- M) O9 I" H1 E s
*/
! A3 @; I* b- M% {FSMC映射地址空间FSMC管理1 GB的映射地址空间。该空间划分为4个大小为256 MB的BANK,每个BANK又划分为4个64 MB的子BANK,如表1所列。FSMC的2个控制器管理的映射地址空间不同。NOR Flash控制器管理第1个BANK,NAND/PC Card控制器管理第2~4个BANK。由于两个控制器管理的存储器类型不同,扩展时应根据选用的存储设备类型确定其映射位置。其中,BANK1的4个子BANK拥有独立的片选线和控制寄存器,可分别扩展一个独立的存储设备,而BANK2~BANK4只有一组控制寄存器。
& Z# ?" n3 @5 T; rtypedef struct; ~" t6 J, z0 g' l: U! P$ B4 q
{
( f7 x; j: i7 \ __IO uint32_t BWTR[7];: |: y4 b0 r7 t0 Q' k. X
} FSMC_Bank1E_TypeDef;那么这里就是FSMC的BANK1的结构体定义
% m1 a+ C8 J" p; m+ b! c
0 R- W) C& A9 H/** % p5 E7 d2 o4 Y/ [9 v' \* Q1 X7 ^
* @brief Flexible Static Memory Controller Bank21 D8 F9 w) q1 b; |
*/
) u6 s: }- O3 w0 R* D1 T6 L: F1 n
; b: f* [3 d. u- Dtypedef struct
. N6 s' Z u7 d8 K{
; B `% @/ H* s& i8 ~+ c. N6 r; v __IO uint32_t PCR2;
0 [5 F# k3 F: B. f __IO uint32_t SR2;* n1 b% J! ]5 Z# b& P
__IO uint32_t PMEM2;- N5 A, ^! e, s/ G5 _* a j
__IO uint32_t PATT2;) p3 ^ E, z% G) ~2 }' ^
uint32_t RESERVED0;
. r l8 H# j X1 L+ |* r __IO uint32_t ECCR2; , n+ M( j/ I0 I6 a
} FSMC_Bank2_TypeDef; 7 p) S' z. j# @% [. M4 ]4 ]
$ {" f" k$ m* @
/**
' s& U8 q4 F* Q9 A% [ * @brief Flexible Static Memory Controller Bank3
! ]( Q9 q" J% i2 L/ \: ? */% l+ f. r% s6 p0 \8 m5 l3 y
8 o+ ]0 Z& }+ N* v! D6 o" Z4 ~typedef struct
# y5 c. Q! E9 O% c{5 ^8 y ]( u% W9 T7 Q# ~9 a! D
__IO uint32_t PCR3;( q: `; h% D: m$ p6 [- ^: R# `
__IO uint32_t SR3;
4 M' V L/ r: e) B6 O+ b( f __IO uint32_t PMEM3;6 z* V) D' C- A9 R
__IO uint32_t PATT3;/ T0 O; _2 A; O1 |7 o2 v0 D. D
uint32_t RESERVED0;
( J2 _4 j- P$ E __IO uint32_t ECCR3; 2 I. O% U; r& S( S# k8 q# ^
} FSMC_Bank3_TypeDef;
" a: l. N) u0 V2 W( j; P8 W( ]! a8 Z/ B7 L+ ]" F
/** & I9 |2 a8 @! w7 `3 p1 |6 L
* @brief Flexible Static Memory Controller Bank43 T5 I# S0 z2 M& k. E
*/
+ w, Z3 M2 c$ G: Z( s0 M! [$ b3 ^! E
, K3 V9 m- _, g+ C, O4 W7 Q2 x
————————————————————————————————————————————————————— —————————————————————————————————————————————————————- R! j3 W U- d3 H, [* H, @1 _
typedef struct
) }6 K( c7 D. @. Y& P/ o0 i{ $ S0 L: h" l, c! A, m- m2 Z. |% z( {
__IO uint32_t PCR4; ( p! i6 N) q7 I/ R+ D& Q3 f
__IO uint32_t SR4; ) y3 N2 b; k( i- K: ?/ r& G
__IO uint32_t PMEM4; ) X6 s- b5 G& r, p# V
__IO uint32_t PATT4;
3 w1 p! ^+ d* `3 i __IO uint32_t PIO4; 4 @+ B6 h3 J( ?0 J
} FSMC_Bank4_TypeDef; & j/ E/ {4 b2 S) W' u( c6 D0 ^
3 K( f6 Q1 M. J% U7 Q/** . M" |9 ]3 r' ~
* @brief General Purpose I/O
. Q, C+ a9 l$ \. o! {1 V' { */
) s1 g _: A& j& ?" c0 ]0 D
6 e a& W4 X4 S1 _typedef struct
. X2 v8 m3 h: `{
: Z, _1 s2 z) ?" F8 y% @ __IO uint32_t CRL;
' ?. u% Z0 D, e2 e* {) z+ M __IO uint32_t CRH; ( u, K$ b; ?& z; `3 `
__IO uint32_t IDR;
$ z0 s4 C+ e- Z% Y __IO uint32_t ODR;
: m0 |- r8 z/ I6 @5 ?% P( P. S __IO uint32_t BSRR;
/ e0 v" U+ D: C( d$ } __IO uint32_t BRR;
$ U0 _, b, R2 o; G; H7 F& A __IO uint32_t LCKR;
8 V6 k- _: h) T0 C; P- @} GPIO_TypeDef; CRL、 CRH、IDR、ODR等都是一个端口中的 寄存器,对寄存器的读写操作实现你需要的功能。STM32 的每个 IO 端口都有 7 个寄存器来控制。他们分别是:配置模式的 2 个 32 位的端口 配置寄存器 CRL 和 CRH;2 个 32 位的数据寄存器 IDR 和 ODR;1 个 32 位的置位/复位寄存器 BSRR;一个 16 位的复位寄存器 BRR; 1 个 32 位的锁存寄存器 LCKR
2 V5 L1 s0 R3 t' EGPIO_Pin 该参数选择待设置的GPIO管脚,使用操作符“|”可以一次选中多个管脚。可以使用下表中的任意组合。 GPIO_Pin_None:无管脚被选中 GPIO_Pin_x:选中管脚x(0–15) GPIO_Pin_All:选中全部管脚
" b) j0 x" Y+ A8 R' U( cGPIO_Speed GPIO_Speed:用以设置选中管脚的速率。 GPIO_Speed_10MHz:最高输出速率10MHz GPIO_Speed_2MHz:最高输出速率2MHz GPIO_Speed_50MHz:最高输出速率50MHz
; T2 E# p9 N* zGPIO_Mode GPIO_Mode:用以设置选中管脚的工作状态。 GPIO_Mode_AIN:模拟输入 GPIO_Mode_IN_FLOATING:浮空输入 GPIO_Mode_IPD:下拉输入 GPIO_Mode_IPU:上拉输入 GPIO_Mode_Out_OD:开漏输出 GPIO_Mode_Out_PP:推挽输出 GPIO_Mode_AF_OD:复用开漏输出 GPIO_Mode_AF_PP:复用推挽输出
# q, |4 S) C+ x% x! l2 a% l函数GPIO_StructInit 功能描述:把GPIO_InitStruct中的每一个参数按缺省值填入 例: GPIO_InitTypeDef GPIO_InitStructure; GPIO_StructInit(&GPIO_InitStructure); GPIO_InitStruct: GPIO_Pin:GPIO_Pin_All GPIO_Speed:GPIO_Speed_2MHz GPIO_Mode:GPIO_Mode_IN_FLOATING
" ?( i8 b* ?. G函数GPIO_ReadInputDataBit 功能描述:读取指定端口管脚的输入 例: u8 ReadValue; ReadValue = GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_7);
% b' L- Q$ O# D9 r3 n: j1 N( k函数GPIO_ReadInputData 功能描述:读取指定的GPIO端口输入 例: u16 ReadValue; ReadValue = GPIO_ReadInputData(GPIOC); # p3 H; ~) G8 g, V* P- Z
, X# l3 e1 z- p* N1 ]函数GPIO_ReadOutputDataBit 功能描述:读取指定端口管脚的输出 例: u8 ReadValue; ReadValue = GPIO_ReadOutputDataBit(GPIOB, GPIO_Pin_7);
' \8 R; o: [' S6 i5 u
& ]+ [1 E- r' G# g" A" }函数GPIO_ReadOutputData 功能描述:读取指定的GPIO端口输出 例: u16 ReadValue; ReadValue = GPIO_ReadOutputData(GPIOC); 3 c1 |: c+ Z+ K) K
函数GPIO_SetBits 功能描述:置位指定的数据端口位 例: GPIO_SetBits(GPIOA, GPIO_Pin_10 | GPIO_Pin_15);
1 A. Z# f' A0 G5 n1 s4 q0 K9 ~$ d
! ` J {# e1 w) F- D' z. d函数GPIO_ResetBits 功能描述:清除指定的数据端口位 例: GPIO_ResetBits(GPIOA, GPIO_Pin_10 | GPIO_Pin_15);
3 M* e8 I. E2 h# T q4 X) E# ]% F6 d1 V1 f& p# y
函数GPIO_WriteBit 功能描述:设置或者清除指定的数据端口位 例: GPIO_WriteBit(GPIOA, GPIO_Pin_15, Bit_SET); 8 ^6 G J, w$ @. x$ T" G1 U
5 s2 W! n2 `! Z+ x* B6 O
! L4 `; r! x8 ]6 s- s; ?) Z函数GPIO_Write 功能描述:向指定GPIO数据端口写入数据 例: GPIO_Write(GPIOA, 0x1101); * g0 Z4 j$ L' d1 O
S$ _; D {, u* }* }1 }函数GPIO_PinLockConfig 功能描述:锁定GPIO管脚设置寄存器 例: GPIO_PinLockConfig(GPIOA, GPIO_Pin_0 | GPIO_Pin_1); 4 B, L0 M" S% x$ e V
( Q; R& M- g6 q+ I# ~
函数GPIO_EventOutputConfig 功能描述:选择GPIO管脚用作事件输出 例: GPIO_EventOutputConfig(GPIO_PortSourceGPIOE, GPIO_PinSource5);
$ m1 y& D. V) K) K' F' R6 hGPIO_PortSource GPIO_PortSource用以选择用作事件输出的GPIO端口。
* z) a( R8 c) r9 ~0 }+ n; q# VGPIO_PinSource GPIO_PinSource用以选择用作事件输出的GPIO管脚。 " S& l# U, q% c8 ~, j- R6 g
# h5 m" F* j- r! f) I4 _- H函数GPIO_EventOutputCmd 功能描述:使能或者失能事件输出
5 Y& P6 F: e' f8 F# H) A例: GPIO_EventOutputConfig(GPIO_PortSourceGPIOC, GPIO_PinSource6); GPIO_EventOutputCmd(ENABLE);
- V" r/ P, | H$ I# {/ Y' A. i$ @: ~
函数GPIO_PinRemapConfig 功能描述:改变指定管脚的映射 例: GPIO_PinRemapConfig(GPIO_Remap_I2C1, ENABLE);
! _9 i! K3 ?) g, N# z5 n& B9 {% v2 |9 q, Q( D. @
GPIO_Remap GPIO_Remap用以选择用作事件输出的GPIO端口。 GPIO_Remap_SPI1:SPI1复用功能映射 GPIO_Remap_I2C1:I2C1复用功能映射 GPIO_Remap_USART1:USART1复用功能映射 GPIO_PartialRemap_USART3:USART2复用功能映射 GPIO_FullRemap_USART3:USART3复用功能完全映射 GPIO_PartialRemap_TIM1:USART3复用功能部分映射 GPIO_FullRemap_TIM1:TIM1复用功能完全映射 GPIO_PartialRemap1_TIM2:TIM2复用功能部分映射1 GPIO_PartialRemap2_TIM2:TIM2复用功能部分映射2 GPIO_FullRemap_TIM2:TIM2复用功能完全映射 GPIO_PartialRemap_TIM3:TIM3复用功能部分映射 GPIO_FullRemap_TIM3:TIM3复用功能完全映射 GPIO_Remap_TIM4:TIM4复用功能映射 GPIO_Remap1_CAN:CAN复用功能映射1 GPIO_Remap2_CAN:CAN复用功能映射2 GPIO_Remap_PD01:PD01复用功能映射 GPIO_Remap_SWJ_NoJTRST:除JTRST外SWJ完全使能(JTAG+SW-DP) GPIO_Remap_SWJ_JTAGDisable:JTAG-DP失能 + SW-DP使能 GPIO_Remap_SWJ_Disable:SWJ完全失能(JTAG+SW-DP) " t5 A0 Z: D9 f' h" E
; t2 E# D$ w5 Z% I( S2 l函数GPIO_EXTILineConfig 功能描述:选择GPIO管脚用作外部中断线路 例: GPIO_EXTILineConfig(GPIO_PortSource_GPIOB, GPIO_PinSource8); /** $ G! i- B: f, ~. F9 O
* @brief Alternate Function I/O 7 P0 A) B6 G3 b* m/ x
*/
0 R6 \, S/ w8 @0 {5 k* w; X- }# v: f7 Q- [2 C5 N" e1 p
typedef struct
+ Y3 R3 h2 r5 P{ $ I4 c' q. N% q8 S
__IO uint32_t EVCR; # P7 D4 N8 \# ~
__IO uint32_t MAPR; 8 x5 j$ K, u7 W) `
__IO uint32_t EXTICR[4];
: i8 {6 q5 @" P uint32_t RESERVED0;
. r& O, y2 ]7 o0 s4 n2 H( n8 k j __IO uint32_t MAPR2; 9 Z: g& A1 U" v7 D9 F
} AFIO_TypeDef; 复用功能寄存器结构,也就是说这里可以把IO做复用。 9 V$ ?. G' N4 O, `$ x9 a; x0 {
/**
& b' q- m" b) g6 _$ E) |/ ? * @brief Inter Integrated Circuit Interface 0 v8 e* y+ x/ C$ C7 ~
*/ 1 W2 D' b6 t" a1 s+ y, f8 U/ c( F
/ o4 K- s. ]7 l# T
typedef struct I2C 结构体类型,这里面的全部是数据寄存器。 ! c, n; U. y0 y0 f. B
{ 9 ^* L4 G: V7 t, U. z
__IO uint16_t CR1; 5 y- G! d6 ~5 q2 S0 D' X$ M
uint16_t RESERVED0;
" v9 |% ]6 Y; b8 B __IO uint16_t CR2; 6 Y* C/ _+ V8 H# a0 h" E
uint16_t RESERVED 1;
+ o! D" k. s$ b. Y, l __IO uint16_t OAR1; 0 d3 Z/ _ [0 [1 ?3 i- f/ B
uint16_t RESERVED2; 7 K$ k" S# r8 f/ r6 f* T3 T( x% g
__IO uint16_t OAR2;
, ?0 y P7 S" H- A# r( a; | uint16_t RESERVED3; % i8 S$ M8 w9 i: t" E- [# u
__IO uint16_t DR;
4 e" V/ u4 u0 h; g# U1 k+ _0 d uint16_t RESERVED4; 7 ?. a' _3 ?! }9 X; P- l
__IO uint16_t SR1; ; M% O( w U3 I
uint16_t RESERVED5; % B- d9 K9 }* u" a1 a
__IO uint16_t SR2;
7 t G# }. N) a( S- x2 E2 o uint16_t RESERVED6; 8 u& _. H$ i, _( k4 N1 }1 T- X* y
__IO uint16_t CCR;
1 W( m: C1 H. E* e1 Y uint16_t RESERVED7;
6 H# I5 l$ ]# |" d/ D( @$ v __IO uint16_t TRISE; ; U8 F: B N& Q( f' R) I; {
uint16_t RESERVED8; " i c" h, m4 U- p+ C
} I2C_TypeDef;
$ o' n6 B" b/ ^! `3 N6 ]' m' f. F5 ?/ U! C& k; ?' |' @
/** # j8 \' x- z# m) d# s' C. @) G
* @brief Independent WATCHDOG
- n& x4 B8 C$ y9 h# Q. E */ s1 j1 E6 B- I+ F9 w- k
在键值寄存器(IWDG_KR)中写入 0xCCCC,开始启用独立看门狗;此时计数器开始从其复 位值 0xFFF 递减计数。当计数器计数到末尾 0x000 时,会产生一个复位信号(IWDG_RESET)。 无论何时,只要键寄存器 IWDG_KR 中被写入 0xAAAA, IWDG_RLR 中的值就会被重新加载 到计数器中从而避免产生看门狗复位 。 IWDG_PR 和 IWDG_RLR 寄存器具有写保护功能。要修改这两个寄存器的值,必须先向 IWDG_KR 寄存器中写入 0x5555。将其他值写入这个寄存器将会打乱操作顺序,寄存器将重新 被保护。重装载操作(即写入 0xAAAA)也会启动写保护功能。 还有两个寄存器,一个预分频寄存器(IWDG_PR),该寄存器用来设置看门狗时钟的分频 系数。另一个重装载寄存器。该寄存器用来保存重装载到计数器中的值。该寄存器也是一个 32 位寄存器,但是只有低 12 位是有效的。 只要对以上三个寄存器进行相应的设置,我们就可以启动 STM32 的独立看门狗。 那么这个就是看门狗定义的 结构体类型。 typedef struct
! i M5 e0 z; g8 Q{
- v9 P) I" [; a' c: q __IO uint32_t KR;
3 \1 L/ Z. O" r! q/ n3 ] __IO uint32_t PR;
! T0 ?: z; R. {9 ~" |% W/ [ __IO uint32_t RLR;, J+ }* b4 f+ Z
__IO uint32_t SR;
: R: G* \+ r9 O! C' N} IWDG_TypeDef;
~0 q0 ^; j& b. B0 n+ M2 A$ B+ E% g5 S u4 F3 }0 _1 O- ^
/**
( E+ Y+ ?8 I/ A9 t7 R* N# Z% p * @brief Power Control
+ Q8 Z9 A O8 X( r* A */; n4 K' z ~4 @# o# o0 Q
. @# H6 i2 l7 ^
typedef struct
# L/ z- A/ e9 N) [7 ~! t{
" ]2 I! E u+ D0 H! g __IO uint32_t CR;# n- y7 E7 T' V
__IO uint32_t CSR;$ m6 ^8 t) d5 q3 [1 P9 V! |# Z' A9 E
} PWR_TypeDef; CR; //电源控制寄存器 vu32 CSR; //电源控制状态寄存器
/ Q% ^" h3 P0 [$ N5 N
' Y9 d9 g8 P8 V: V/** 7 h6 V; l, s# G% I4 |( D
* @brief Reset and Clock Control
6 ~, {, Y2 X* ~( `# a */
# n# v' X9 u3 ~7 x9 v r! o/ V
) v1 D Z" f: A& Y ~ Wtypedef struct
9 v9 V! r; C- W! e) t8 p{; X) Z$ p8 x* P) e; j @5 n2 }
__IO uint32_t CR;
0 _- h$ K0 `( T1 `" U) T __IO uint32_t CFGR;# ~0 u- h9 u! O, \- q$ V
__IO uint32_t CIR;
, A0 \1 a8 V( N9 _& D& l __IO uint32_t APB2RSTR;7 f8 X F6 F' n# b: G. C6 O- T- i
__IO uint32_t APB1RSTR;
) O/ E$ {4 z" k; K: B __IO uint32_t AHBENR;' q0 a$ ^6 }( s0 T
__IO uint32_t APB2ENR;' I/ b/ m4 }0 F# d( M/ q
__IO uint32_t APB1ENR;
+ ]& Y* K' o5 u __IO uint32_t BDCR;
7 s+ k) [. n, j/ m' \! x __IO uint32_t CSR;8 Y8 [% }. Z2 g. U- h! z
2 B( k6 g9 I. P% A3 k #ifdef STM32F10X_CL % i" C6 k* e, J& Y# {( E: U
__IO uint32_t AHBRSTR;( ]* g* {" _& j; V9 c& U
__IO uint32_t CFGR2;
& }+ S+ N: @) J! R* y3 }#endif /* STM32F10X_CL */
# P/ V8 U% ]2 u2 |3 A- V
: i2 Y+ J) p/ ^5 {" Q# Z0 [9 |#if defined (STM32F10X_LD_VL) || defined (STM32F10X_MD_VL) || defined (STM32F10X_HD_VL)
" ?1 P+ x5 x1 e; {" } k uint32_t RESERVED0;1 }6 F' d& l- N3 i
__IO uint32_t CFGR2;7 }3 G. |. W! T# w& e* \
#endif /* STM32F10X_LD_VL || STM32F10X_MD_VL || STM32F10X_HD_VL */ % F, R6 F0 w; P
} RCC_TypeDef; . 这个宏定义是把RCC宏定义到stm32RCC寄存器的分配的存储器单元的首地址上,其中RCC_TypeDef是stm32f10x_map.h中定义的结构体,用来表述RCC所有寄存器构成的
) X/ t5 I3 ~8 Y3 X( i; F/ k1 |6 u- c% y
———————————————————————————————————————————————————6 C! C/ `: M. M9 r, M
——————————————————————————————————————————————————— //本程序只供学习使用,如果用于工程应用,请仔细检查
# H- U: _% }6 P M//主要对于ST公司的库存文件stm32f10x.h进行解析
) x% s8 G; W3 D//修改日期:2014/6
# I( }6 u$ r+ \+ n: W& G//Copyright(C) 2014-2025
3 B" q* U3 d5 ^6 @//All rights reserved* K2 X8 i: W/ J. d2 }
//******************************************************************************** */
+ P& K5 P q% b5 \2 G/** 0 h- l: c: L1 u+ H3 J( |
* @brief Real-Time Clock4 L3 c; j l( Z, i, p( L
*/
! d5 w z! E+ I5 m* u# k& DRTC预分频器余数寄存器高位(RTC_DIVH)
( \6 e& I/ C) Q, ERTC预分频器余数寄存器低位(RTC_DIVL)9 g9 M3 Z9 O0 S0 A
RTC控制寄存器高位(RTC_CRH)
* v5 Z* g5 c# f0 l, t# |! L/ x7 M' URTC控制寄存器低位(RTC_CRL)" h) V+ W" z1 S; Q b9 `9 z8 h
RTC预分频装载寄存器高位(RTC_PRLH) ; E% p* v5 r& j1 |
RTC预分频装载寄存器低位(RTC_PRLL)( c* |# Y$ D0 q2 q* i2 g
RTC计数器寄存器高位(RTC_CNTH)& W6 X( k6 ?9 l/ c
RTC计数器寄存器低位(RTC_CNTL) 1 k: O4 f- y' c0 ^; ^
RTC闹钟寄存器高位(RTC_ALRH) ' ~0 n u- U4 K1 ~' d2 B) A2 R2 ?
RTC闹钟寄存器低位(RTC_ALRL) 0 z: ]- Q4 M& z' M7 w: L4 Y- ~6 P6 Z1 n
. l( Y$ h$ N, a$ T
typedef struct
3 j c) `0 m' D{
! c1 Q+ y& q6 ^4 Y* F __IO uint16_t CRH;
8 q& s( Y% G) @% M+ U& W6 X uint16_t RESERVED0; RTC寄存器是16位可寻址寄存器,这是定义它的数据类型为16位的。
* A5 Z7 O4 S& i0 Y' Q) ] __IO uint16_t CRL;1 o4 x5 d9 X! B2 }, V9 Y, q
uint16_t RESERVED1;# l2 S5 Z& O# J* ?! l8 a2 @
__IO uint16_t PRLH;/ n9 J' D& u" ^* t& u" O
uint16_t RESERVED2;
) X% a( Y: a& |0 v __IO uint16_t PRLL;
+ C$ j& g, n4 X/ W! e; a5 |% S uint16_t RESERVED3;
. I) D: p1 F4 H* A __IO uint16_t DIVH;$ \ U6 a1 G; u4 o
uint16_t RESERVED4;
* P) l' I( s4 s2 ~ __IO uint16_t DIVL;
) g5 d+ y* e$ w: ~6 n% n uint16_t RESERVED5;
3 y, F' u4 G/ L3 x5 I2 b' Y$ w __IO uint16_t CNTH;
9 g6 H+ S \8 D uint16_t RESERVED6;
' p$ F( A' R$ B4 r: X0 G' m __IO uint16_t CNTL;4 y ^0 l8 v; Q2 ?. g
uint16_t RESERVED7;4 @6 F Y2 N; U$ I4 k2 d
__IO uint16_t ALRH;
6 F3 A& I' v+ R# T2 d) z uint16_t RESERVED8;" q$ e3 z" H2 k1 [7 R1 J. w& _ I
__IO uint16_t ALRL;
3 d3 N$ E5 }* v' c( ~. r6 K2 I: Z uint16_t RESERVED9;# B# T/ C+ m( w5 s; a
}
) w; S# C# Y' B7 [% N$ DRTC_TypeDef;
, ]# Q/ z1 j1 H) M/** * p% O5 h2 j& P" ~" N# K2 X
* @brief SD host Interface SD卡接口; f0 X4 ^! M$ h; W9 t$ u
*/. V# N4 I# p4 b4 I
SDIO电源控制寄存器(SDIO_POWER)
* r) R- X3 d. q: {4 F- sSDIO时钟控制寄存器(SDIO_CLKCR)
% ?9 [1 z: H" h) C5 A$ ^SDIO参数寄存器(SDIO_ARG) 3 \- ]6 s: I0 K; |
SDIO命令寄存器(SDIO_CMD)
2 \9 `% s/ R# j8 o9 I! VSDIO命令响应寄存器(SDIO_RESPCMD)9 s. L6 V: N' k1 a
SDIO响应1..4寄存器(SDIO_RESPx)
' c R: j( u( `SDIO数据定时器寄存器(SDIO_DTIMER)
" B; b/ {& F5 P% o( K+ }SDIO数据长度寄存器(SDIO_DLEN)3 y5 R7 E1 E$ k/ ?9 z
SDIO数据控制寄存器(SDIO_DCTRL)
& x( A( M8 s4 p( o& E& w+ U P' NSDIO数据计数器寄存器(SDIO_DCOUNT) & b) W9 _! R9 s8 R: W( O4 Y4 C
SDIO状态寄存器(SDIO_STA) % D! a. Q& g0 R# S u
SDIO清除中断寄存器(SDIO_ICR) ) ] J+ w$ l. U3 ^
SDIO中断屏蔽寄存器(SDIO_MASK)
2 ~0 Q. N% }7 M; R2 }SDIO FIFO计数器寄存器(SDIO_FIFOCNT)
* N! X2 J2 x- A8 j: j$ x' USDIO数据FIFO寄存器(SDIO_FIFO) " q3 b) f; f4 q
typedef struct5 ^ z6 g0 L. m: t3 v. V
{
$ Y( \6 T2 x: k+ w0 n __IO uint32_t POWER;
9 w. m5 O: ^, ]6 W& A3 n __IO uint32_t CLKCR;( @4 |$ P, J0 l" Q$ ?
__IO uint32_t ARG;
' i n8 ?6 g/ x" r __IO uint32_t CMD;
+ t. `- C: t# w: X( b+ M __I uint32_t RESPCMD;2 @* ~6 \' y- V0 R! z: {
__I uint32_t RESP1;/ H) U# R& L" o0 W4 W1 ~" A4 W
__I uint32_t RESP2;& r8 R% X/ j; ?' U
__I uint32_t RESP3;+ H4 E/ n# \- ?# E8 h: H7 O
__I uint32_t RESP4;
5 f$ |( c! F$ g8 M4 x" F* y; Y# b __IO uint32_t DTIMER;
4 r" a' {$ v+ W* ^' N __IO uint32_t DLEN;
6 y9 Z, G2 Z e __IO uint32_t DCTRL;
. y" o* w- L9 j" D5 {4 R' W1 d __I uint32_t DCOUNT;
6 q r* s0 b4 k __I uint32_t STA;" p- s8 I) y' |7 C" K
__IO uint32_t ICR;
% K) ^8 G! I4 |+ @; N __IO uint32_t MASK;
$ \5 S( [) o3 s( \- T" f. R uint32_t RESERVED0[2];9 Q# u( a0 }6 ~9 F, M( O
__I uint32_t FIFOCNT;$ j5 M0 W8 n1 r6 q# J; i J
uint32_t RESERVED1[13];
' d: E" z" p* a$ K% j& P __IO uint32_t FIFO;
/ v0 L: W {- S/ O} SDIO_TypeDef;1 e$ }6 Y* d7 p* p/ e7 M0 [
' v2 }( L8 d) {7 X: e% W/**
. D3 l. [5 d5 I. a6 |1 w1 v+ ? * @brief Serial Peripheral Interface————-SPI串行总线
6 C1 J+ P+ A- @+ ] */
0 f9 y; z& s, z9 Y4 ~SPI控制寄存器1(SPI_CR1)
9 M9 Y+ T2 ~/ H( o) }& z9 KSPI控制寄存器2(SPI_CR2) / J/ X# i. h, `$ P3 W2 q/ ^( J
SPI 状态寄存器(SPI_SR) / T# S: Q: X L m$ X Q
SPI 数据寄存器(SPI_DR)
( F( E) R& [1 L# ?8 V9 W% I4 ~SPI CRC多项式寄存器(SPI_CRCPR) , b" J# n4 n* E
SPI Rx CRC寄存器(SPI_RXCRCR)
7 P! O/ [ @- B9 n) a FSPI Tx CRC寄存器(SPI_TXCRCR)
' g7 B4 K1 ?( E; k# n0 F/ N6 |SPI_I2S配置寄存器(SPI_I2S_CFGR)3 L! j) V8 K& t0 s
SPI_I2S预分频寄存器(SPI_I2SPR)
' b% `- A c0 N. U( T
" ^8 l: ]. ]2 U
. Z A2 f. l# b0 ~3 |* w' b! Mtypedef struct
& P9 e: z- }& ~$ Z+ A{5 \, x: K- X! X* E: f* d
__IO uint16_t CR1;
}" e- W. o: ~$ i& P+ c) t. w% @8 P uint16_t RESERVED0;
/ w2 I8 x* b: z% N3 l$ g+ ] __IO uint16_t CR2;2 j" j9 a; W7 Y
uint16_t RESERVED1;
, z, j$ M8 V g x __IO uint16_t SR;
6 g- V2 T; `! o( \$ W' M6 m& @$ e7 X uint16_t RESERVED2;
' c# r0 K$ D+ w% C- C; N __IO uint16_t DR;- n) V. T( a/ l
uint16_t RESERVED3;
& k, `& \ g' p __IO uint16_t CRCPR;; g; c }0 `$ l. X" j% V( {" o
uint16_t RESERVED4; B" d3 _- k$ H5 V/ m% T6 `3 n, y
__IO uint16_t RXCRCR;
& {5 d4 r: [- G9 {) p uint16_t RESERVED5;
3 B% |6 e/ T5 u: S __IO uint16_t TXCRCR;
+ v6 N3 v' W8 ?5 E. S uint16_t RESERVED6;2 k" Z# K+ n4 I# c0 ^# `# C( B
__IO uint16_t I2SCFGR;' b5 v* q7 _; v1 q! Y e7 }
uint16_t RESERVED7;) S+ O5 E) k) r3 b5 u5 l
__IO uint16_t I2SPR;
; ]6 }' q- O, |/ K9 U uint16_t RESERVED8; + z, {, b0 n; P
} SPI_TypeDef;
* u% {* B8 ~+ r! W* o; y8 J
; e. [5 m. r$ b) P/** * V+ x" `0 F/ O) V X
* @brief TIM
& ?8 J8 m5 ^4 o6 n6 k' a0 }7 ? 高级控制定时器(TIM1和TIM8)由一个16位的自动装载计数器组成,它由一个可编程的预分频器驱动。1 A% l$ B0 h7 I E
它适合多种用途,包含测量输入信号的脉冲宽度(输入捕获),或者产生输出波形(输出比较、
7 M% y; v: N* w" f* G% p: bPWM、嵌入死区时间的互补PWM等)。
$ ^& ]; B2 \6 o, ~2 i. G! |) p* ^2 M使用定时器预分频器和RCC时钟控制预分频器,可以实现脉冲宽度和波形周期从几个微秒到几3 s4 C" y. W. l7 K
个毫秒的调节。
% j' L$ M N1 e高级控制定时器(TIM1和TIM8)和通用定时器(TIMx)是完全独立的,它们不共享任何资源。它们
" _0 E( {) H% F# B. t) d [ f可以同步操作.4 |7 H1 A1 q3 P3 i
; r3 b" Q ^4 E: Q" O2 u2 f; v. T2 [
控制寄存器1(TIMx_CR1) 3 K' e( C Y. ~4 Q, k1 \+ |- d
控制寄存器2(TIMx_CR2)
# H4 T- R+ U! ~$ d; E2 f& I1 v! |从模式控制寄存器(TIMx_SMCR)
! i$ `, z5 k/ U8 V! T# m& eDMA/中断使能寄存器(TIMx_DIER)) m4 z9 B* r+ x, [7 B3 I
状态寄存器(TIMx_SR): ~/ C0 U& I% b& q) E1 ?$ V* U8 ]
事件产生寄存器(TIMx_EGR)
& s- z8 |; `8 k" C捕获/比较模式寄存器1(TIMx_CCMR1) & k; g5 ^( u( R
捕获/比较模式寄存器2(TIMx_CCMR2)
" @: Y9 N" d0 W9 Y9 z7 S捕获/比较使能寄存器(TIMx_CCER)
4 _6 Y! k6 B. H( }3 O2 h) B! q计数器(TIMx_CNT)# r. l& r, D; p- ~- e" ^ x9 }
预分频器(TIMx_PSC)
2 g6 n3 Z d$ A5 M: d- l* ?8 T自动重装载寄存器(TIMx_ARR)
- a( c! W; d8 n3 d; ^, f0 @6 I, E重复计数寄存器(TIMx_RCR)
U# l3 Z4 @: H捕获/比较寄存器1(TIMx_CCR1) C( [2 m5 s: J8 j5 t
捕获/比较寄存器2(TIMx_CCR2)
' e* @1 P0 }5 A! S5 N9 ]捕获/比较寄存器3(TIMx_CCR3)
3 \3 Q8 x( W8 Q* ^/ U/ s3 |& M6 L捕获/比较寄存器(TIMx_CCR4)! ?# |2 K+ K6 N, Q' O6 x" C
刹车和死区寄存器(TIMx_BDTR)
- x6 I8 Z% \: c3 VDMA控制寄存器(TIMx_DCR) . B) t3 q: R6 f. z( `
连续模式的DMA地址(TIMx_DMAR) 4 H& g# @! T+ `1 c0 t# }* \9 C
, c% d- S) ]2 D# b# ~. A
这个结构体就是以上这些寄存器的类型定义。1 n9 Y4 M+ z. }/ j- q
7 W% b; Z* l1 K- l0 Q* S9 q3 Q: u
*/
7 T( B+ U$ q/ C6 u; ]# E4 I# V' ~# }# B' B7 U' x# f
typedef struct. R# j* O3 c& u- ?+ }& O
{
2 _$ _0 u# I2 g: w __IO uint16_t CR1;
( P, k( w) M9 s' z1 Y, K uint16_t RESERVED0;3 H0 |: p: D9 e( p' A
__IO uint16_t CR2;- n0 U" ]+ I% _" A4 E7 r
uint16_t RESERVED1;/ O& y( U3 T6 n4 _
__IO uint16_t SMCR;0 ?& j5 d% z4 K/ T) |; T6 B
uint16_t RESERVED2;
$ i2 @! z2 `- { __IO uint16_t DIER;& Q( B8 W5 m* m
uint16_t RESERVED3;% Q/ \7 \3 Y% u. x @' |( |8 P& B
__IO uint16_t SR;4 V+ p6 i, \3 j" b% G8 g( `: u d
uint16_t RESERVED4;
0 p# \( D/ s. v0 s __IO uint16_t EGR;# J. r& k1 L1 c: |$ E3 M
uint16_t RESERVED5;0 A7 [$ p9 H# P+ ~7 q+ a5 T1 X* D
__IO uint16_t CCMR1;4 ~# \' { j/ n8 b7 K) I: H* l" [
uint16_t RESERVED6;; L( ? G- H( P- u2 j- M. b* a/ q
__IO uint16_t CCMR2;
, v9 p! D; C' ^$ }3 r uint16_t RESERVED7;, t- L( ]3 v* h3 X1 p; @
__IO uint16_t CCER;
9 j" r6 O/ n! M! D uint16_t RESERVED8;
# b1 _8 T M# m- u2 v- \( E __IO uint16_t CNT;
+ |8 j2 A, Q7 B N5 @, O, ^9 D uint16_t RESERVED9;1 w/ L, x- c# L. ~; r
__IO uint16_t PSC;* n/ A, W# ^; |. \5 K: b
uint16_t RESERVED10;. P% t- f6 Q3 e e T4 x
__IO uint16_t ARR;
5 L! |$ U! r7 z: r% {4 L+ H/ `3 a4 D& y uint16_t RESERVED11;
5 G' Z5 F9 x; @# w" } __IO uint16_t RCR;* v# M( P/ K# [2 I7 R- b
uint16_t RESERVED12;+ m0 }+ {* `/ T! E- b
__IO uint16_t CCR1;
7 r6 F6 ^0 z1 j% R9 I5 R( n uint16_t RESERVED13;$ Q# _: E3 m- \# k
__IO uint16_t CCR2;" b/ h9 A E& K5 s
uint16_t RESERVED14;
& P5 P7 d. b5 w8 M& e( m __IO uint16_t CCR3;
/ a& P, z- k; p uint16_t RESERVED15;
[# l( j9 D- J$ d( w+ }! M2 X9 c __IO uint16_t CCR4;5 ?& Q3 V7 _4 p+ Q4 r
uint16_t RESERVED16;
1 X3 x) W n5 \' W( O U# k! [' I __IO uint16_t BDTR;
9 k* J( }- m6 t% x3 o1 @ uint16_t RESERVED17;
) ]6 t; O: F/ `% g __IO uint16_t DCR;4 g1 p2 w5 L1 h% m; `0 b% d9 @
uint16_t RESERVED18;4 w2 `/ z. k5 c, S2 _) z; C
__IO uint16_t DMAR;
, y- Y# G; F2 M! V$ Y$ m: l uint16_t RESERVED19;" k( h; F, K! `& |6 X' P( V" G4 i/ A
} TIM_TypeDef;
. L+ v3 x( v6 L% ]. m6 Q k' V+ ^
/** 2 s3 J9 T' C6 i/ a7 p5 \
* @brief Universal Synchronous Asynchronous Receiver Transmitter
9 ?1 Q% n( a+ e: z! t! j6 S7 Z$ W */在UART上追加同步方式的序列信号变换电路的产品,被称为USART(Universal Synchronous Asynchronous Receiver Transmitter)。
) o3 I7 J, {+ }1 I' d7 h# a状态寄存器(USART_SR)
) x( a/ u) J: o6 E- ?) m; K# z) V; q数据寄存器(USART_DR)
) k! L1 n& J9 m9 w+ ?波特比率寄存器(USART_BRR)
- G/ _% ?' W& {% X+ a1 F) a b2 o控制寄存器1(USART_CR1); l8 a& Q* u* L
控制寄存器2(USART_CR2)
0 g& U: u/ e. D" F& O控制寄存器3(USART_CR3) + C+ N. M& i) ]+ E% x" d
保护时间和预分频寄存器(USART_GTPR)
7 _1 d4 K4 G! @6 q/ c6 b: G# m0 R1 U; A6 n$ x3 ? M1 I e, w) ?# T7 d: O. V
typedef struct2 V* k8 B+ P/ p6 _
{; b0 Y/ r$ _+ x8 w9 _- f
__IO uint16_t SR;" X9 r# r z+ |. ?& B5 e- k" E' p
uint16_t RESERVED0;
% n! V& S. A1 _, H% h# { __IO uint16_t DR;
% z( D6 p) ^. n7 l3 T uint16_t RESERVED1;6 {: J* n7 u' C1 z8 ?6 q9 R2 f
__IO uint16_t BRR;% Q/ Z T5 V6 H4 Z$ p
uint16_t RESERVED2;
4 ]2 Z% X! c R& R' B- Z' [ __IO uint16_t CR1;
/ e/ C) D! u# U uint16_t RESERVED3;
' E* S. Y4 N' E9 R; Z% J __IO uint16_t CR2;% f& q3 x! S2 D% g" l) e+ W
uint16_t RESERVED4;
/ I# Q7 C$ d, V9 U3 r2 t+ D __IO uint16_t CR3;. f2 V9 `# U( _2 E# p9 q% `
uint16_t RESERVED5;
B' u) I' \# T- a6 Z* T __IO uint16_t GTPR;
4 \- Q$ q% `6 d2 B uint16_t RESERVED6;/ ~- r% j; j. P% l
} USART_TypeDef;
6 v+ | U/ N4 M- j9 w
+ N- g C6 F: I; [" ~/** % c, L3 x+ W, f1 f
* @brief Window WATCHDOG
0 y3 {6 E( d; t# J' c1 V! w */
' l% a7 y* U, g/ ` t3 X' N- b
- z( T; o5 X0 C% ~( R$ utypedef struct
% u% R& T& [" z |{
, G. L, e1 g1 i0 e) M3 U% T __IO uint32_t CR;
2 r2 [, c: z6 D2 Z __IO uint32_t CFR;& u W' j7 {( J8 o5 j, R
__IO uint32_t SR;
" c F# M5 D4 y0 v2 h# H% a' W& n} WWDG_TypeDef;
- T# m6 ?. M/ T
1 W$ l, H% |7 b/ p/**
T. ~8 @/ `9 A7 p * @}7 Q1 ]% G/ q* [ I; T
*/0 y" m0 j% ?& K& ]
1 V" R3 c9 h' g6 q' k
/** @addtogroup Peripheral_memory_map! r1 F1 O; y5 j# U- p2 W' h" y% c9 w
* @{7 ]8 V2 ?" M' g7 [$ [
*/
2 Z! j, ~! v( i6 }2 {/ H3 ` F5 S, d( J
: l- D N, i6 X! M' ?
#define FLASH_BASE ((uint32_t)0x08000000) /*!< FLASH base address in the alias region a) i$ d- k% k. Z1 ]
在Alias地区Flash基址*/) U* a* T i/ l: B9 Q5 x/ B+ W
#define SRAM_BASE ((uint32_t)0x20000000) /*!< SRAM base address in the alias region */
! o8 Y r' M2 p7 |0 L6 ?#define PERIPH_BASE ((uint32_t)0x40000000) /*!< Peripheral base address in the alias region */$ c! @4 I! ?& ?3 x. d/ E8 x. i
! ] H9 {9 M% O0 w0 l. r3 f* ~#define SRAM_BB_BASE ((uint32_t)0x22000000) /*!< SRAM base address in the bit-band region */* h$ F! z7 D# ~
#define PERIPH_BB_BASE ((uint32_t)0x42000000) /*!< Peripheral base address in the bit-band region */2 Y1 z" k5 E& `4 L+ k
( H7 B: U% C; a; {8 p' A
#define FSMC_R_BASE ((uint32_t)0xA0000000) /*!< FSMC registers base address *// G+ ?4 p3 n! N2 ]; F* [% M- \
' r) z. u/ N/ J/*!< Peripheral memory map */
* m- r# ^+ p7 \! Y$ ~#define APB1PERIPH_BASE PERIPH_BASE3 u- H7 a% Z. k" I' z! P
#define APB2PERIPH_BASE (PERIPH_BASE + 0x10000)$ j+ }; x, A: S8 P ~) f7 a( p
#define AHBPERIPH_BASE (PERIPH_BASE + 0x20000)! ]3 Q# j8 q- E. T7 P
. f3 e- k+ A; B3 x; l8 I#define TIM2_BASE (APB1PERIPH_BASE + 0x0000)
4 ~4 V% A1 b4 R* {% B2 I% W) v#define TIM3_BASE (APB1PERIPH_BASE + 0x0400)+ q% u, @* [, i$ _/ y m
#define TIM4_BASE (APB1PERIPH_BASE + 0x0800)% V5 V' `1 c) _. A; V' }1 l0 ?
#define TIM5_BASE (APB1PERIPH_BASE + 0x0C00)
% R; q) r f! G' p1 w#define TIM6_BASE (APB1PERIPH_BASE + 0x1000)$ ?$ [" @% l/ d9 ^$ C
#define TIM7_BASE (APB1PERIPH_BASE + 0x1400)4 W6 ^1 @. ?1 Y; J, E8 d4 T
#define TIM12_BASE (APB1PERIPH_BASE + 0x1800)
# j! n8 M+ H% w! ~#define TIM13_BASE (APB1PERIPH_BASE + 0x1C00): d8 N8 g6 x% x: ^
#define TIM14_BASE (APB1PERIPH_BASE + 0x2000)
0 @" N/ `9 p; {4 v#define RTC_BASE (APB1PERIPH_BASE + 0x2800)
5 k6 W, E5 _/ _" h1 d$ G#define WWDG_BASE (APB1PERIPH_BASE + 0x2C00)
' h% U m0 U. Q1 O3 S% H% z#define IWDG_BASE (APB1PERIPH_BASE + 0x3000)
0 D/ g2 b7 G6 Y9 W1 R' Q' ^#define SPI2_BASE (APB1PERIPH_BASE + 0x3800)
& [; x6 R% d4 ?! K1 w#define SPI3_BASE (APB1PERIPH_BASE + 0x3C00) _; q) V2 A8 k7 _
#define USART2_BASE (APB1PERIPH_BASE + 0x4400)
% w( ], K [) U: y' f#define USART3_BASE (APB1PERIPH_BASE + 0x4800)
$ r* G* q K6 _: |) p* p9 V#define UART4_BASE (APB1PERIPH_BASE + 0x4C00)
- u3 t5 f+ }+ T, f) N, [#define UART5_BASE (APB1PERIPH_BASE + 0x5000)
/ B6 `& G7 G* _0 p#define I2C1_BASE (APB1PERIPH_BASE + 0x5400) \/ h( d- |- u4 y
#define I2C2_BASE (APB1PERIPH_BASE + 0x5800)
& }# I' n& [8 C#define CAN1_BASE (APB1PERIPH_BASE + 0x6400)( [3 ^2 z. t+ ~0 v" f6 S
#define CAN2_BASE (APB1PERIPH_BASE + 0x6800)
$ a N% Q! G7 t0 B& `0 H# C#define BKP_BASE (APB1PERIPH_BASE + 0x6C00)
& z% C5 g5 H' m ~9 x$ I/ l#define PWR_BASE (APB1PERIPH_BASE + 0x7000)% ~$ m. L t$ I h' V( ~; B
#define DAC_BASE (APB1PERIPH_BASE + 0x7400)6 M( W1 _% \ H" D, D( y+ N) Z2 A
#define CEC_BASE (APB1PERIPH_BASE + 0x7800)- i3 f9 f* V5 l' F7 i5 o1 E$ W# p& L
% }1 k( a3 o# q, }; C
#define AFIO_BASE (APB2PERIPH_BASE + 0x0000)3 C$ m; r1 Q( n9 }+ }9 b
#define EXTI_BASE (APB2PERIPH_BASE + 0x0400)+ z4 W& f5 r5 q' C5 h
#define GPIOA_BASE (APB2PERIPH_BASE + 0x0800) }# @( I$ D7 l# p' V" E
#define GPIOB_BASE (APB2PERIPH_BASE + 0x0C00)
* P% r6 k! W( J/ D, l% w#define GPIOC_BASE (APB2PERIPH_BASE + 0x1000), W" q+ y6 S3 y, s! X# k: |5 ?
#define GPIOD_BASE (APB2PERIPH_BASE + 0x1400)- V( P' Y7 b& w) r, q
#define GPIOE_BASE (APB2PERIPH_BASE + 0x1800)$ y3 ~/ Y# J9 ^- p/ i
#define GPIOF_BASE (APB2PERIPH_BASE + 0x1C00)
: k; [4 T; j7 e3 e#define GPIOG_BASE (APB2PERIPH_BASE + 0x2000)4 t' J% [$ @* Y1 t) k% I
#define ADC1_BASE (APB2PERIPH_BASE + 0x2400)0 c0 l9 v( b6 Y% b' f# ]
#define ADC2_BASE (APB2PERIPH_BASE + 0x2800)/ T: P* C4 [' U0 \ h& e
#define TIM1_BASE (APB2PERIPH_BASE + 0x2C00)3 N. U( w" y3 n% W- u* `
#define SPI1_BASE (APB2PERIPH_BASE + 0x3000)
: s+ s2 |$ q' @4 ~1 j( \#define TIM8_BASE (APB2PERIPH_BASE + 0x3400)
, [4 R/ J! |1 j: ]5 s9 N#define USART1_BASE (APB2PERIPH_BASE + 0x3800)
9 `# @2 Q: i P$ W/ Y0 g3 m#define ADC3_BASE (APB2PERIPH_BASE + 0x3C00)8 {3 V% a8 J* W( T4 L
#define TIM15_BASE (APB2PERIPH_BASE + 0x4000)
# X }# u* ?+ R/ R+ m#define TIM16_BASE (APB2PERIPH_BASE + 0x4400)% Z2 U0 r8 u1 `, s; V9 ~: l
#define TIM17_BASE (APB2PERIPH_BASE + 0x4800)
* j y, K* r: }4 ]: j#define TIM9_BASE (APB2PERIPH_BASE + 0x4C00)
; o# l- v# b, ^& _#define TIM10_BASE (APB2PERIPH_BASE + 0x5000); k; K- I/ r3 G6 |
#define TIM11_BASE (APB2PERIPH_BASE + 0x5400)
0 J6 M, m+ [6 _# m- v1 D7 V; X6 e% \% X4 w
#define SDIO_BASE (PERIPH_BASE + 0x18000)
* c/ S1 h7 K) O" j) p, J9 x! ?7 M# o, c r$ A% X
#define DMA1_BASE (AHBPERIPH_BASE + 0x0000)
3 q( o# v, x: G/ j8 L! s. |#define DMA1_Channel1_BASE (AHBPERIPH_BASE + 0x0008)
) x6 @# O6 S' f9 o4 `4 O#define DMA1_Channel2_BASE (AHBPERIPH_BASE + 0x001C)7 q5 q, f6 L4 A
#define DMA1_Channel3_BASE (AHBPERIPH_BASE + 0x0030)
% \3 U. @, g1 K& u6 {3 W#define DMA1_Channel4_BASE (AHBPERIPH_BASE + 0x0044)/ j* y, D1 v N! Z8 }4 o* ], t. ?" o' H
#define DMA1_Channel5_BASE (AHBPERIPH_BASE + 0x0058)
# Z& E8 F3 ^6 t: C$ n#define DMA1_Channel6_BASE (AHBPERIPH_BASE + 0x006C)
" W+ x4 [ ?$ {) `1 I; E#define DMA1_Channel7_BASE (AHBPERIPH_BASE + 0x0080)9 M* x9 v8 U- n& I+ C
#define DMA2_BASE (AHBPERIPH_BASE + 0x0400)7 U8 D! c8 I* z6 O/ ^
#define DMA2_Channel1_BASE (AHBPERIPH_BASE + 0x0408)
$ N/ g" s! T6 e4 ^) R#define DMA2_Channel2_BASE (AHBPERIPH_BASE + 0x041C)
* k" S, P; y0 o @( C- s# G#define DMA2_Channel3_BASE (AHBPERIPH_BASE + 0x0430)
8 G, q- F% H+ o/ x3 m; U#define DMA2_Channel4_BASE (AHBPERIPH_BASE + 0x0444)
" P* z p7 f4 r8 X#define DMA2_Channel5_BASE (AHBPERIPH_BASE + 0x0458)
, ^ k0 c; R( z) q5 |- F1 }' U#define RCC_BASE (AHBPERIPH_BASE + 0x1000)
9 r+ N- T* E! Q6 D3 l$ ~#define CRC_BASE (AHBPERIPH_BASE + 0x3000)( O! Q+ I( r1 x$ A# }
1 Z8 A2 J$ F* U% q: @
#define FLASH_R_BASE (AHBPERIPH_BASE + 0x2000) /*!< Flash registers base address */3 Z+ a! @$ n: A' R6 E1 \
#define OB_BASE ((uint32_t)0x1FFFF800) /*!< Flash Option Bytes base address */( b/ L* e- y! j) ]% e4 X+ |4 M
) Z4 H& Q9 ~. ?! ]' A
#define ETH_BASE (AHBPERIPH_BASE + 0x8000)
% y6 }3 p5 z/ X' F#define ETH_MAC_BASE (ETH_BASE); ]; _% c7 W: |7 _# a6 r
#define ETH_MMC_BASE (ETH_BASE + 0x0100)
0 L4 }/ Z% ?, H9 Q#define ETH_PTP_BASE (ETH_BASE + 0x0700)4 Y- ~, T e2 q, u
#define ETH_DMA_BASE (ETH_BASE + 0x1000)( i6 ^3 H: ~+ I4 [9 F( v
3 D) T2 P' @2 }$ b+ @* j6 D#define FSMC_Bank1_R_BASE (FSMC_R_BASE + 0x0000) /*!< FSMC Bank1 registers base address */* I! O) q$ w2 Y- D/ U/ w
#define FSMC_Bank1E_R_BASE (FSMC_R_BASE + 0x0104) /*!< FSMC Bank1E registers base address */
+ l1 l5 V D. {8 o" v" _; w7 E#define FSMC_Bank2_R_BASE (FSMC_R_BASE + 0x0060) /*!< FSMC Bank2 registers base address */
4 t+ F* ?7 {8 O+ Q#define FSMC_Bank3_R_BASE (FSMC_R_BASE + 0x0080) /*!< FSMC Bank3 registers base address */ Y2 `% b* k$ V& y2 z+ D
#define FSMC_Bank4_R_BASE (FSMC_R_BASE + 0x00A0) /*!< FSMC Bank4 registers base address *// b0 j( ?9 Q7 H4 h. U/ w2 \5 f" O
8 _2 I( i+ x" e* ?4 h
#define DBGMCU_BASE ((uint32_t)0xE0042000) /*!< Debug MCU registers base address */
* {4 q6 _* v5 E. u7 L
1 o/ o4 o2 K. D: ^3 q1 i h, } c; X6 ]! U
——————————————————————————————————————————————————— ——————————————————————————————————————————————————— /******************************************************************************/
2 w" x& X2 i/ ]* W5 X1 J; y) v /* Peripheral Registers_Bits_Definition 0 K+ A- E6 O% Z. m
、 串行寄存器位定义 */
' k1 x5 ?: ~: N6 b7 z/ u2 F/******************************************************************************/, l* b' _7 r7 f* Y
9 P6 }; l/ ]; T( k5 y
/******************************************************************************/' ?# @1 R& \3 X2 _, b
/* */$ x8 N9 P U2 r! ~* @) q9 f y
/* CRC calculation unit */
9 W$ ^3 G( {0 o: |7 Z s/* CRC 校验单元 */
p* T2 A7 {8 V K9 O/******************************************************************************/
5 d" R& R' ~9 ?, n" t
" ^+ C9 @4 X$ d' }/******************* Bit definition for CRC_DR register *********************/8 m8 [4 G& p; O! T7 k% C% K
#define CRC_DR_DR ((uint32_t)0xFFFFFFFF) /*!< Data register bits数据寄存器位 */
* c' k$ d; r5 Q- I* l7 m5 r" Z3 o数据寄存器(CRC_DR)+ J9 t1 A/ C; K. U* S9 M( h
+ @7 ]+ g9 v% e5 D4 @/******************* Bit definition for CRC_IDR register ********************/5 |+ a' K( F$ k1 e% R; I
#define CRC_IDR_IDR ((uint8_t)0xFF) /*!< General-purpose 8-bit data register bits 通用8位寄存器*/
* R" {- `; E1 }: L. J+ l. R独立数据寄存器(CRC_IDR)) e$ v9 h+ y& D# \# \9 s# K- t" q1 G
控制寄存器(CRC_CR) 2 N0 B. h8 i2 r& e
/******************** Bit definition for CRC_CR register ********************/
3 l& Y. V* O; \#define CRC_CR_RESET ((uint8_t)0x01) /*!< RESET bit 重启位*/# D2 m" \' B: Q1 |
/ W" \4 n e$ X( S* s4 C, i0 ]/******************************************************************************/
% w& F b: I: G2 a8 q/* */5 z2 `6 ^) k; [4 q
/* Power Control */
3 g* c9 B4 a+ L% _) R3 q/* */
! z V( B4 q% @! F$ D/******************************************************************************/
0 X) y2 P9 L# }! y2 E
! x* ?5 ^4 L& L/******************** Bit definition for PWR_CR register ********************/
$ x3 @4 [$ |& I/ M#define PWR_CR_LPDS ((uint16_t)0x0001) /*!< Low-Power Deepsleep */$ K3 @8 [! ]! E+ g- ^
#define PWR_CR_PDDS ((uint16_t)0x0002) /*!< Power Down Deepsleep */
/ p) G- }" M: P- P+ F2 g: D#define PWR_CR_CWUF ((uint16_t)0x0004) /*!< Clear Wakeup Flag */
/ n" z5 @2 s/ H#define PWR_CR_CSBF ((uint16_t)0x0008) /*!< Clear Standby Flag */
3 l8 H6 p0 S! }: [: s" P/ W$ n' ^#define PWR_CR_PVDE ((uint16_t)0x0010) /*!< Power Voltage Detector Enable */
3 v1 L. E8 R+ W0 A) q; H9 R% L+ a+ T+ E2 m: f
#define PWR_CR_PLS ((uint16_t)0x00E0) /*!< PLS[2:0] bits (PVD Level Selection) */0 G6 I# V: x2 i; J1 s3 G6 T
#define PWR_CR_PLS_0 ((uint16_t)0x0020) /*!< Bit 0 */
7 S) l+ D. u& T* i. ~9 B#define PWR_CR_PLS_1 ((uint16_t)0x0040) /*!< Bit 1 */+ X1 K) T4 b9 c* U9 I2 w' z
#define PWR_CR_PLS_2 ((uint16_t)0x0080) /*!< Bit 2 */
! a; t5 e0 i8 V& ?5 x. b% x1 Z* A! X# D5 N- w
/*!< PVD level configuration */8 m3 Z+ I- \: a# y! K# _
#define PWR_CR_PLS_2V2 ((uint16_t)0x0000) /*!< PVD level 2.2V */
0 T7 y I1 h5 y4 m* A6 j* M#define PWR_CR_PLS_2V3 ((uint16_t)0x0020) /*!< PVD level 2.3V */
V" [, k9 w% p#define PWR_CR_PLS_2V4 ((uint16_t)0x0040) /*!< PVD level 2.4V */! f* `5 |2 h2 K9 e9 r
#define PWR_CR_PLS_2V5 ((uint16_t)0x0060) /*!< PVD level 2.5V */- o4 C7 f* L* z' q
#define PWR_CR_PLS_2V6 ((uint16_t)0x0080) /*!< PVD level 2.6V */
' t8 ^/ ~ t# }1 h3 h' B& N#define PWR_CR_PLS_2V7 ((uint16_t)0x00A0) /*!< PVD level 2.7V */+ {* [: |, D3 Q |6 d6 d
#define PWR_CR_PLS_2V8 ((uint16_t)0x00C0) /*!< PVD level 2.8V */. k. A0 H T( y2 M
#define PWR_CR_PLS_2V9 ((uint16_t)0x00E0) /*!< PVD level 2.9V */
) H6 X9 f+ Q( I6 ]& R8 O* E+ R y+ b; ~* k. `; |1 \
#define PWR_CR_DBP ((uint16_t)0x0100) /*!< Disable Backup Domain write protection */
" Y, m/ `" K( U+ b9 g2 M$ R$ t% Y! r. j7 k" F' A, M: y$ T% k {
8 s; {6 X0 d% l) I! L+ T+ `/******************* Bit definition for PWR_CSR register ********************/6 F: C7 Z9 @0 C
#define PWR_CSR_WUF ((uint16_t)0x0001) /*!< Wakeup Flag */
4 _; |- i* e9 n0 T1 s#define PWR_CSR_SBF ((uint16_t)0x0002) /*!< Standby Flag */- V' u7 b- m1 m, V; R% Y8 k
#define PWR_CSR_PVDO ((uint16_t)0x0004) /*!< PVD Output */, F% e5 L" J% n% t t- Q- \
#define PWR_CSR_EWUP ((uint16_t)0x0100) /*!< Enable WKUP pin */; ^; C1 l" z' i# V* {
* I) l& r: V, h4 w# }. o/******************************************************************************/- p' h0 {# l/ c
/* */
. w6 x" c0 j8 J# Y* A; a; V/* Backup registers */
& O+ a* J/ S3 r2 h }; G$ {2 [5 w/* */
- l! d" G$ j+ s/******************************************************************************/0 X" D& a( k) Y) x
2 @5 r; {) x1 L8 G6 n y8 [: G/******************* Bit definition for BKP_DR1 register ********************/2 c. J$ s( P3 T" @$ Q
#define BKP_DR1_D ((uint16_t)0xFFFF) /*!< Backup data */& T* i) k/ ?5 S
+ r5 M7 R6 F1 q2 ~( T
/******************* Bit definition for BKP_DR2 register ********************/1 ?5 k$ Z+ Z- l/ Y
#define BKP_DR2_D ((uint16_t)0xFFFF) /*!< Backup data */
) X# c' |8 S& V9 P% R8 O: |/ k9 R$ \- i# A# J+ W
/******************* Bit definition for BKP_DR3 register ********************/
8 N' w8 q0 l$ W% d$ [6 u6 z#define BKP_DR3_D ((uint16_t)0xFFFF) /*!< Backup data */, K' B! l& v) z* f, s
( {" F! R l3 ?5 o$ Q/******************* Bit definition for BKP_DR4 register ********************/3 l0 t$ @, y5 }. p
#define BKP_DR4_D ((uint16_t)0xFFFF) /*!< Backup data */4 K/ ^4 G" }5 Y; k u4 {
1 ~3 @& s- b4 e' {$ Q% V* T$ X/ u/******************* Bit definition for BKP_DR5 register ********************/) J( G* L, y) H
#define BKP_DR5_D ((uint16_t)0xFFFF) /*!< Backup data */
! }. R3 N' N: |2 v" G5 Z: e' F
* Y6 o% J' ^* l8 k) O) _5 A( X+ [" m/******************* Bit definition for BKP_DR6 register ********************/
( }7 f6 O' P( S- y$ [1 n+ M; i#define BKP_DR6_D ((uint16_t)0xFFFF) /*!< Backup data */+ I, @7 L9 o7 {( g7 n) E; W
" E+ M& `2 ?& ?
/******************* Bit definition for BKP_DR7 register ********************/* F6 m& S: k0 U' ~& x8 w( L
#define BKP_DR7_D ((uint16_t)0xFFFF) /*!< Backup data */* c7 @& |8 v) }* ^ g
" U0 Y9 E7 P+ d7 L2 w$ V% Q+ G# l/******************* Bit definition for BKP_DR8 register ********************/3 t* r( H- Y( K k7 s
#define BKP_DR8_D ((uint16_t)0xFFFF) /*!< Backup data */
4 J) ?7 V+ M: m/ }* r% Q
6 q, H5 x7 s9 v' Z8 ?/******************* Bit definition for BKP_DR9 register ********************/
- c$ C: u% v8 A( D$ k; I- l#define BKP_DR9_D ((uint16_t)0xFFFF) /*!< Backup data */) X3 K- c5 I/ a0 p. H
2 \" P) z6 J+ v, e+ Q3 j- L( h9 }% U
/******************* Bit definition for BKP_DR10 register *******************/
5 G% D; A7 f. x9 u+ O#define BKP_DR10_D ((uint16_t)0xFFFF) /*!< Backup data */
4 ^: O( b$ U7 f P! t. V( q w p! a* i1 C
/******************* Bit definition for BKP_DR11 register *******************/
+ o6 J( ~& a" n$ H& N4 S- |# I#define BKP_DR11_D ((uint16_t)0xFFFF) /*!< Backup data */
* s3 J# _: \) Q: a4 V% e$ d4 Y! u$ L- n
/******************* Bit definition for BKP_DR12 register *******************/
8 M2 c+ B5 C, |1 X' @#define BKP_DR12_D ((uint16_t)0xFFFF) /*!< Backup data */
: u+ i" Z; U0 Q) _3 z0 ?8 \; U2 L! ?- g k, h& G/ L
/******************* Bit definition for BKP_DR13 register *******************/
0 G! x T! P2 Y#define BKP_DR13_D ((uint16_t)0xFFFF) /*!< Backup data */
# ]( T& m+ ?9 y: c( s7 j8 K% W _% N/ u* n; g
/******************* Bit definition for BKP_DR14 register *******************/
" O' h* q0 U8 k. g#define BKP_DR14_D ((uint16_t)0xFFFF) /*!< Backup data */
6 R. d) ~8 z( R6 G! ^# J6 V! [1 D) a* ]5 D6 u' V# Y
/******************* Bit definition for BKP_DR15 register *******************/0 f* d% i& K6 p: Y- o
#define BKP_DR15_D ((uint16_t)0xFFFF) /*!< Backup data */
8 ] s; D0 q. Y( d0 z# G% D( g/ C( K0 `: M* X X0 f8 f& T; ~" x
/******************* Bit definition for BKP_DR16 register *******************/" I& ?5 @' V1 g, r. Y
#define BKP_DR16_D ((uint16_t)0xFFFF) /*!< Backup data */& l( G* E G3 L
; |; [% [" r" D- c( F" ]$ t/******************* Bit definition for BKP_DR17 register *******************/* P# i" F2 c. z, f r7 {/ W; s- o4 M
#define BKP_DR17_D ((uint16_t)0xFFFF) /*!< Backup data */
3 L: ^9 z& v* Y, a) H* i. }' Y
' w: X# f# D( n0 V7 c/****************** Bit definition for BKP_DR18 register ********************/2 p+ u5 c( l) E1 K O& U0 a
#define BKP_DR18_D ((uint16_t)0xFFFF) /*!< Backup data */# m0 S0 t: w+ z: H5 m! V T6 \
- |0 G9 R6 l( k( E( s) k
/******************* Bit definition for BKP_DR19 register *******************/* f8 d4 E( _: q: A! H; n
#define BKP_DR19_D ((uint16_t)0xFFFF) /*!< Backup data */
) B4 t! \# m3 k* h$ P1 U! H2 M3 R; S3 Z5 e: d) _7 E
/******************* Bit definition for BKP_DR20 register *******************/: x( s) K" Y! F7 {0 [
#define BKP_DR20_D ((uint16_t)0xFFFF) /*!< Backup data */7 W5 P- c* K! q
/ Q0 A, [6 E: f6 w+ P/ g: ] B/******************* Bit definition for BKP_DR21 register *******************/
/ O0 w- G# \" v8 _6 e5 M#define BKP_DR21_D ((uint16_t)0xFFFF) /*!< Backup data */
0 B0 B. [- m; w4 |: S# ]7 l, V' |, {8 l2 ^/ M
/******************* Bit definition for BKP_DR22 register *******************/
% D7 x, D. k: x9 F( [" M S9 I#define BKP_DR22_D ((uint16_t)0xFFFF) /*!< Backup data */
8 d# \, r3 O, k$ ~3 C4 J. q7 |' {' A n
{, D" s" v5 K) G9 h/******************* Bit definition for BKP_DR23 register *******************/- T: w& Q$ _$ l" k/ D
#define BKP_DR23_D ((uint16_t)0xFFFF) /*!< Backup data */+ B& j$ W2 Q. b/ N* \
r% _! {) h8 v. r7 ~/******************* Bit definition for BKP_DR24 register *******************/
# h- l: h: A7 j/ O* \#define BKP_DR24_D ((uint16_t)0xFFFF) /*!< Backup data */5 {' k, a4 h3 ~# f# b' T) W
- z7 ~0 z; j% x( q) l" `/******************* Bit definition for BKP_DR25 register *******************/1 q- B( ~* Q+ B4 o2 k9 {9 V
#define BKP_DR25_D ((uint16_t)0xFFFF) /*!< Backup data */
O! H% F; u" d2 d; L
. I+ w. {6 i; }- Y, r/******************* Bit definition for BKP_DR26 register *******************/' u* z* B$ n$ U2 u2 t! E! O; B
#define BKP_DR26_D ((uint16_t)0xFFFF) /*!< Backup data */" w( U; |# Y9 ~6 L+ ]" p0 b1 A
2 }; K, r$ w* Y, f; B- C5 ~/******************* Bit definition for BKP_DR27 register *******************/
5 v4 d) o: g7 [- c0 w! R#define BKP_DR27_D ((uint16_t)0xFFFF) /*!< Backup data */% h7 q( g- D0 H. s$ Y9 O: I0 H; o7 D1 H
$ _6 Z. S0 R! f+ S/******************* Bit definition for BKP_DR28 register *******************/" Z5 Z) ~ t$ e/ s
#define BKP_DR28_D ((uint16_t)0xFFFF) /*!< Backup data */
1 I2 K6 [4 s/ t9 f- m b3 e
3 n. v2 ~& Y# O; @; I9 Z, y8 E+ e$ ^/******************* Bit definition for BKP_DR29 register *******************/
( V4 s! l& K! ?' d, E$ N#define BKP_DR29_D ((uint16_t)0xFFFF) /*!< Backup data */ _2 r2 A2 W% W# O
; ^% a# [: G; F. T$ O W" Y
/******************* Bit definition for BKP_DR30 register *******************/4 Q- B3 M5 `% Z1 J; {/ `, Z
#define BKP_DR30_D ((uint16_t)0xFFFF) /*!< Backup data */
8 ^- l0 ]" x1 g* x1 R( Q! Q9 N! P* x( |3 Y+ C
/******************* Bit definition for BKP_DR31 register *******************/
$ M# m+ A" p8 _#define BKP_DR31_D ((uint16_t)0xFFFF) /*!< Backup data */
* X9 R/ U& a) Q8 O/ l) b5 C7 G) E' g4 a0 Y8 e7 ?
/******************* Bit definition for BKP_DR32 register *******************/
1 R9 e2 J V9 h0 g$ O; n6 E#define BKP_DR32_D ((uint16_t)0xFFFF) /*!< Backup data */ Z* B( E. E i) G. `
/ f6 ^: j0 A1 P( _/******************* Bit definition for BKP_DR33 register *******************/9 u( j9 C6 z; ?! R
#define BKP_DR33_D ((uint16_t)0xFFFF) /*!< Backup data */
f3 U& p$ E- D& H u7 Y8 E, o6 V, y1 M: \
/******************* Bit definition for BKP_DR34 register *******************/
0 e% p% N- v# o( L#define BKP_DR34_D ((uint16_t)0xFFFF) /*!< Backup data */
: F2 _3 L; l. c$ Q4 S6 O3 }8 [6 l' W9 v( f
/******************* Bit definition for BKP_DR35 register *******************/
( ~- k( }; C2 I G6 U8 O( [1 A+ L0 W#define BKP_DR35_D ((uint16_t)0xFFFF) /*!< Backup data */
/ ~+ }! Q" r$ |5 A# P/ K& s/ x D% m; d
( e' O# C4 }* I: T% F# X4 {/******************* Bit definition for BKP_DR36 register *******************/7 ~0 S+ m f+ `+ P3 n
#define BKP_DR36_D ((uint16_t)0xFFFF) /*!< Backup data */) }" D7 y3 N% _6 v
: _( r' S6 d" y' K1 W/******************* Bit definition for BKP_DR37 register *******************/
2 T- f. @6 b* H+ t! ~/ B5 r' p#define BKP_DR37_D ((uint16_t)0xFFFF) /*!< Backup data */% X" h1 Y: T) v9 x, Q2 S$ H* J
2 D. T: N$ T+ O1 Y8 B: C/******************* Bit definition for BKP_DR38 register *******************/
# `$ t& i$ f; }#define BKP_DR38_D ((uint16_t)0xFFFF) /*!< Backup data */
, m0 p7 f: \" o$ p1 M
. Z1 y1 c1 U% M' i9 e$ g/******************* Bit definition for BKP_DR39 register *******************/
: r# ~2 l9 z. W4 m% e#define BKP_DR39_D ((uint16_t)0xFFFF) /*!< Backup data */7 e1 ?* j, W( z( f. ^, n
+ X f7 `6 C% k3 o& b- h" a/******************* Bit definition for BKP_DR40 register *******************/
' B! O+ X. V: P& p9 n4 @#define BKP_DR40_D ((uint16_t)0xFFFF) /*!< Backup data */
$ X# U- c* W2 L* o; }" d5 |& O( D, m0 u2 Z6 T0 N
/******************* Bit definition for BKP_DR41 register *******************/
% w& S5 y. n+ y- `- d# ?7 o2 t! j#define BKP_DR41_D ((uint16_t)0xFFFF) /*!< Backup data */
+ q. ]9 }$ Z- h6 C; O( `5 h: e! N- N- z
/******************* Bit definition for BKP_DR42 register *******************/) {! U0 k& w4 x/ ^
#define BKP_DR42_D ((uint16_t)0xFFFF) /*!< Backup data */
6 e0 e9 f1 a) z; ^) ^ v# {0 b; X* j/ p2 o) O
/****************** Bit definition for BKP_RTCCR register *******************/
, e; P" y" b p0 M4 a+ p#define BKP_RTCCR_CAL ((uint16_t)0x007F) /*!< Calibration value */
& N- G( H, y9 A! b5 D9 g# c#define BKP_RTCCR_CCO ((uint16_t)0x0080) /*!< Calibration Clock Output */8 w! x& A/ n( {( V3 A2 U
#define BKP_RTCCR_ASOE ((uint16_t)0x0100) /*!< Alarm or Second Output Enable */
' v5 w" }; {$ G' ~, _$ ]1 t#define BKP_RTCCR_ASOS ((uint16_t)0x0200) /*!< Alarm or Second Output Selection */$ \: s0 C$ T" C- r& i6 F
8 q9 e% @- {- l$ a. u& ~5 o/******************** Bit definition for BKP_CR register ********************/
" Q9 t' Q( w4 R1 d C9 z#define BKP_CR_TPE ((uint8_t)0x01) /*!< TAMPER pin enable */: u/ C, \ h0 U( C7 q2 J
#define BKP_CR_TPAL ((uint8_t)0x02) /*!< TAMPER pin active level */
9 ?/ _# ?, ~6 Q3 t, L6 r! Q+ S' x3 T9 i0 u" K% A3 |; p0 m
/******************* Bit definition for BKP_CSR register ********************/; w: e0 z4 [: K) e
#define BKP_CSR_CTE ((uint16_t)0x0001) /*!< Clear Tamper event */" c5 n$ k0 j, h
#define BKP_CSR_CTI ((uint16_t)0x0002) /*!< Clear Tamper Interrupt */0 C4 V1 a8 g h( w; {; I
#define BKP_CSR_TPIE ((uint16_t)0x0004) /*!< TAMPER Pin interrupt enable */
6 I6 G; Y( H- ^& M) m#define BKP_CSR_TEF ((uint16_t)0x0100) /*!< Tamper Event Flag */ l, w2 M- k3 W: P
#define BKP_CSR_TIF ((uint16_t)0x0200) /*!< Tamper Interrupt Flag */* p% g9 |3 n" r, b. O7 b
! g) P/ ~9 Z6 |
/******************************************************************************/( }" b. {' j; y+ N& ]
/* */! i5 a: K% d* M7 O5 g
/* Reset and Clock Control */
" J6 [% h3 Y5 w/* */
' V+ o2 a; g0 W) c/******************************************************************************/
# K5 a1 K i- I2 ]. E4 q* h) p9 n; d, f- O b% {5 q- M) t5 g5 @6 j
/******************** Bit definition for RCC_CR register ********************/( O* I. e, Q. s3 S& q$ W8 w
#define RCC_CR_HSION ((uint32_t)0x00000001) /*!< Internal High Speed clock enable */7 ~ l5 o; `9 k. x+ O4 Z& |
#define RCC_CR_HSIRDY ((uint32_t)0x00000002) /*!< Internal High Speed clock ready flag */- ^7 n: b' k/ c6 d/ l
#define RCC_CR_HSITRIM ((uint32_t)0x000000F8) /*!< Internal High Speed clock trimming */0 i9 {) h% z9 l' I L1 S7 C4 D4 j
#define RCC_CR_HSICAL ((uint32_t)0x0000FF00) /*!< Internal High Speed clock Calibration */
" n! ^9 I/ x/ {& C2 _( m#define RCC_CR_HSEON ((uint32_t)0x00010000) /*!< External High Speed clock enable */
/ I# k4 w# U# S- A& Z4 n/ ^( C#define RCC_CR_HSERDY ((uint32_t)0x00020000) /*!< External High Speed clock ready flag */
2 X. U9 ?' J& A" t w$ ~) Q#define RCC_CR_HSEBYP ((uint32_t)0x00040000) /*!< External High Speed clock Bypass */' S/ H t2 W2 y0 E) N( `
#define RCC_CR_CSSON ((uint32_t)0x00080000) /*!< Clock Security System enable */2 s" Z: w* `$ ?( t" L+ [
#define RCC_CR_PLLON ((uint32_t)0x01000000) /*!< PLL enable */
4 u& w! Y4 L' l#define RCC_CR_PLLRDY ((uint32_t)0x02000000) /*!< PLL clock ready flag */5 c' Q; [ }0 T4 O* h: I
! ]. \, ~; q' i C8 q( N, T8 H#ifdef STM32F10X_CL1 D! l- r+ Z* V7 N1 s
#define RCC_CR_PLL2ON ((uint32_t)0x04000000) /*!< PLL2 enable */% s6 A* \( r8 I# g/ S
#define RCC_CR_PLL2RDY ((uint32_t)0x08000000) /*!< PLL2 clock ready flag */
) J8 D7 F8 D) ~8 w; ?#define RCC_CR_PLL3ON ((uint32_t)0x10000000) /*!< PLL3 enable */) A8 @: j& B% L" Z+ r
#define RCC_CR_PLL3RDY ((uint32_t)0x20000000) /*!< PLL3 clock ready flag */
3 X+ f9 @( D: Y$ E#endif /* STM32F10X_CL */* F+ A( l9 c, z& z8 `% c
$ g8 G: b% P$ M1 S% L: C4 N) {
2 j2 B$ N: M! b: F+ d
9 G1 B# y% K* K: |: s: D# } ——————————————————————————————————————————————————— ——————————————————————————————————————————————————— 截止到目前为止。这个头文件应该注意的都已经解析完毕,剩下的就是相关控制位的定义了。: M# w* U) H( ^$ E2 \6 P. h# k' s
|