FreeCalypso > hg > freecalypso-sw
annotate target-utils/libcommon/cmd_r16.c @ 62:6fb41cfa773d
fc-loadtool: flash erase implemented, compiles
author | Michael Spacefalcon <msokolov@ivan.Harhan.ORG> |
---|---|
date | Thu, 27 Jun 2013 04:56:17 +0000 |
parents | f4fc449a64ea |
children |
rev | line source |
---|---|
13
f4fc449a64ea
target-utils libcommon infrastructure for interactive commands
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1 /* |
f4fc449a64ea
target-utils libcommon infrastructure for interactive commands
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2 * r16 hexaddr -- read a 16-bit register or memory location |
f4fc449a64ea
target-utils libcommon infrastructure for interactive commands
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3 */ |
f4fc449a64ea
target-utils libcommon infrastructure for interactive commands
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
4 |
f4fc449a64ea
target-utils libcommon infrastructure for interactive commands
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
5 #include <sys/types.h> |
f4fc449a64ea
target-utils libcommon infrastructure for interactive commands
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
6 #include "types.h" |
f4fc449a64ea
target-utils libcommon infrastructure for interactive commands
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
7 |
f4fc449a64ea
target-utils libcommon infrastructure for interactive commands
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
8 void |
f4fc449a64ea
target-utils libcommon infrastructure for interactive commands
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
9 cmd_r16(argbulk) |
f4fc449a64ea
target-utils libcommon infrastructure for interactive commands
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
10 char *argbulk; |
f4fc449a64ea
target-utils libcommon infrastructure for interactive commands
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
11 { |
f4fc449a64ea
target-utils libcommon infrastructure for interactive commands
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
12 char *argv[2]; |
f4fc449a64ea
target-utils libcommon infrastructure for interactive commands
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
13 u_long addr; |
f4fc449a64ea
target-utils libcommon infrastructure for interactive commands
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
14 |
f4fc449a64ea
target-utils libcommon infrastructure for interactive commands
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
15 if (parse_args(argbulk, 1, 1, argv, 0) < 0) |
f4fc449a64ea
target-utils libcommon infrastructure for interactive commands
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
16 return; |
f4fc449a64ea
target-utils libcommon infrastructure for interactive commands
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
17 if (parse_hexarg(argv[0], 8, &addr) < 0) { |
f4fc449a64ea
target-utils libcommon infrastructure for interactive commands
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
18 printf("ERROR: argument must be a valid 32-bit hex address\n"); |
f4fc449a64ea
target-utils libcommon infrastructure for interactive commands
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
19 return; |
f4fc449a64ea
target-utils libcommon infrastructure for interactive commands
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
20 } |
f4fc449a64ea
target-utils libcommon infrastructure for interactive commands
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
21 if (addr & 1) { |
f4fc449a64ea
target-utils libcommon infrastructure for interactive commands
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
22 printf("ERROR: unaligned address\n"); |
f4fc449a64ea
target-utils libcommon infrastructure for interactive commands
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
23 return; |
f4fc449a64ea
target-utils libcommon infrastructure for interactive commands
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
24 } |
f4fc449a64ea
target-utils libcommon infrastructure for interactive commands
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
25 printf("%04X\n", *(volatile u16 *)addr); |
f4fc449a64ea
target-utils libcommon infrastructure for interactive commands
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
26 } |