-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathcbus_dump.c
43 lines (39 loc) · 1.14 KB
/
cbus_dump.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include<stdio.h>
#include<stdint.h>
#include<unistd.h>
#include<sys/mman.h>
#include<sys/types.h>
#include<sys/stat.h>
#include<fcntl.h>
#include "ls1c_regs.h"
int main()
{
uint32_t * map_base;
FILE *f;
int n, fd;
fd = open("/dev/mem", O_RDWR|O_SYNC);
if (fd == -1) {
return (-1);
}
/* 把bfd01000开始0x1000字节,映射到map_base */
map_base = mmap(NULL, 0x1000, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0x1fd01000);
if (map_base == 0) {
printf("NULL pointer!\n");
}
unsigned long addr;
unsigned char content;
int i = 0,i1 = 0;
uint32_t dat;
printf("[gpio_number]: 0 8 16 24 32 40 48 56 64 72 80 88 96 104 112 120");
for(i1 = 0 ; i1 < 5 ; i1 ++) { //每个gpio5个功能的定义分别是bfd0110c0,bfd0110d0,bfd0110e0,bfd0110f0,bfd011200开始的16个字节,
printf("\nfun%d[1fd01%03x]:",i1 + 1,LS1X_CBUS_FIRST0 + i1 * 0x10);
for(i = 0 ; i < 0x4 ; i ++) {
dat=map_base[(LS1X_CBUS_FIRST0 + i1 * 0x10)/4 + i];
printf(" %02x %02x %02x %02x",(uint8_t) dat&0xff,(uint8_t)(dat>>8)&0xff,(uint8_t)(dat>>16)&0xff,(uint8_t)(dat>>24)&0xff);
}
}
close(fd);
printf("\n");
munmap(map_base, 0xff);
return (0);
}