Jetson Nano IO物理引脚与虚拟引脚映射计算

由于项目需求,需要使用Jetson Nano进行io输入采集和输出控制,在网上查找到的资料无法满足所需,有些虚拟引脚号无法得到,以至于无法对相应的io进行操作。

根据网上相关文档资料,通过以下步骤可以得到相应的引脚映射号,详细步骤如下所示:

(1)登录NVIDIA官网(https://developer.nvidia.com/embedded/downloads

),进行物理引脚文档表格下载,文件名为《NV_Jetson_Nano_Module_Pinmux_Config_Template.xlsm》

(2)登录官网(https://developer.nvidia.com/embedded/linux-tegra-r3223

),下载Jeston Nano相应的BSP源码包,下载后文件名为《public_sources.tbz2》

(3)打开NV_Jetson_Nano_Module_Pinmux_Config_Template.xlsm

(4)解压public_sources.tbz2文件,进入Linux_for_Tegra\source\publickernel_src.tbz2\hardware\nvidia\soc\tegra\kernel-include\dt-bindings\gpio目录。可在该目录下看到《tegra-gpio.h》文件,打开该文件,内容如下:

/*

* This header provides constants for binding nvidia,tegra*-gpio.

*

* The first cell in Tegra's GPIO specifier is the GPIO ID. The macros below

* provide names for this.

*

* The second cell contains standard flag values specified in gpio.h.

*/

#ifndef _DT_BINDINGS_GPIO_TEGRA_GPIO_H

#define _DT_BINDINGS_GPIO_TEGRA_GPIO_H

#include <dt-bindings/gpio/gpio.h>

#define TEGRA_GPIO_BANK_ID_A 0

#define TEGRA_GPIO_BANK_ID_B 1

#define TEGRA_GPIO_BANK_ID_C 2

#define TEGRA_GPIO_BANK_ID_D 3

#define TEGRA_GPIO_BANK_ID_E 4

#define TEGRA_GPIO_BANK_ID_F 5

#define TEGRA_GPIO_BANK_ID_G 6

#define TEGRA_GPIO_BANK_ID_H 7

#define TEGRA_GPIO_BANK_ID_I 8

#define TEGRA_GPIO_BANK_ID_J 9

#define TEGRA_GPIO_BANK_ID_K 10

#define TEGRA_GPIO_BANK_ID_L 11

#define TEGRA_GPIO_BANK_ID_M 12

#define TEGRA_GPIO_BANK_ID_N 13

#define TEGRA_GPIO_BANK_ID_O 14

#define TEGRA_GPIO_BANK_ID_P 15

#define TEGRA_GPIO_BANK_ID_Q 16

#define TEGRA_GPIO_BANK_ID_R 17

#define TEGRA_GPIO_BANK_ID_S 18

#define TEGRA_GPIO_BANK_ID_T 19

#define TEGRA_GPIO_BANK_ID_U 20

#define TEGRA_GPIO_BANK_ID_V 21

#define TEGRA_GPIO_BANK_ID_W 22

#define TEGRA_GPIO_BANK_ID_X 23

#define TEGRA_GPIO_BANK_ID_Y 24

#define TEGRA_GPIO_BANK_ID_Z 25

#define TEGRA_GPIO_BANK_ID_AA 26

#define TEGRA_GPIO_BANK_ID_BB 27

#define TEGRA_GPIO_BANK_ID_CC 28

#define TEGRA_GPIO_BANK_ID_DD 29

#define TEGRA_GPIO_BANK_ID_EE 30

#define TEGRA_GPIO_BANK_ID_FF 31

#define TEGRA_GPIO(bank, offset) \

((TEGRA_GPIO_BANK_ID_##bank * 8) + offset)

#endif

(5)综合以上

《NV_Jetson_Nano_Module_Pinmux_Config_Template.xlsm》内容说明IO物理引脚号定义

《tegra-gpio.h》内容说明IO虚拟引脚号公式计算定义

下面举例说明如何计算出我们需要的IO虚拟引脚号的数值。

如上图,我们选择 UART1_RTS* 对应的物理引脚号 GPIO3_PG.02

然后查找到 #define TEGRA_GPIO_BANK_ID_G 6

代入公式可得 6*8+2=50。

所以我们操作的IO虚拟引脚号为50。

计算完成后,可以登录Jetson Nano进行gpio50的测试操作。