Hi Jari and Alan,

I have a proof of concept of how a "more generic" way of using GPIOs could work, actually running on my port of .NET nanoFramework for NuttX. The idea is to have an entry per GPIO bank at `/dev/gpio{bank}`, so all the pins of the bank would be managed by this entry.

NuttX side:
https://github.com/dotnuttx/incubator-nuttx/blob/ef87a8c70363d6cc3bc4247de0dc153a6f9b6d27/include/nuttx/ioexpander/gpio.h#L134

https://github.com/dotnuttx/incubator-nuttx/blob/ef87a8c70363d6cc3bc4247de0dc153a6f9b6d27/drivers/ioexpander/gpio.c#L333

https://github.com/dotnuttx/incubator-nuttx/blob/ef87a8c70363d6cc3bc4247de0dc153a6f9b6d27/boards/arm/rp2040/raspberrypi-pico/src/rp2040_gpio.c#L189

Application side:
https://github.com/dotnuttx/nf-Community-Targets/blob/linux/posix/target/PAL/CPU_Gpio_Nuttx.cpp

https://github.com/dotnuttx/incubator-nuttx-apps/blob/dotnet/examples/gpio/gpio_main.c

Remembering that this is an idea, proof of concept, still work in progress.

BR,
Matheus Castello

Em 10/27/2021 4:11 PM, Alan Carvalho de Assis escreveu:
Hi Jari,

I agree! Also in the Linux its name is just gpioN inside /sys.

But this modification will involve many boards modifications and also
the error message will need to give more details explaining that the
user cannot use that pin as input because it is configured to output
and vice-versa. Also an input without interruption support needs to be
handled correctly case someone try to wait for a signal event on the
gpio.

BR,

Alan

On 10/27/21, Jari van Ewijk <jari.vanew...@nxp.com> wrote:
Hi all,

I am currently working with the ioexpander/gpio driver to control GPIO pins
from an application. I am wondering if anybody is using this interface for
more practical applications than toggling a pin from the command line (i.e.
apps/examples/gpio).
I would say the interface is simple but effective. It can read and set pin
values and pintypes can be changed. That's all I need.

However, I am wondering about the naming of the devices. Pins are registered
as /dev/gpinN, /dev/gpoutN, or /dev/gpintN (where N is a integer number, of
course) depending on their pintype.
Now, there is a SETPINTYPE command, which you can use to change pintypes. So
that means an output pin initially registered as /dev/gpout0 could be
changed to be an input pin, with it keeping the same name.

Wouldn't it make more sense to register ALL pins as generic /dev/gpioN
instead of the specific /dev/gpinN, /dev/gpoutN, /dev/gpintN? Maybe there's
a good reason to keep these distinct names, but it is also really confusing
when pin types start to change.

Best regards,
Jari van Ewijk

Reply via email to