- 1 void GPIO_Configuration(void)4 y c4 g% O3 b i4 \" P s/ ^
- 2 {
& B/ b4 y! I/ s3 p - 3 RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA, ENABLE);
5 V( ]5 t" P2 y2 P$ J: S - 4 RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOB, ENABLE);4 N* x8 _: T6 I; K
- 5 + u! F/ V& q9 F/ V- m4 N
- 6 /* Configure ADC Channel as analog input */8 c* l* d2 N1 |0 l4 d. a0 S |$ Z
- 7 GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1 ;
8 k# A! H; y% h. T1 C4 w, u - 8 GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AN;$ H2 r8 E& [1 F) L ?
- 9 GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
* s, d$ n: w/ U* D& p3 `# c - 10 GPIO_Init(GPIOB, &GPIO_InitStructure);
; ~$ E$ E* B: ~$ Z6 K - 11 9 L0 i3 Y. c; z3 e6 _& g
- 12 /*GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9;
& M9 c( s. p4 z1 m! H - 13 GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;1 B9 {, E9 Q- e; p# V& n
- 14 GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
2 Y: m7 d9 i& L5 s: u3 j8 G - 15 GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
4 K& }2 H: ~- f( O) }- Q7 f - 16 GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL ;
& c4 B5 p3 L0 U, a" {" i - 17 GPIO_Init(GPIOA, &GPIO_InitStructure); - v9 E5 i4 r1 t, s7 B n
- 18 GPIO_PinAFConfig(GPIOA, GPIO_PinSource9, GPIO_AF_2);
3 H' P. h: r L: s: _ - 19
. a; T. ~4 q+ O( O$ p - 20 GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0;//
0 u; W( k7 B1 `( M/ v4 c) K - 21 GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
O) f) C, r: o - 22 GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
+ [4 c+ h3 X% c& X1 q - 23 GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
[2 q: m8 u, \+ h4 K' l9 C - 24 GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_DOWN ;
4 Q6 {4 r0 Y; E. U - 25 GPIO_Init(GPIOA, &GPIO_InitStructure); */
5 l& c/ ~' w$ H - 26
/ b5 P/ `0 s& r+ p, O - 27 GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6|GPIO_Pin_1 ;//3 t2 t8 y$ d: G. y/ O' @( B
- 28 GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;. I3 L' U' Q9 d! B& l
- 29 GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
- N! `4 q# j( j - 30 GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;# T3 X9 T6 h/ g) g! e" G, M
- 31 GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_DOWN;
( f; o: D& s+ C& Z& i c2 c! ` - 32 GPIO_Init(GPIOA, &GPIO_InitStructure); 5 o& d# } n# g
- 33
; j g) C+ E0 Z# v! G' }2 I - 34
5 g8 i7 D9 o& ^6 ?" I! a7 P* w& l - 35
( \8 @) v3 r& K/ h4 x$ m - 36 GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0;//
) u t, }# A0 _9 ?! V - 37 GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
; v* i9 r2 o% \$ o' b' E - 38 GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP; //外部电路上拉,设置为上拉' U7 |# Y5 O4 X& Y: D
- 39 GPIO_Init(GPIOA, &GPIO_InitStructure); ( U4 I0 u" R' y+ z& C6 r) ]
- 40 9 ~% ]8 a' L9 y* K0 J. B
- 41 7 \7 A. @7 c( _8 D$ }: A
- 42
0 A: R2 y0 r# y- L: E+ B3 A - 43 GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2|GPIO_Pin_3|GPIO_Pin_4|GPIO_Pin_5|GPIO_Pin_7|GPIO_Pin_9|GPIO_Pin_10;//& r- ]' u* X/ }2 d: H% C
- 44 GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AN;
0 W" h+ b3 F8 r5 n/ Z# Q - 45 GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_DOWN ;
4 A% k7 D: X+ r - 46 GPIO_Init(GPIOA, &GPIO_InitStructure); 6 U8 t( m1 j+ r4 w3 X; r
- 47 }7 H2 M# t, [5 Y% ]6 I, A
4 L% W+ q+ V9 P: p
复制代码 " W8 C1 V) O, t$ E2 y2 X+ q. x/ _, i
|