全志平台通读写寄存器的方法

https://blog.csdn.net/weixin_43094346/article/details/87974003

echo 寄存器值 > /sys/class/sunxi_dump/dump

cat dump 查看写进去的值

echo 寄存器值 > /sys/class/sunxi_dumo/write

cat write 查看写进去的值

示例:

1.

到全志一号通查阅对应芯片的user_manual,看想查的寄存器的位置是多少

如,将PH8配作spi0的mosi

2.

io口的基地址0x01C2 0800

PH Configure Register 1的偏移 Offset:0x100

所以这一组是的地址是0x01C2 0900

3.

查到PH8_SELECT Bit 2:0(0到2位):

PH8_SELECT

000: Input

001: Output

010: SPI0_MOSI

011: UART3_RTS

100: Reserved

101: Reserved

110: Reserved

111: IO Disable

所以如果PH8配成spi 的mosi的话,应该是

0x00000022

32位寄存器:

0000 0000 0000 0000 0000 0000 0000 0010

后面3位010则代表是配成SPI0_MOSI

4.

验证:

root@mico:/sys/class/sunxi_dump# echo 0x01C20900 > dump                         
root@mico:/sys/class/sunxi_dump# cat dump                                       
0x00000022

确认无误

5.

再查spi0对应的寄存器的数值:

R16 spi0 - 0x01C6 8000 --- 0x01C6 8FFF  (size 4K)

root@mico:/sys/class/sunxi_dump# echo 0x01C68000 > dump                         
root@mico:/sys/class/sunxi_dump# cat dump                                       
0x00090000

即:

0000 0000 0000 1001 0000 0000 0000 0000

读多个寄存器的数据:

root@mico:/sys/class/sunxi_dump# echo 0x01c68000,0x01c68300 > dump              
root@mico:/sys/class/sunxi_dump# cat dump                                       
0x01c68000: 0x00090000 0x00000083 0x000001c4 0x00000000                         
0x01c68010: 0x00000000 0x00000032 0x00400001 0x00000000                         
0x01c68020: 0x00000000 0x00001001 0x00000000 0x00000000                         
0x01c68030: 0x00000000 0x00000000 0x00000000 0x00000000                         
.....                         
0x01c682f0: 0x00000000 0x00000000 0x00000000 0x00000000                         
0x01c68300: 0x00000000

比如,查offset 0x08

root@mico:/sys/class/sunxi_dump# echo 0x01c68008 > dump                         
root@mico:/sys/class/sunxi_dump# cat dump                                       
0x000001c4

0x000001c4 = 0000 0000 0000 0000 0000 0001 1100 0100

从右边数第31个bit位是0,0: Idle-0代表idle,可以从用户手册里查到每个寄存器每个数值的含义。

(0)

相关推荐