View: 12916|Reply: 6

how wiringOp interrupt works??

[Copy link]

1

threads

3

posts

19

credits

Novice

Rank: 1

credits
19
Published in 2016-9-20 18:07:29 | Show all floors |Read mode
I install Jessie server / armbian on orange pi one and install wiring op on it from this link https://github.com/zhaolei/WiringOP
and for test interrupt I use this example form https://github.com/n.../examples/isr.c
as he said in comment for test write
  1. gpio mode 0 up
  2. gpio mode 0 down
Copy code
in other terminal , I did this and it just print waiting...
my question is , Is wiringPiISR  working on orange pi one?
If the answer is yes, what should happen in this example?
Is it need any thing to connect to the pin Externally?
or can give me an other example for interrupt?


10

threads

218

posts

2040

credits

Gold member

Rank: 6Rank: 6

credits
2040
Published in 2016-9-20 19:10:09 | Show all floors
wiringPiISR  isn't working on orange pi.

There are no functions of the interrupt in GPIO of OPI.

1

threads

3

posts

19

credits

Novice

Rank: 1

credits
19
 Author| Published in 2016-9-21 13:05:53 | Show all floors
So, what should I do?

10

threads

218

posts

2040

credits

Gold member

Rank: 6Rank: 6

credits
2040
Published in 2016-9-21 19:30:03 | Show all floors
Edited by nopnop2002 at 2016-9-21 19:40
isan replied at 2016-9-21 13:05
So, what should I do?

waitForInterrupt doesn't also work in OPI.
Please use RPI

1

threads

3

posts

19

credits

Novice

Rank: 1

credits
19
 Author| Published in 2016-9-27 16:50:14 | Show all floors
Edited by isan at 2016-9-27 16:54

I get wiring op from this link
https://github.com/WereCatf/WiringOP
and install it and interrupt works.

10

threads

218

posts

2040

credits

Gold member

Rank: 6Rank: 6

credits
2040
Published in 2016-9-28 21:53:35 | Show all floors
isan replied at 2016-9-27 16:50
I get wiring op from this link
https://github.com/WereCatf/WiringOP
and install it and interrupt w ...

I tried this code.

  1. #include <wiringPi.h>
  2. #include <stdlib.h>
  3. #include <stdio.h>

  4. #define pin     0

  5. void signal(void){
  6.   printf("Signal\n");
  7. }


  8. int main(void){
  9.   if(wiringPiSetup() == -1) {
  10.     printf("wiringPiSetup Error\n");
  11.   }
  12.   pinMode(pin,INPUT);
  13.   wiringPiISR(pin, INT_EDGE_FALLING, signal );
  14. //  wiringPiISR(pin, INT_EDGE_RISING, signal );
  15.   while(1) {
  16.     sleep(10000);
  17.   }
  18.   return 0;
  19. }

Copy code


But An error occurred.

sudo ./test1
[wiringPiISR2677] the pin:0 is invalid, please check it over!


Please show me your sample source code

10

threads

218

posts

2040

credits

Gold member

Rank: 6Rank: 6

credits
2040
Published in 2016-9-29 22:17:18 | Show all floors
Edited by nopnop2002 at 2016-10-9 17:51

I sent Pull Request.

https://github.com/zhaolei/WiringOP/pull/5

You can copy modified source from here.
You can use wiringPiISR with all GPIO(GPIO0-GPIO26).
You need to load gpio_sunxi.
waitForInterrupt function don't work.

Because a device file is being read periodically.

I tested armbian.
This is test code.
  1. #include <wiringPi.h>
  2. #include <stdlib.h>
  3. #include <stdio.h>

  4. void signal_both(void){
  5.   printf("Signal Both\n");
  6. }

  7. void signal_falling(void){
  8.   printf("Signal Falling\n");
  9. }

  10. void signal_rising(void){
  11.   printf("Signal Rising\n");
  12. }

  13. int main(int argc, char **argv){
  14.   int mode=INT_EDGE_BOTH;
  15.   int pin = 0;

  16.   if(wiringPiSetup() == -1) {
  17.     printf("wiringPiSetup Error\n");
  18.   }
  19.   if (argc == 2) {
  20.     mode = atoi(argv[1]);
  21.   }
  22.   if (argc == 3) {
  23.     mode = atoi(argv[1]);
  24.     pin = atoi(argv[2]);
  25.   }
  26.   pinMode(pin,INPUT);
  27.   printf("pin=%d\n",pin);
  28.   if ( mode == INT_EDGE_BOTH) {
  29.     printf("INT_EDGE_BOTH\n");
  30.     wiringPiISR(pin, INT_EDGE_BOTH, signal_both );
  31.   } else if ( mode == INT_EDGE_FALLING) {
  32.     printf("INT_EDGE_FALLING\n");
  33.     wiringPiISR(pin, INT_EDGE_FALLING, signal_falling );
  34.   } else if ( mode == INT_EDGE_RISING) {
  35.     printf("INT_EDGE_RISING\n");
  36.     wiringPiISR(pin, INT_EDGE_RISING, signal_rising );
  37.   }

  38.   while(1) {
  39.     sleep(10000);
  40.   }
  41.   return 0;
  42. }
Copy code



This is test result.
  1. orangepi@orangepipc:~/test$ sudo ./test2 1 15
  2. pin=15
  3. INT_EDGE_FALLING
  4. Signal Falling
  5. Signal Falling
  6. Signal Falling
  7. Signal Falling
  8. ^Corangepi@orangepipc:~/test$ sudo ./test2 2 15
  9. pin=15
  10. INT_EDGE_RISING
  11. Signal Rising
  12. Signal Rising
  13. Signal Rising
  14. Signal Rising
  15. Signal Rising
  16. ^Corangepi@orangepipc:~/test$ sudo ./test2 3 15
  17. pin=15
  18. INT_EDGE_BOTH
  19. Signal Both
  20. Signal Both
  21. Signal Both
  22. Signal Both
  23. Signal Both
  24. Signal Both
  25. Signal Both
  26. Signal Both
  27. ^Corangepi@orangepipc:~/test$
Copy code




You need to log in before you can reply login | Register

Points Rule

Quick reply Top Return list