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?

1 Answer 1

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).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.