文章目录
- 1 查看当前系统gpio配置信息
- 2 orin / nano gpio
- 2.1 GPIO 映射表
- 2.2 nano 平台对外提供的2排端口表
- 3 配置GPIO 电平
- 3.1 通过指令配置普通GPIO高电平
- 3.2 通过设备树配置普通GPIO高电平
- 3.3 配置特定 gpio 高电平
1 查看当前系统gpio配置信息
sudo cat /sys/kernel/debug/gpio
2 orin / nano gpio
2.1 GPIO 映射表
orin 平台提供了一个 xls 表,可通过它生成dtb 设备树,同样可以看到管脚的定义:
Jetson_Orin_NX_and_Orin_Nano_series_Pinmux_Config_Template.xlsm
2.2 nano 平台对外提供的2排端口表
https://jetsonhacks.com/nvidia-jetson-orin-nano-gpio-header-pinout/
3 配置GPIO 电平
3.1 通过指令配置普通GPIO高电平
配置gpio 9为高电平
nano@orin-nano:/sys/class/gpio$ sudo -s
[sudo] password for nano:
root@orin-nano:/sys/class/gpio# echo 492 > /sys/class/gpio/export
root@orin-nano:/sys/class/gpio# ls
export gpiochip316 gpiochip348 PAC.06 unexport
root@orin-nano:/sys/class/gpio/PAC.06# echo out > direction
root@orin-nano:/sys/class/gpio/PAC.06# echo 1 > value
root@orin-nano:/sys/class/gpio/PAC.06#
cat /sys/kernel/debug/gpio
3.2 通过设备树配置普通GPIO高电平
3.3 配置特定 gpio 高电平
AON 特定管脚,使用的宏, GPIO6 代表的就是 CC , 3
/** Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.** This program is free software; you can redistribute it and/or modify* it under the terms of the GNU General Public License as published by* the Free Software Foundation; either version 2 of the License, or* (at your option) any later version.** This program is distributed in the hope that it will be useful, but WITHOUT* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for* more details.** You should have received a copy of the GNU General Public License* along with this program. If not, see <http://www.gnu.org/licenses/>.*/#include "tegra234-camera-rbpcv3-imx477.dtsi"#define CAM0_PWDN TEGRA234_MAIN_GPIO(H, 6)
#define CAM1_PWDN TEGRA234_MAIN_GPIO(AC, 0)
#define CAM_I2C_MUX TEGRA234_AON_GPIO(CC, 3)/ {cam_i2cmux {compatible = "i2c-mux-gpio";#address-cells = <1>;#size-cells = <0>;mux-gpios = <&tegra_aon_gpio CAM_I2C_MUX GPIO_ACTIVE_HIGH>;i2c-parent = <&cam_i2c>;i2c@0 {reg = <0>;#address-cells = <1>;#size-cells = <0>;rbpcv3_imx477_a@1a {status = "disabled";reset-gpios = <&tegra_main_gpio CAM0_PWDN GPIO_ACTIVE_HIGH>;};};i2c@1 {reg = <1>;#address-cells = <1>;#size-cells = <0>;rbpcv3_imx477_c@1a {status = "disabled";reset-gpios = <&tegra_main_gpio CAM1_PWDN GPIO_ACTIVE_HIGH>;};};};gpio@6000d000 {camera-control-output-low {gpio-hog;output-low;gpios = < CAM1_PWDN 0 CAM0_PWDN 0>;label = "cam1-pwdn", "cam0-pwdn";};};
};