- 1 void GPIO_Configuration(void)" G G3 I0 B7 r5 W7 l6 d2 [
- 2 {
9 i1 j- c' ~3 Z: G/ e& U - 3 RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA, ENABLE); 4 b- g; G* Q1 u$ m# n; |9 x
- 4 RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOB, ENABLE);; @* a) v& E. D8 _/ d
- 5
/ k2 Q$ J& ^+ h, J( l - 6 /* Configure ADC Channel as analog input */
1 W) }/ z; [5 Z' V/ G - 7 GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1 ;) x2 j% N; c0 k0 ]- y% t- h
- 8 GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AN;
2 X8 I; |5 I$ k% U. X - 9 GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;" S# P, @4 [8 u4 O
- 10 GPIO_Init(GPIOB, &GPIO_InitStructure);' g+ q B; n) Y3 _9 [
- 11
: h& j6 x# c' y3 A1 k& E4 \9 N - 12 /*GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9;+ s+ L" I! S J+ _/ ^
- 13 GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;# s; M1 N8 E5 M' {* O
- 14 GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
9 W0 g1 F; m; B7 m+ g - 15 GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
) h7 U I& Y' V - 16 GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL ;$ h \$ c+ F2 C- B% L9 a; k$ C
- 17 GPIO_Init(GPIOA, &GPIO_InitStructure); ( d+ Q4 [) W, m. N, C
- 18 GPIO_PinAFConfig(GPIOA, GPIO_PinSource9, GPIO_AF_2);' ?3 k# u* J6 g% s4 ] \& f6 l
- 19 7 ]3 [4 X" J9 C h2 o o' I
- 20 GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0;//( h x) r! H" ?2 Q
- 21 GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;4 P8 z: B9 @% U
- 22 GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
4 r: A% S1 J2 ?& a3 |* [9 { - 23 GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
. \, D" t( k a0 M& L+ o1 p+ V - 24 GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_DOWN ;9 w' a* M# f$ M# b3 D" V
- 25 GPIO_Init(GPIOA, &GPIO_InitStructure); */ # H' G4 P- @5 D# \$ h; C
- 26 1 W- A0 f* I7 f- g
- 27 GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6|GPIO_Pin_1 ;//( N+ N: h# R0 F1 { `- y
- 28 GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
6 m# K! d" j" l& \ - 29 GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
1 U+ r- u! C; _& R: A; q0 S - 30 GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;, [' c. I; S3 @, h! R% k: r( [
- 31 GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_DOWN;) q9 i8 o* o7 d
- 32 GPIO_Init(GPIOA, &GPIO_InitStructure);
, C; t8 h. x' Y0 j& d( p - 33
. ?. F3 P# Z5 p5 \! X - 34 2 [- j5 |) H- G; }
- 35
: _! q! p a+ W9 U: p - 36 GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0;//
9 f5 L! Y s, ~, K - 37 GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;) b4 e) v* H/ z. X& i+ R
- 38 GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP; //外部电路上拉,设置为上拉3 k% x; E* Y/ q
- 39 GPIO_Init(GPIOA, &GPIO_InitStructure); U6 O5 \4 y' C6 K# O! E+ _
- 40
0 w( [5 V* J7 I - 41 $ N$ k& e6 }8 Z# B& y: Y
- 42 $ h' H+ Q/ _" P2 }
- 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;//9 o" ?7 n1 S9 a; V! O" H" c
- 44 GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AN;8 Q0 d! W% k: P/ s6 I- a; n- t' Q
- 45 GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_DOWN ;
9 n, y* i4 F4 D0 l+ s" W! G5 c - 46 GPIO_Init(GPIOA, &GPIO_InitStructure);
" u" F1 i4 f' \' p/ s2 a - 47 }3 T @8 z8 ^. u& t
/ H1 Z Q/ W! A% ]- N' ?) P
复制代码 ! Q b, {3 X" V: [' F- y
|