Jetson-TX2中GPIO端口号的计算及端口的控制

Jetson-TX2中引脚总共有两个group,分别是main和aon参见tegra186-gpio.h,分别是320和256,具体的计算公式如下:

group+ (port * 8 + pin)

tegra186-gpio.h文件:

/* GPIOs implemented by main GPIO controller */
#define TEGRA_MAIN_GPIO_PORT_A 0
#define TEGRA_MAIN_GPIO_PORT_B 1
#define TEGRA_MAIN_GPIO_PORT_C 2
#define TEGRA_MAIN_GPIO_PORT_D 3
#define TEGRA_MAIN_GPIO_PORT_E 4
#define TEGRA_MAIN_GPIO_PORT_F 5
#define TEGRA_MAIN_GPIO_PORT_G 6
#define TEGRA_MAIN_GPIO_PORT_H 7
#define TEGRA_MAIN_GPIO_PORT_I 8
#define TEGRA_MAIN_GPIO_PORT_J 9
#define TEGRA_MAIN_GPIO_PORT_K 10
#define TEGRA_MAIN_GPIO_PORT_L 11
#define TEGRA_MAIN_GPIO_PORT_M 12
#define TEGRA_MAIN_GPIO_PORT_N 13
#define TEGRA_MAIN_GPIO_PORT_O 14
#define TEGRA_MAIN_GPIO_PORT_P 15
#define TEGRA_MAIN_GPIO_PORT_Q 16
#define TEGRA_MAIN_GPIO_PORT_R 17
#define TEGRA_MAIN_GPIO_PORT_T 18
#define TEGRA_MAIN_GPIO_PORT_X 19
#define TEGRA_MAIN_GPIO_PORT_Y 20
#define TEGRA_MAIN_GPIO_PORT_BB 21
#define TEGRA_MAIN_GPIO_PORT_CC 22
#define TEGRA_MAIN_GPIO_PORT_DD 23
#define TEGRA_MAIN_GPIO(port, offset) \
((TEGRA_MAIN_GPIO_PORT_##port * 8) + offset)

/* GPIOs implemented by AON GPIO controller */
#define TEGRA_AON_GPIO_PORT_S 0
#define TEGRA_AON_GPIO_PORT_U 1
#define TEGRA_AON_GPIO_PORT_V 2
#define TEGRA_AON_GPIO_PORT_W 3
#define TEGRA_AON_GPIO_PORT_Z 4
#define TEGRA_AON_GPIO_PORT_AA 5
#define TEGRA_AON_GPIO_PORT_EE 6
#define TEGRA_AON_GPIO_PORT_FF 7

#define TEGRA_AON_GPIO(port, offset) \
((TEGRA_AON_GPIO_PORT_##port * 8) + offset)

1.GPIO8/ALS_PROX_INT在Jetson-TX2-Generic-Customer-Pinmux-Template文件GPIO一栏中查找对应值为GPIO3_PI.04(如下图),根据tegra186-gpio.h中对应的PI为PORT_I的缩写即在main组即#define TEGRA_MAIN_GPIO_PORT_I 8,所以group是320,port为8pin为4

group+ (port * 8 + pin)=320+(8*8+4)=388

 

2.GPIO10/WIFI_WAKE_AP在Jetson-TX2-Generic-Customer-Pinmux-Template文件GPIO一栏中查找对应值为GPIO3_PC.00(如下图),根据tegra186-gpio.h中对应的PC为PORT_C的缩写即在main组即#define TEGRA_MAIN_GPIO_PORT_C 2所以group是320,port为2pin为0

group+ (port * 8 + pin)=320+(2*8+0)=336

控制GPIO口的语句为:(在root权限下,正极接3.3V负极接端口)

echo 388 > /sys/class/gpio/export   //端口号

echo out > /sys/class/gpio/gpio388/direction    //方向

echo 1 > /sys/class/gpio/gpio388/value      //电平值

以上为GPIO口输出为高电平。

参考资料:

  1. https://blog.csdn.net/qq_38880380/article/details/78799103
  2. https://devtalk.nvidia.com/default/topic/1003613/jetson-tx2/gpio-doesn-t-work-/1

猜你喜欢

转载自blog.csdn.net/baidu_15547923/article/details/89743390