I have the following code to monitor GPIO pulses on i.MX8, using GPIO v2 ioctls of kernel 6.x:
(partially borrowed from [linux tree]/tools/gpio/gpio-utils)
#define PULSE_PIN 1
struct gpio_v2_line_config config;
memset(&config, 0, sizeof(config));
unsigned pins[]={PULSE_PIN};
config.flags |= GPIO_V2_LINE_FLAG_INPUT;
config.flags |= GPIO_V2_LINE_FLAG_EDGE_RISING;
//config.flags |= GPIO_V2_LINE_FLAG_EDGE_FALLING;
config.flags |= GPIO_V2_LINE_FLAG_EVENT_CLOCK_REALTIME;
ret = gpiotools_request_line("gpiochip0", pins, 1, &config, "IN_PULSE");
for (;;)
{
int rc;
uint64_t ts;
rc = gpiotools_read_line_event(fd, (void*)&ts);
if (rc > 0) {
printf(" %d\n", rc);
}
}
When I use only GPIO_V2_LINE_FLAG_EDGE_RISING or GPIO_V2_LINE_FLAG_EDGE_FALLING, these events are properly detected. But if I use both, only falling is detected. Why? The i.MX8 itself can be configured to interrupt on both edges.
Same behavior using gpiomon -r -f .
Hello,
I just wanted to verify if that behavior could be caused by the logic operation since there is a definition for both rising and falling events.
Best regards
@JorgeCas Thank you for your response - but I did what you advise, only in slightly different way.
Hello, I hope you are doing well.
Could you please try with:
config.flags |= (GPIO_V2_LINE_FLAG_EDGE_RISING | (GPIO_V2_LINE_FLAG_EDGE_FALLING);
Best regards.