GPIO(ROM-5880)

From ESS-WIKI
Jump to: navigation, search

The RK3568 bank/bit notation for GPIOs must be formed as “GPIO<GPIO_ bank>_<gpio_bit>”.
The numeric value of GPIO is calculated as follows:
32 x (gpio_bank) + gpio_bit gpio_bit: A0~A7 0-7 B0~B7 8-15 C0~C7 16-23 D0~D7 24-31 E.g. GPIO2_D0 becomes 88

ROM-5880 GPIO

ROM-5880 GPIO.png

SOM-DB2510 GPIO Pin header:

SOM-DB2510 CN9.PNG

Export GPIO then you can use control GPIO from user space through sysfs.
Export GPIO

# echo 88 > /sys/class/gpio/export

Set GPIO direction to in/out

# echo "out" > /sys/class/gpio/gpio88/direction

Set GPIO value 0/1 if GPIO pin define is output

# echo 1 > /sys/class/gpio/gpio88/value

Used as IRQ signal

# echo "rising" > /sys/class/gpio/gpio88/edge

NOTE:
You have to configure GPIO to input.
rising: Trigger on rising edge
falling: Trigger on falling edge
both: Trigger on both edges
none: Disable interrupt on both edges

Unexport GPIO

# echo 88 > /sys/class/gpio/unexport

GPIO0 and GPIO1 are taken as an example: Connect GPIO0 and GPIO1

Export GPIO0 and GPIO1

# echo 88 > /sys/class/gpio/export
# echo 89 > /sys/class/gpio/export

Set GPIO0 to output and GPIO1 to input

# echo "out" > /sys/class/gpio/gpio88/direction
# echo "in" > /sys/class/gpio/gpio89/direction

Change GPIO0 to 1 and read GPIO1 value

# echo 1 > /sys/class/gpio/gpio88/value
# cat /sys/class/gpio/gpio89/value
1

Change GPIO0 to 0 and read GPIO2 value

# echo 0 > /sys/class/gpio/gpio88/value
# cat /sys/class/gpio/gpio89/value
0