OpenglMan Posted March 10, 2018 Share Posted March 10, 2018 Hello, I need to use an IRQ interruption with a button. I mean, I push a button, and then a code is executed. Some information: The PIN is PH19, EINT19. and the board A20 SOM. Armbian SO, kernel 4.13 Firstly i configure the digital pin and IRQ from user space: echo 243 > /sys/class/gpio/export echo "in" > /sys/class/gpio/gpio243/direction echo "falling" > /sys/class/gpio/gpio243/edge Now, when I push the button, I can monitoring the IRQ and the counter related to cat /proc/interrupts But now, how can I run a program when the interruption event happens ? I have seen this useful link http://linux-sunxi.org/External_interrupts How can i use it? I think there is very few information about this issue. I executed a bash script with while true , and polling the digital pin, but the disadvantage is that it consumes a lot of cpu. I hope you can help me. Thank you very much in advance Regards Link to comment Share on other sites More sharing options...
martinayotte Posted March 10, 2018 Share Posted March 10, 2018 It shoud not take a lot of cpu using poll() function with proper arguments. Take a look at this example : http://developer.ridgerun.com/wiki/index.php?title=Gpio-int-test.c http://developer.ridgerun.com/wiki/index.php/How_to_use_GPIO_signals Link to comment Share on other sites More sharing options...
OpenglMan Posted March 11, 2018 Author Share Posted March 11, 2018 Thank you martinayotte for your answer. However i have found an alternative solution in PHP language that works pretty well. It barely consumes CPU. The code is very simple. Anyway I will try the code in c language that you indicated in your previous post. I imagine that the internal functioning will be similar in both solutions. If anyone is interested, check the following link: https://github.com/PacktPublishing/GNU-Linux-Rapid-Embedded-Programming/blob/master/Chapter06/gpio-poll.php Regards Link to comment Share on other sites More sharing options...
dagix5 Posted March 14, 2018 Share Posted March 14, 2018 I used this one: https://github.com/larsks/gpio-watch Link to comment Share on other sites More sharing options...
Recommended Posts