Quantcast
Channel: Active questions tagged linux-kernel - Stack Overflow
Viewing all articles
Browse latest Browse all 12323

GPIO: Getting ISR on both edges though edge is set to ''rising"

$
0
0

Specific GPIO pin is connected to switch, upon pressing the switch the ISR needs to triggeredSo I have the userspace application to read the ISR, but i am getting the ISR on both the edges.

Receiving the interrupt when switch is pressed and also when released. How to configure to receive the ISR only on rising edge

    #include <stdio.h>      #include <stdlib.h>      #include <fcntl.h>      #include <unistd.h>      #include <poll.h> int main(int argc, char *argv[]){     int fd;     char value;     struct pollfd poll_gpio;     poll_gpio.events = POLLPRI;     // export GPIO     fd = open ("/sys/class/gpio/export", O_WRONLY);     write (fd, "44", 4);     close (fd);     // configure as input     fd = open ("/sys/class/gpio/gpio44/direction", O_WRONLY);     write (fd, "in", 3);     close (fd);     // configure interrupt     fd = open ("/sys/class/gpio/gpio44/edge", O_WRONLY);     write (fd, "rising", 7); // configure as rising edge     close (fd);     // open value file     fd = open("/sys/class/gpio/gpio44/value", O_RDONLY );     poll_gpio.fd = fd;     poll (&poll_gpio, 1, -1); // discard first IRQ     read (fd, &value, 1);     // wait for interrupt     while (1){         poll (&poll_gpio, 1, -1);         if ((poll_gpio.revents & POLLPRI) == POLLPRI){             lseek(fd, 0, SEEK_SET);             read (fd, &value, 1);             usleep  (50);             printf("Interrupt GPIO val: %c\n", value);         }}     close(fd); //close value file     return EXIT_SUCCESS; }

Viewing all articles
Browse latest Browse all 12323

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>