FreeCalypso > hg > freecalypso-sw
annotate target-utils/libcommon/abbcmd.c @ 389:e60aecf23970
target-utils: ABB operations implemented (ported from OsmocomBB),
linked into pirexplore
author | Michael Spacefalcon <msokolov@ivan.Harhan.ORG> |
---|---|
date | Wed, 11 Jun 2014 06:50:46 +0000 |
parents | |
children | bb4814eb51e4 |
rev | line source |
---|---|
389
e60aecf23970
target-utils: ABB operations implemented (ported from OsmocomBB),
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1 /* |
e60aecf23970
target-utils: ABB operations implemented (ported from OsmocomBB),
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2 * abbr pg reg -- read ABB register |
e60aecf23970
target-utils: ABB operations implemented (ported from OsmocomBB),
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3 * abbw pg reg val -- write ABB register |
e60aecf23970
target-utils: ABB operations implemented (ported from OsmocomBB),
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
4 */ |
e60aecf23970
target-utils: ABB operations implemented (ported from OsmocomBB),
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
5 |
e60aecf23970
target-utils: ABB operations implemented (ported from OsmocomBB),
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
6 #include <sys/types.h> |
e60aecf23970
target-utils: ABB operations implemented (ported from OsmocomBB),
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
7 #include "types.h" |
e60aecf23970
target-utils: ABB operations implemented (ported from OsmocomBB),
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
8 #include "abbdefs.h" |
e60aecf23970
target-utils: ABB operations implemented (ported from OsmocomBB),
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
9 |
e60aecf23970
target-utils: ABB operations implemented (ported from OsmocomBB),
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
10 extern u16 abb_reg_read(); |
e60aecf23970
target-utils: ABB operations implemented (ported from OsmocomBB),
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
11 extern void abb_reg_write(); |
e60aecf23970
target-utils: ABB operations implemented (ported from OsmocomBB),
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
12 |
e60aecf23970
target-utils: ABB operations implemented (ported from OsmocomBB),
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
13 void |
e60aecf23970
target-utils: ABB operations implemented (ported from OsmocomBB),
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
14 cmd_abbr(argbulk) |
e60aecf23970
target-utils: ABB operations implemented (ported from OsmocomBB),
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
15 char *argbulk; |
e60aecf23970
target-utils: ABB operations implemented (ported from OsmocomBB),
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
16 { |
e60aecf23970
target-utils: ABB operations implemented (ported from OsmocomBB),
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
17 char *argv[3]; |
e60aecf23970
target-utils: ABB operations implemented (ported from OsmocomBB),
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
18 u32 pg, reg, val; |
e60aecf23970
target-utils: ABB operations implemented (ported from OsmocomBB),
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
19 |
e60aecf23970
target-utils: ABB operations implemented (ported from OsmocomBB),
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
20 if (parse_args(argbulk, 2, 2, argv, 0) < 0) |
e60aecf23970
target-utils: ABB operations implemented (ported from OsmocomBB),
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
21 return; |
e60aecf23970
target-utils: ABB operations implemented (ported from OsmocomBB),
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
22 pg = strtoul(argv[0], 0, 0); |
e60aecf23970
target-utils: ABB operations implemented (ported from OsmocomBB),
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
23 reg = strtoul(argv[1], 0, 0); |
e60aecf23970
target-utils: ABB operations implemented (ported from OsmocomBB),
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
24 if (pg > 1 || reg > 31) { |
e60aecf23970
target-utils: ABB operations implemented (ported from OsmocomBB),
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
25 printf("ERROR: argument(s) out of range\n"); |
e60aecf23970
target-utils: ABB operations implemented (ported from OsmocomBB),
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
26 return; |
e60aecf23970
target-utils: ABB operations implemented (ported from OsmocomBB),
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
27 } |
e60aecf23970
target-utils: ABB operations implemented (ported from OsmocomBB),
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
28 val = abb_reg_read(PAGE(pg) | reg); |
e60aecf23970
target-utils: ABB operations implemented (ported from OsmocomBB),
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
29 printf("%03X\n", val); |
e60aecf23970
target-utils: ABB operations implemented (ported from OsmocomBB),
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
30 } |
e60aecf23970
target-utils: ABB operations implemented (ported from OsmocomBB),
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
31 |
e60aecf23970
target-utils: ABB operations implemented (ported from OsmocomBB),
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
32 void |
e60aecf23970
target-utils: ABB operations implemented (ported from OsmocomBB),
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
33 cmd_abbw(argbulk) |
e60aecf23970
target-utils: ABB operations implemented (ported from OsmocomBB),
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
34 char *argbulk; |
e60aecf23970
target-utils: ABB operations implemented (ported from OsmocomBB),
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
35 { |
e60aecf23970
target-utils: ABB operations implemented (ported from OsmocomBB),
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
36 char *argv[4]; |
e60aecf23970
target-utils: ABB operations implemented (ported from OsmocomBB),
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
37 u32 pg, reg, val; |
e60aecf23970
target-utils: ABB operations implemented (ported from OsmocomBB),
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
38 |
e60aecf23970
target-utils: ABB operations implemented (ported from OsmocomBB),
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
39 if (parse_args(argbulk, 3, 3, argv, 0) < 0) |
e60aecf23970
target-utils: ABB operations implemented (ported from OsmocomBB),
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
40 return; |
e60aecf23970
target-utils: ABB operations implemented (ported from OsmocomBB),
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
41 pg = strtoul(argv[0], 0, 0); |
e60aecf23970
target-utils: ABB operations implemented (ported from OsmocomBB),
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
42 reg = strtoul(argv[1], 0, 0); |
e60aecf23970
target-utils: ABB operations implemented (ported from OsmocomBB),
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
43 val = strtoul(argv[2], 0, 16); |
e60aecf23970
target-utils: ABB operations implemented (ported from OsmocomBB),
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
44 if (pg > 1 || reg > 31 || val > 0x3FF) { |
e60aecf23970
target-utils: ABB operations implemented (ported from OsmocomBB),
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
45 printf("ERROR: argument(s) out of range\n"); |
e60aecf23970
target-utils: ABB operations implemented (ported from OsmocomBB),
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
46 return; |
e60aecf23970
target-utils: ABB operations implemented (ported from OsmocomBB),
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
47 } |
e60aecf23970
target-utils: ABB operations implemented (ported from OsmocomBB),
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
48 abb_reg_write(PAGE(pg) | reg, val); |
e60aecf23970
target-utils: ABB operations implemented (ported from OsmocomBB),
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
49 } |