FreeCalypso > hg > freecalypso-tools
comparison target-utils/libcommon/abbcmd.c @ 0:e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sat, 11 Jun 2016 00:13:35 +0000 |
parents | |
children | 4be951811791 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:e7502631a0f9 |
---|---|
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 abb_init(); | |
29 val = abb_reg_read(PAGE(pg) | reg); | |
30 printf("%03X\n", val); | |
31 } | |
32 | |
33 void | |
34 cmd_abbw(argbulk) | |
35 char *argbulk; | |
36 { | |
37 char *argv[4]; | |
38 u32 pg, reg, val; | |
39 | |
40 if (parse_args(argbulk, 3, 3, argv, 0) < 0) | |
41 return; | |
42 pg = strtoul(argv[0], 0, 0); | |
43 reg = strtoul(argv[1], 0, 0); | |
44 val = strtoul(argv[2], 0, 16); | |
45 if (pg > 1 || reg > 31 || val > 0x3FF) { | |
46 printf("ERROR: argument(s) out of range\n"); | |
47 return; | |
48 } | |
49 abb_init(); | |
50 abb_reg_write(PAGE(pg) | reg, val); | |
51 } |