wiringPI - wiringPiISR - not working on BPI-M2 but yes un RPI-2


(Martin) #1

Hi, I’m having problems with wiringPiISR. I need a C program to trigger an interruption when is pushed.

I’ve tried to run isr.c under wiringPi examples and it is automatically triggered (I mean, like pushed button) or having other problems like permission denied to configure some ports. Also changed the code to include pull-up resistence with no luck, still having detections. I’m working with bananian 15.08. Had any of you had success with wiringPiISR funtion?

My code is working perfectly under RaspberryPi 2, so its not a coding issue, but I want to migrate it to BPI-M2.

Here is the code.

#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <stdlib.h>
#include <wiringPi.h>


// globalCounter:
//      Global variable to count interrupts
//      Should be declared volatile to make sure the compiler doesn't cache it.

static volatile int globalCounter [8] ;


/*
 * myInterrupt:
 *********************************************************************************
 */

//void myInterrupt0 (void) { ++globalCounter [0] ; }
void myInterrupt1 (void) { ++globalCounter [1] ; }
//void myInterrupt2 (void) { ++globalCounter [2] ; }
//void myInterrupt3 (void) { ++globalCounter [3] ; }
//void myInterrupt4 (void) { ++globalCounter [4] ; }
//void myInterrupt5 (void) { ++globalCounter [5] ; }
//void myInterrupt6 (void) { ++globalCounter [6] ; }
//void myInterrupt7 (void) { ++globalCounter [7] ; }


/*
 *********************************************************************************
 * main
 *********************************************************************************
 */

int main (void)
{
  int gotOne, pin ;
  int myCounter [8] ;

  for (pin = 0 ; pin < 8 ; ++pin)
    globalCounter [pin] = myCounter [pin] = 0 ;

  wiringPiSetup () ;
  pinMode (0, INPUT) ;
  pullUpDnControl (0, PUD_UP) ;
//  wiringPiISR (0, INT_EDGE_FALLING, &myInterrupt0) ;
  wiringPiISR (0, INT_EDGE_BOTH, &myInterrupt1) ;
//  wiringPiISR (2, INT_EDGE_FALLING, &myInterrupt2) ;
//  wiringPiISR (3, INT_EDGE_FALLING, &myInterrupt3) ;
//  wiringPiISR (4, INT_EDGE_FALLING, &myInterrupt4) ;
//  wiringPiISR (5, INT_EDGE_FALLING, &myInterrupt5) ;
//  wiringPiISR (6, INT_EDGE_FALLING, &myInterrupt6) ;
//  wiringPiISR (7, INT_EDGE_FALLING, &myInterrupt7) ;

  for (;;)
  {
    gotOne = 0 ;
    printf ("Waiting ... ") ; fflush (stdout) ;

    for (;;)
    {
      for (pin = 0 ; pin < 8 ; ++pin)
      {
        if (globalCounter [pin] != myCounter [pin])
        {
          printf (" Int on pin %d: Counter: %5d\n", pin, globalCounter [pin]) ;
          myCounter [pin] = globalCounter [pin] ;
          ++gotOne ;
        }
      }
      if (gotOne != 0)
        break ;
    }
  }

  return 0 ;
}

`

(Manish) #2

Coincidentally, I came here to look for solution to a similar problem. What is the exact error message?

I am getting something like

wiringPiISR: unable to open /sys/class/gpio/gpio233/value: No such file or directory