How to use GPIO RK3576
From ESS-WIKI
Configuration
The RK3576 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<br/>
gpio_bit : A0~A7 0-7 B0~B7 8-15 C0~C7 16-23 D0~D7 24-31
E.g. GPIO3_A0 becomes 96
AOM-3841
| GPIO Number | GPIO formed | Numeric Representation |
| GPIO3 | GPIO0_B0 | 8 |
| GPIO4 | GPIO4_C5 | 149 |
Test
Here we take GPIO3 of AOM-3841 as an example.
Export GPIO then you can use control GPIO from userr space through sysfs
Export GPIO3
# echo 8 > /sys/class/gpio/export
Set GPIO direction to in/out
# echo "out" > /sys/class/gpio/gpio8/direction
Set GPIO value 0/1 if GPIO pin define is output
# echo 1 > /sys/class/gpio/gpio8/value
Used as IRQ signal
Note:You have to configure GPIO to input
# echo "rising" > /sys/class/gpio/gpio8/edge
- rising: Trigger on rising edge
- falling: Trigger on falling edge
- both: Trigger on both edges
- none: Disable interrupt on both edges
Unexport GPIO3
# echo 8 > /sys/class/gpio/unexport
Test
GPIO3 and GPIO4 of AOM-3841 are taken as an example:
- Connect GPIO3 and GPIO4
- Export GPIO3 and GPIO4
# echo 8 > /sys/class/gpio/export # echo 149 > /sys/class/gpio/export
- Set GPIO3 to output
# echo "out" > /sys/class/gpio/gpio8/direction
- Set GPIO4 to input
# echo "in" > /sys/class/gpio/gpio149/direction
- Change GPIO3 to 1 and read GPIO4 value
# echo 1 > /sys/class/gpio/gpio8/value # cat /sys/class/gpio/gpio149/value 1
- Change GPIO3 to 0 and read GPIO4 value
# echo 0 > /sys/class/gpio/gpio8/value # cat /sys/class/gpio/gpio149/value 0