Hi,
I'm trying to get GPIO Interrrupt functionality working using sysfs and poll calls. The problem appears to be that the poll call is always returnng immediately and is not triggering on the actualy rising edge. I have configured the kernel for this GPIO to be an input which does work correctly. I've also configured the GPIO (114) correctly for an interrupt input set for rising edge. This can be seen here:
root@dm814x-evm:/sys/class# mount -t debugfs debugfs /sys/kernel/debug
root@dm814x-evm:/sys/class# cat /sys/kernel/debug/gpio
GPIOs 0-31, gpio:
gpio-31 (ts_irq ) in hi irq-191 edge-falling
GPIOs 32-63, gpio:
GPIOs 64-95, gpio:
GPIOs 96-127, gpio:
gpio-114 (sysfs ) in lo irq-247 edge-rising
GPIOs 128-143, i2c/1-0021, pcf8575, can sleep:
gpio-128 (lcd_power ) out lo
When I call my "Wait/Poll" routine below from a thead , it does not Bock waiting on the interrupt...instead it ruturns immediately and indicates that an interrupt was encountered but there is none because the line is tied low.... Any suggestions on what might be wrong below or with this wait / poll process ??????? Also can a GPIO interrupt be configured as a level triggered interrupt ???? If so , how .....
int CGPIOControlPort::GpioPoll(unsigned int gpio)
{
struct pollfd fdset[1];
int timeout, nfds, rc;
int fd, len;
char buf[60];
len = snprintf(buf, sizeof(buf), "/sys/class/gpio/gpio%d/value", gpio);
fd = open(buf, O_RDONLY | O_NONBLOCK);
if (fd < 0)
{
perror("gpio/poll");
return fd;
}
timeout = -1;
nfds = 1;
fdset[0].fd = fd;
fdset[0].events = POLLPRI;
fdset[0].revents = 0;
rc = poll(fdset, nfds, timeout); // I believe this should be blocking until an actual rising edge is seen but it is not
if (rc < 0)
{
m_DebugLog.LogDebug(AT, 0, "CGPIOControlPort::GpioPoll Protect FAILED" );
xfc_printf("CGPIOControlPort::GpioPoll FAILED\n");
return -1;
}
if (fdset[0].revents & POLLPRI)
{
m_DebugLog.LogDebug(AT, 0, "CGPIOControlPort::GpioPoll Interrupt" ); // This is being displayed immediately everytime routine is called
len = read(fdset[0].fd, buf, sizeof(buf));
xfc_printf("\npoll() GPIO %d interrupt occurred = %d \n", gpio, rc);
}
close(fd);
return 0;
}