- 1 void GPIO_Configuration(void)
8 b% ], e6 C7 I. t' Q. i - 2 {
( ~$ j9 f/ G. f& r - 3 RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA, ENABLE);
; f: j% _' {! @9 x' ~; k8 W - 4 RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOB, ENABLE);
5 z1 ~; H7 G/ q) h* y - 5
5 p% f; i1 B G. e$ {9 Z - 6 /* Configure ADC Channel as analog input */* A3 K. |1 _- o3 c' u" |2 y
- 7 GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1 ;5 M; z$ }( x- Q6 _) T
- 8 GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AN;
4 E: J3 |7 m; C/ y5 U, } - 9 GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
2 q, v/ e( h, z6 J1 B2 a, t* N - 10 GPIO_Init(GPIOB, &GPIO_InitStructure);
- Z' L3 n' W. z - 11 & q) E0 \/ _; S2 Q& |' T8 T
- 12 /*GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9;
! S$ n5 q O; F# t Y$ H - 13 GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;* Y" ?: q4 L, x, k3 U8 D$ b
- 14 GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
; C- T# e" G' K/ V9 e' P - 15 GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;" l/ l6 p. p3 w ]
- 16 GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL ;
1 j2 P- C" ^/ ~+ Q; ^ - 17 GPIO_Init(GPIOA, &GPIO_InitStructure);
1 U8 Z7 h4 `: Q7 _/ m8 _ - 18 GPIO_PinAFConfig(GPIOA, GPIO_PinSource9, GPIO_AF_2);
% s4 `5 h# h4 p2 [/ D2 O - 19 , e- b, o% B5 b' @- y# D, @
- 20 GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0;// S0 X4 a1 k9 P: t" q' c* c
- 21 GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;9 Z; j7 } j- L
- 22 GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;8 |7 |' @& Y2 \7 W
- 23 GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
1 j& h" ]5 b, G1 D& B! z - 24 GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_DOWN ;6 g) ~) N+ D$ q: S3 i% }$ n
- 25 GPIO_Init(GPIOA, &GPIO_InitStructure); */ ! T1 h7 ~- v! }& `" }
- 26
+ [' H5 y, Q- o2 h1 G. } - 27 GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6|GPIO_Pin_1 ;//
' H' h3 n. N# D: l - 28 GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;* b& o/ h i( v$ B, i) I j( i! z# Z
- 29 GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;. B" t: M+ Z( w% t0 {; |5 u! y I
- 30 GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;) @5 O& X; Z/ k& y6 M4 `
- 31 GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_DOWN;3 T" B5 [2 k+ [% U6 [
- 32 GPIO_Init(GPIOA, &GPIO_InitStructure);
1 a0 d9 }8 |3 S8 W8 y. M - 33 , k# f% l0 K* C$ a, b- R# G8 G+ y
- 34 * A% `" z& q" M* \/ `: B
- 35
6 m- O8 k+ d" S0 A* x" x - 36 GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0;//5 O- y; |1 D( L( I. k% |! c. J
- 37 GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
. y3 A: {9 Z" c, l3 F+ [ - 38 GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP; //外部电路上拉,设置为上拉& g' q0 a; C$ B$ R' N
- 39 GPIO_Init(GPIOA, &GPIO_InitStructure);
% _* e% J& o" \ y - 40
7 v0 T; b6 ?: R; h$ q; \3 X! p4 H - 41 ! S( a# `( s/ X0 {' i
- 42 * s% D8 K; C% L% G) e# v
- 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;//+ u5 x5 b1 @( h! ]7 g$ n8 t, N" b
- 44 GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AN;* i. \, D, L% d8 L0 I/ ]
- 45 GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_DOWN ;& B. G- \& S# `7 R9 f" {6 H- i/ Y
- 46 GPIO_Init(GPIOA, &GPIO_InitStructure); 3 Z% |* e) Z% [6 i( _: u& [
- 47 }, d; ?" _* ?3 `0 d' f) u
- " N- Q, |/ q: |& J
复制代码 & K; `: R' m; ~5 ?8 S
|