赞
踩
目录
无
在 RK3588 中,有只支持 1.8V,和支持 1.8V/3.3V 两种电压可配置,共两种类型的 GPIO。
Core-3588J 有 5 组 GPIO bank:GPIO0~GPIO4,每组又以 A0~A7, B0~B7, C0~C7, D0~D7 作为编号区分,常用以下公式计算引脚:
GPIO pin脚计算公式:pin = bank * 32 + number
GPIO 小组编号计算公式:number = group * 8 + X
下面演示GPIO1_D0 pin脚计算方法:
bank = 1; //GPIO1_D0 => 1, bank ∈ [0,4]
group = 3; //GPIO1_D0 => 3, group ∈ {(A=0), (B=1), (C=2), (D=3)}
X = 0; //GPIO1_D0 => 0, X ∈ [0,7]
number = group * 8 + X = 3 * 8 + 0 = 24
pin = bank*32 + number= 1 * 32 + 24 = 56;
:/ # ls /sys/class/gpio/ export gpiochip128 gpiochip32 gpiochip64 unexport gpiochip0 gpiochip200 gpiochip509 gpiochip96 :/ # echo 56 > /sys/class/gpio/export :/ # ls /sys/class/gpio/ export gpiochip0 gpiochip200 gpiochip509 gpiochip96 gpio56 gpiochip128 gpiochip32 gpiochip64 unexport :/ # ls /sys/class/gpio/gpio56 active_low device direction edge power subsystem uevent value :/ # cat /sys/class/gpio/gpio56/direction in :/ # cat /sys/class/gpio/gpio56/value 0
1、申请 GPIO
echo 13 > /sys/class/gpio/export
2、配置引脚方向
查看默认引脚方向:
cat /sys/class/gpio/gpio13/direction
配置成输出方向:
echo out > /sys/class/gpio/gpio13/direction
3、配置引脚输出电平
从前面的原理图可知,输出高电平为点亮 LED:
echo 1 > /sys/class/gpio/gpio13/value
熄灭 LED:
echo 0 > /sys/class/gpio/gpio13/value
参考:
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。