Jump to content

GPIO pin numbering, old vs new


richardk

Recommended Posts

So using the old sysfs (/sys/class/gpio/) interface, you "export" a gpio by spitting the gpio number into /sys/class/gpio/export.  The GPIO number depends on the board and relevant documentation.

 

Having once found that I need GPIO number 76, I'm migrating code to the new "gpio character device" interface (/dev/gpiochipn) on my Rock64.  However, "gpioinfo" shows that hardly any gpios have useful labels, and Google searches always turn up Raspberry Pi results.

 

So, can I just calculate the new gpio identify?  Old gpio is 76, all /dev/gpiochips have 32 lines, 76/32 = 2 rem 12, so old gpio 76 is now /dev/gpiochip2 line 12?

 

Edit: I tried this, and it was correct.  Is this anywhere documented to be correct in all/most/many/some cases?

 

Edited by richardk
Tried it.
Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

Terms of Use - Privacy Policy - Guidelines