FreeCalypso > hg > freecalypso-sw
comparison 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 |
comparison
equal
deleted
inserted
replaced
388:821a26f90968 | 389:e60aecf23970 |
---|---|
1 /* | |
2 * abbr pg reg -- read ABB register | |
3 * abbw pg reg val -- write ABB register | |
4 */ | |
5 | |
6 #include <sys/types.h> | |
7 #include "types.h" | |
8 #include "abbdefs.h" | |
9 | |
10 extern u16 abb_reg_read(); | |
11 extern void abb_reg_write(); | |
12 | |
13 void | |
14 cmd_abbr(argbulk) | |
15 char *argbulk; | |
16 { | |
17 char *argv[3]; | |
18 u32 pg, reg, val; | |
19 | |
20 if (parse_args(argbulk, 2, 2, argv, 0) < 0) | |
21 return; | |
22 pg = strtoul(argv[0], 0, 0); | |
23 reg = strtoul(argv[1], 0, 0); | |
24 if (pg > 1 || reg > 31) { | |
25 printf("ERROR: argument(s) out of range\n"); | |
26 return; | |
27 } | |
28 val = abb_reg_read(PAGE(pg) | reg); | |
29 printf("%03X\n", val); | |
30 } | |
31 | |
32 void | |
33 cmd_abbw(argbulk) | |
34 char *argbulk; | |
35 { | |
36 char *argv[4]; | |
37 u32 pg, reg, val; | |
38 | |
39 if (parse_args(argbulk, 3, 3, argv, 0) < 0) | |
40 return; | |
41 pg = strtoul(argv[0], 0, 0); | |
42 reg = strtoul(argv[1], 0, 0); | |
43 val = strtoul(argv[2], 0, 16); | |
44 if (pg > 1 || reg > 31 || val > 0x3FF) { | |
45 printf("ERROR: argument(s) out of range\n"); | |
46 return; | |
47 } | |
48 abb_reg_write(PAGE(pg) | reg, val); | |
49 } |