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.
code:
- #include <wiringPi.h>
- #include <stdlib.h>
- #include <stdio.h>
- void signal_both(void){
- printf("Signal Both\n");
- }
- void signal_falling(void){
- printf("Signal Falling\n");
- }
- void signal_rising(void){
- printf("Signal Rising\n");
- }
- int main(int argc, char **argv){
- int mode=INT_EDGE_BOTH;
- int pin = 0;
- if(wiringPiSetup() == -1) {
- printf("wiringPiSetup Error\n");
- }
- if (argc == 2) {
- mode = atoi(argv[1]);
- }
- if (argc == 3) {
- mode = atoi(argv[1]);
- pin = atoi(argv[2]);
- }
- pinMode(pin,INPUT);
- printf("pin=%d\n",pin);
- if ( mode == INT_EDGE_BOTH) {
- printf("INT_EDGE_BOTH\n");
- wiringPiISR(pin, INT_EDGE_BOTH, signal_both );
- } else if ( mode == INT_EDGE_FALLING) {
- printf("INT_EDGE_FALLING\n");
- wiringPiISR(pin, INT_EDGE_FALLING, signal_falling );
- } else if ( mode == INT_EDGE_RISING) {
- printf("INT_EDGE_RISING\n");
- wiringPiISR(pin, INT_EDGE_RISING, signal_rising );
- }
- while(1) {
- sleep(10000);
- }
- return 0;
- }
This is test result.
code:
- orangepi@orangepipc:~/test$ sudo ./test2 1 15
- pin=15
- INT_EDGE_FALLING
- Signal Falling
- Signal Falling
- Signal Falling
- Signal Falling
- ^Corangepi@orangepipc:~/test$ sudo ./test2 2 15
- pin=15
- INT_EDGE_RISING
- Signal Rising
- Signal Rising
- Signal Rising
- Signal Rising
- Signal Rising
- ^Corangepi@orangepipc:~/test$ sudo ./test2 3 15
- pin=15
- INT_EDGE_BOTH
- Signal Both
- Signal Both
- Signal Both
- Signal Both
- Signal Both
- Signal Both
- Signal Both
- Signal Both
- ^Corangepi@orangepipc:~/test$