Khadas Docs

Amazing Khadas, always amazes you!

User Tools

Site Tools


Sidebar

products:sbc:common:applications:gpio:get-gpio-number

Get GPIO number

Calculation:

GPIO PIN number calculation method: Number = Range Base + Pin Index

  • Range Base refers to the base value of GPIO ranges
  • Pin Index refers to the sorting of the GPIO pins you need to calculate in the corresponding ranges

Example:

1. Get Range Base:

# cat /sys/kernel/debug/pinctrl/fe000000.apb4\:pinctrl\@4000-pinctrl-meson/gpio-ranges
GPIO ranges handled:
0: periphs-banks GPIOS [430 - 511] PINS [0 - 81]

2. Get Pin Index:

# cat /sys/kernel/debug/pinctrl/fe000000.apb4\:pinctrl\@4000-pinctrl-meson/pins
registered pins: 82
pin 22 (GPIOE_0)  fe000000.apb4:pinctrl@4000
pin 23 (GPIOE_1)  fe000000.apb4:pinctrl@4000
pin 0 (GPIOB_0)  fe000000.apb4:pinctrl@4000
pin 1 (GPIOB_1)  fe000000.apb4:pinctrl@4000
pin 2 (GPIOB_2)  fe000000.apb4:pinctrl@4000
pin 3 (GPIOB_3)  fe000000.apb4:pinctrl@4000
pin 4 (GPIOB_4)  fe000000.apb4:pinctrl@4000
...
pin 76 (GPIOZ_8)  fe000000.apb4:pinctrl@4000
pin 77 (GPIOZ_9)  fe000000.apb4:pinctrl@4000
pin 78 (GPIOZ_10)  fe000000.apb4:pinctrl@4000
...

3. Calculate Number:

Here is an example for GPIOZ_10:

GPIOZ_10 = Range Base + Pin Index = 430 + 78 = 508

Last modified: 2024/08/06 06:05 by nick