Why Jetson nano takes ~2sec to toggle the gpio with IOCTL interface?

Hi,
I am try setting gpio on Jetson nano with below interfaces and find out that , legacy interface is faster to toggle the gpio then new interface.
I use c program to toggle the gpio with legacy interface for example:
int uart_pin = 15;
for(int i = 0; i < 4; i++)
{
gpio_write(uart_pin, 1);
gpio_write(uart_pin, 0);
}
I found that it takes few microsecs to toggle the gpio, but when I update the interfaces to new IOCTL interface for example
rq.lineoffsets[0] = offset;
rq.flags = GPIOHANDLE_REQUEST_OUTPUT;
rq.lines = 1;
ret = ioctl(fd, GPIO_GET_LINEHANDLE_IOCTL, &rq);
close(fd);
if (ret == -1)
{
printf(“Unable to line handle from ioctl : %s”, strerror(errno));
return;
}
data.values[0] = value;
ret = ioctl(rq.fd, GPIOHANDLE_SET_LINE_VALUES_IOCTL, &data);

it takes ~2secs to toggle the GPIO. could you please let us know how can we use the new interface to quickly toggle the GPIO or nano has any limitation ?

hello mithlesh.singh2,

may I know which GPIO pin you’re using, are you able to control the pin manually via sysnode to check the performance.
for example,
please enter the location of the GPIOs, $ cd /sys/class/gpio
taking gpio220 as an example, you should generate gpio220 name with… $ echo 220 > export
after that, you should able to enable the GPIO and toggle the pin, $ echo out > direction && echo 1 > value

Hi JerryChang,

may I know which GPIO pin you’re using

I am using gpio 18 on the nano .
are you able to control the pin manually via sysnode to check the performance.

I used logic analyazer to check the performance and used gpio_export and gpio_set_dir () by which Gpio performance are fine.
the only issue is when we use IOCTL call to control the GPIOs.

hello mithlesh.singh2,

then, please review your driver implementation, thanks

Hi JeeryChang
is that okay to use IOCTL call to control the GPIO on jetson nano?
or you recommend to use Export APIs to use?

please see-also Topic 144550, for several ways to access GPIOs. such as, kernel APIs, python scripts, C++ samples.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.