Hi3519v101gpio寄存器操作

1、海思gpio寄存器操作说明

①管脚复用配置;

②方向配置;

③设置管脚输出值;

2、工具说明

海思文件系统内置寄存器查看修改工具常用如下表,参数address既可以是寄存器地址,也可以是内存地址,工具可以用于内存查看、修改。

工具

参数

功能

备注

himd

参数1:address,必选

参数2:length,可选

从address开始,以大端方式打印length字节长度的内容。 

如果没有输入length,那么默认打印256字节。

himd.l

参数1:address,必选

参数2:length,可选

从address开始,以小端方式打印length字节长度的内容。

如果没有输入length,那么默认打印256字节。

himc

参数1:address,必选

参数2:value,必选

参数3:length,必选

从address开始,把 length字节长度的内容全部设置为value。

一般仅用于物理内存内容的修改。

打印工具帮助信息

btools -h

~ # btools -h
-h
        print help msg
-i
        install board tools
-u
        uninstall board tools
-V
        print version
------------------------------------------------------
 himc       : memory clear
 himd       : memory display (8bit)
 himd.l     : memory display (32bit)
 himm       : memory modify
 hivd       : video dump
 himdb      : video dump
 hiddrs     : ddr statistic
 hiew       : extend device write
 hier       : extend device read
 i2c_read   : i2c device read
 i2c_write  : i2c device read
 ssp_read   : ssp device read
 ssp_write  : ssp device read
~ #

4、管脚相关寄存器查找

以gpio3_2为例,步骤如下:

通过《Hi3519V101_PINOUT_CN》查看gpio3_2管脚复用寄存器为muxctrl_reg26,地址为0x12040068,该寄存器等于0时,管脚为gpio。

Hi3519v101gpio寄存器操作_第1张图片

通过《Hi3519V101 专业型HD IP Camera SoC用户指南》gpio篇gpio3_2管脚基地址为0x1214_3000,数据寄存器偏移地址为0x000~0x3CF,方向寄存器偏移地址为0x400。具体寄存器代表的位查看寄存器说明。

Hi3519v101gpio寄存器操作_第2张图片

 

Hi3519v101gpio寄存器操作_第3张图片

对于数据寄存器操作这里需注意:

当GPIO_DIR相应的比特配置为输入时,有效读取的结果将返回管脚的值;当配置为输出的时候,有效读取的结果将返回写入的值。 
GPIO_DATA寄存器利用PADDR[9:2]实现了读写寄存器比特的屏蔽操作。该寄存器对应256个地址空间。PADDR[9:2]分别对应GPIO_DATA[7:0],当相应的bit为高时,则可以对相应的位进行读写操作;反之,若对应bit为低则不能进行操作。例如: 
若地址为0x3FC(0b11_1111_1100),则对GPIO_DATA[7:0]这8bit操作全部有效。 
若地址为0x200(0b10_0000_0000),则仅对GPIO_DATA[7]的操作有效。 

所以,gpio3_2 数据寄存器操作偏移地址为0b00_0001_0000 = 0x010,该地址写0xFF输出高,0x00输出低。

5、操作步骤

管脚复用寄存器0x12040068配置为0

himm 0x12040068 0

~ # himm 0x12040068 0
*** Board tools : ver0.0.1_20121120 ***
[debug]: {source/utils/cmdshell.c:161}cmdstr:himm
0x12040068: 0x00000003 --> 0x00000000
[END]
~ # himd 0x12040068
*** Board tools : ver0.0.1_20121120 ***
[debug]: {source/utils/cmdshell.c:161}cmdstr:himd
====dump memory 0X12040068====
00000:  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  |................|
00010:  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  |................|
00020:  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  |................|
00030:  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  |................|
00040:  00 00 00 00 01 00 00 00 01 00 00 00 00 00 00 00  |................|
00050:  01 00 00 00 01 00 00 00 01 00 00 00 01 00 00 00  |................|
00060:  01 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00  |................|
00070:  00 00 00 00 01 00 00 00 01 00 00 00 01 00 00 00  |................|
00080:  01 00 00 00 01 00 00 00 01 00 00 00 01 00 00 00  |................|
00090:  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  |................|
000a0:  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  |................|
000b0:  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  |................|
000c0:  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  |................|
000d0:  00 00 00 00 02 00 00 00 02 00 00 00 02 00 00 00  |................|
000e0:  02 00 00 00 02 00 00 00 02 00 00 00 02 00 00 00  |................|
000f0:  02 00 00 00 02 00 00 00 02 00 00 00 02 00 00 00  |................|
[END]

管脚方向寄存器0x12143400 (0x12143000 + 0x400)配置为4 (0b0000_0100) 

0:输入

1:输出

~ # himm 0x12143400 4
*** Board tools : ver0.0.1_20121120 ***
[debug]: {source/utils/cmdshell.c:161}cmdstr:himm
0x12143400: 0x00000000 --> 0x00000004
[END]
~ # himd 0x12143400
*** Board tools : ver0.0.1_20121120 ***
[debug]: {source/utils/cmdshell.c:161}cmdstr:himd
====dump memory 0X12143400====
00000:  04 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  |................|
00010:  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  |................|
00020:  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  |................|
00030:  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  |................|
00040:  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  |................|
00050:  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  |................|
00060:  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  |................|
00070:  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  |................|
00080:  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  |................|
00090:  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  |................|
000a0:  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  |................|
000b0:  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  |................|
000c0:  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  |................|
000d0:  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  |................|
000e0:  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  |................|
000f0:  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  |................|
[END]
~ #

管脚数据寄存器0x12143010 (0x12143000 + 0x010)配置为0xFF输出高电平

~ # himm 0x12143010 0xFF
*** Board tools : ver0.0.1_20121120 ***
[debug]: {source/utils/cmdshell.c:161}cmdstr:himm
0x12143010: 0x00000000 --> 0x000000FF
[END]
~ # himd 0x12143010
*** Board tools : ver0.0.1_20121120 ***
[debug]: {source/utils/cmdshell.c:161}cmdstr:himd
====dump memory 0X12143010====
00000:  04 00 00 00 04 00 00 00 04 00 00 00 04 00 00 00  |................|
00010:  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  |................|
00020:  04 00 00 00 04 00 00 00 04 00 00 00 04 00 00 00  |................|
00030:  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  |................|
00040:  04 00 00 00 04 00 00 00 04 00 00 00 04 00 00 00  |................|
00050:  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  |................|
00060:  04 00 00 00 04 00 00 00 04 00 00 00 04 00 00 00  |................|
00070:  20 00 00 00 20 00 00 00 20 00 00 00 20 00 00 00  | ... ... ... ...|
00080:  24 00 00 00 24 00 00 00 24 00 00 00 24 00 00 00  |$...$...$...$...|
00090:  20 00 00 00 20 00 00 00 20 00 00 00 20 00 00 00  | ... ... ... ...|
000a0:  24 00 00 00 24 00 00 00 24 00 00 00 24 00 00 00  |$...$...$...$...|
000b0:  20 00 00 00 20 00 00 00 20 00 00 00 20 00 00 00  | ... ... ... ...|
000c0:  24 00 00 00 24 00 00 00 24 00 00 00 24 00 00 00  |$...$...$...$...|
000d0:  20 00 00 00 20 00 00 00 20 00 00 00 20 00 00 00  | ... ... ... ...|
000e0:  24 00 00 00 24 00 00 00 24 00 00 00 24 00 00 00  |$...$...$...$...|
000f0:  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  |................|
[END]

配置为0x00输出低电平

~ # himm 0x12143010 0x00
*** Board tools : ver0.0.1_20121120 ***
[debug]: {source/utils/cmdshell.c:161}cmdstr:himm
0x12143010: 0x00000004 --> 0x00000000
[END]
~ # himd 0x12143010
*** Board tools : ver0.0.1_20121120 ***
[debug]: {source/utils/cmdshell.c:161}cmdstr:himd
====dump memory 0X12143010====
00000:  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  |................|
00010:  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  |................|
00020:  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  |................|
00030:  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  |................|
00040:  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  |................|
00050:  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  |................|
00060:  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  |................|
00070:  20 00 00 00 20 00 00 00 20 00 00 00 20 00 00 00  | ... ... ... ...|
00080:  20 00 00 00 20 00 00 00 20 00 00 00 20 00 00 00  | ... ... ... ...|
00090:  20 00 00 00 20 00 00 00 20 00 00 00 20 00 00 00  | ... ... ... ...|
000a0:  20 00 00 00 20 00 00 00 20 00 00 00 20 00 00 00  | ... ... ... ...|
000b0:  20 00 00 00 20 00 00 00 20 00 00 00 20 00 00 00  | ... ... ... ...|
000c0:  20 00 00 00 20 00 00 00 20 00 00 00 20 00 00 00  | ... ... ... ...|
000d0:  20 00 00 00 20 00 00 00 20 00 00 00 20 00 00 00  | ... ... ... ...|
000e0:  20 00 00 00 20 00 00 00 20 00 00 00 20 00 00 00  | ... ... ... ...|
000f0:  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  |................|
[END]
~ #

 

你可能感兴趣的:(linux,gpio,驱动)