daeun

mid

Showing 1 changed file with 24 additions and 24 deletions
...@@ -11,30 +11,6 @@ int time = 0; ...@@ -11,30 +11,6 @@ int time = 0;
11 int data[] = { 0,0,0,0,0,0 }; 11 int data[] = { 0,0,0,0,0,0 };
12 int state = 2; 12 int state = 2;
13 13
14 -void init(){
15 - int i;
16 - if( wiringPiSetupGpio() == -1 ){
17 - printf( "wiringPiSetupGpio() error\n" );
18 - exit(-1);
19 - }
20 - for(i=0;i<6;i++){
21 - pinMode( FndSelectPin[i], OUTPUT );
22 - digitalWrite( FndSelectPin[i], HIGH );
23 - }
24 - for(i=0;i<8;i++){
25 - pinMode( FndPin[i], OUTPUT );
26 - digitalWrite( FndPin[i], LOW );
27 - }
28 - for (i = 0; i < 3; i++)
29 - pinMode(Keypad[i], INPUT);
30 -
31 - if (wiringPiISR(Keypad[1], INT_EDGE_FALLING, &stop) < 0) {
32 - return 1;
33 - }
34 - if (wiringPiISR(Keypad[2], INT_EDGE_FALLING, &reset) < 0) {
35 - return 1;
36 - }
37 -}
38 int KeypadRead() 14 int KeypadRead()
39 { 15 {
40 int i, keypadnum = -1; 16 int i, keypadnum = -1;
...@@ -87,6 +63,30 @@ void reset() { ...@@ -87,6 +63,30 @@ void reset() {
87 time = 0; 63 time = 0;
88 state = 2; 64 state = 2;
89 } 65 }
66 +void init() {
67 + int i;
68 + if (wiringPiSetupGpio() == -1) {
69 + printf("wiringPiSetupGpio() error\n");
70 + exit(-1);
71 + }
72 + for (i = 0; i < 6; i++) {
73 + pinMode(FndSelectPin[i], OUTPUT);
74 + digitalWrite(FndSelectPin[i], HIGH);
75 + }
76 + for (i = 0; i < 8; i++) {
77 + pinMode(FndPin[i], OUTPUT);
78 + digitalWrite(FndPin[i], LOW);
79 + }
80 + for (i = 0; i < 3; i++)
81 + pinMode(Keypad[i], INPUT);
82 +
83 + if (wiringPiISR(Keypad[1], INT_EDGE_FALLING, &stop) < 0) {
84 + return 1;
85 + }
86 + if (wiringPiISR(Keypad[2], INT_EDGE_FALLING, &reset) < 0) {
87 + return 1;
88 + }
89 +}
90 int main(){ 90 int main(){
91 init(); 91 init();
92 if (KeypadRead() == 0) { 92 if (KeypadRead() == 0) {
......