3

How do I attach/detach interrupts in C language. I am currently working with GPIO Pins of Raspberry Pi and want to convert statements which I used for arduino:

attachInterrupt();
detachInterrupt(Pin_no);

to C language commands. I read about one of them . atachInterrupt() may be written as wiringPiISR(1, INT_EDGE_RISING, &fun);

What about detachInterrupt?

Jivings
  • 22,538
  • 11
  • 90
  • 139
user8080
  • 31
  • 1
  • 2

1 Answers1

1

At the time of writing it doesn't seem possible. See https://github.com/WiringPi/WiringPi/blob/3fbc564d00b4e8fa5dc6772190575f7d1d12d12d/wiringPi/wiringPi.c

wiringPiISR() creates thread which runs never-ending thread which waits for interrupt launches your functions and waits again. If I read it correctly if launched wiringPiISR() again with the same pin, it would change it mode and functions, but not without some nasty racing conditions. Also it would create new thread doing exactly the same thing (which is to poll interrupt and launch currently associated function).

RooTer
  • 579
  • 4
  • 6