Orange Pi - WiringPi - Python and Interrupts?


bozden
 Share

2 2

Recommended Posts

I build a device with several buttons, sensors etc. Implemented in python. I selected WiringOP for GPIO and installed it with some tweaking. 

 

First version is implemented in polling mode. Whenever I start interrupt driven code, I got stuck. No such support as far as I can see. 

 

How can I handle this?

Thanks

 

Link to post
Share on other sites

Armbian is a community driven open source project. Do you like to contribute your code?

No one? I can choose another library and/or use C for interrupt handling etc. What is the good and stable way of doing this?

Can somebody please point me to the right direction? There are many related posts around, but they are relatively old and I could not find a solid answer. 

 

Link to post
Share on other sites

18 hours ago, bozden said:

No one? I can choose another library and/or use C for interrupt handling etc. What is the good and stable way of doing this?

Can somebody please point me to the right direction? There are many related posts around, but they are relatively old and I could not find a solid answer. 

 

#include <wiringPi.h>
#include <stdio.h>

#define pin_22  6       // pin#22(PA2)
#define pin_26  11      // pin#26(PA21)
#define pin_28  31      // pin#28(PA18)

void int_falling(void){
  printf("%s\n",__func__);
}

void int_rising(void){
  printf("%s\n",__func__);
}

void int_both(void){
  printf("%s\n",__func__);
}

int main(void){

  printf("pi interrupt test start !!\n");
  if (wiringPiSetup() == -1){
    printf("wiringPiSetup init error\n");
    return(1);
  }
  pinMode(pin_22, INPUT);
  pinMode(pin_26, INPUT);
  pinMode(pin_28, INPUT);

  wiringPiISR(pin_22,INT_EDGE_FALLING, &int_falling );
  wiringPiISR(pin_26,INT_EDGE_RISING, &int_rising );
  wiringPiISR(pin_28,INT_EDGE_BOTH, &int_both );

  while(1){
  }
  return 0;
}

This code work Rpi & Opi.

 

$ uname -a
Linux orangepipc 3.4.113-sun8i #10 SMP PREEMPT Thu Feb 23 19:55:00 CET 2017 armv7l GNU/Linux

 

Link to post
Share on other sites

Guest
This topic is now closed to further replies.
 Share

2 2