Hai,
Here I configured the gpio pin 142 to a rising edge interrupt.
It was working but sometimes it was giving interruptions for falling edges also.
Here I am attaching the code and also attaching the output observed.
#include<stdio.h>
#include<unistd.h>
#include<string.h>
#include<stdlib.h>
#include<fcntl.h>
#include<poll.h>
int main(int args,char *argv[])
{
int fd;
char value;
struct pollfd poll_gpio;
poll_gpio.events = POLLPRI;
//gpio export
fd = open("/sys/class/gpio/export",O_WRONLY);
if(fd<0)
{
printf("fail to export the gpio\n");
//close(fd);
return -1;
}
write(fd,"142",3);
close(fd);
// set direction
fd = open("/sys/class/gpio/gpio142/direction",O_WRONLY);
if(fd<0)
{
printf("fail to open gpio142 direction\n");
//close(fd);
return -1;
}
write(fd,"in",2);
close(fd);
// gpio interrupt config
fd= open("/sys/class/gpio/gpio142/edge",O_WRONLY);
if(fd<0)
{
printf("fail to opne gpio142 edge\n");
return fd;
}
write(fd,"rising",6);
close(fd);
fd = open("/sys/class/gpio/gpio142/value",O_RDONLY);
if(fd<0)
{
printf("fail to open gpio142 value\n");
return -1;
}
poll_gpio.fd = fd;
poll(&poll_gpio,1,-1);
read(fd,&value,1);
while(1)
{
printf("enter into while\n");
poll(&poll_gpio,1,10*1000);
if((poll_gpio.revents & POLLPRI)==POLLPRI)
{
lseek(fd,0,SEEK_SET);
read(fd,&value,1);
printf("Interrupt value : %c\n",value);
}
}
}
![WhatsApp Image 2021-11-09 at 10.50.05|666x500](upload://yMxcv8w9mtWxiVUQRXpeLyEYfL0.jpeg)
**OUTPUT OBSERVED**
Interrupt value : 0
Interrupt value : 1
Interrupt value : 1
Interrupt value : 1
Interrupt value : 0
Interrupt value : 1
Interrupt value : 1
Interrupt value : 0
Interrupt value : 1
Interrupt value : 1
Interrupt value : 0
Interrupt value : 1
Interrupt value : 0
Interrupt value : 1
Interrupt value : 1
Interrupt value : 1
Interrupt value : 1
Interrupt value : 1
Interrupt value : 1
Interrupt value : 1
Interrupt value : 0
Can anyone help me to sortout this problem.
thanks.