Skip to content

Commit af6880f

Browse files
author
Sean Cross
committed
debugger: Add more SFRs
1 parent 0365fb7 commit af6880f

File tree

2 files changed

+53
-8
lines changed

2 files changed

+53
-8
lines changed

doc/ax215.md

+22-4
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,11 @@ Special Function Registers
4040
-----+-------+-------+-------+-------+-------+-------+-------+-------+
4141
98 | | | | | | | | |
4242
-----+-------+-------+-------+-------+-------+-------+-------+-------+
43-
A0 | | | | | | | | |
43+
A0 | SDUN4 | SDUN5 | | | | | | |
4444
-----+-------+-------+-------+-------+-------+-------+-------+-------+
4545
A8 | IE | | | | | | | |
4646
-----+-------+-------+-------+-------+-------+-------+-------+-------+
47-
B0 | | | | | | | | |
47+
B0 | | | | | | SDUN6 | | |
4848
-----+-------+-------+-------+-------+-------+-------+-------+-------+
4949
B8 | | SDFMT | | | | | | |
5050
-----+-------+-------+-------+-------+-------+-------+-------+-------+
@@ -56,11 +56,11 @@ Special Function Registers
5656
-----+-------+-------+-------+-------+-------+-------+-------+-------+
5757
D8 | ER20 | ER21 | ER22 | ER23 | | | SDXBL | SDXBH |
5858
-----+-------+-------+-------+-------+-------+-------+-------+-------+
59-
E0 | ACC | | | | | | SDCMD | SDX |
59+
E0 | ACC | | | SDUN1 | SDUN2 | SDUN3 | SDCMD | SDX |
6060
-----+-------+-------+-------+-------+-------+-------+-------+-------+
6161
E8 | SDXSM | SDI1 | SDI2 | SDI3 | SDI4 | | GPIO1 | |
6262
-----+-------+-------+-------+-------+-------+-------+-------+-------+
63-
F0 | B | | GPIO2 | | | | | |
63+
F0 | B | | GPIO2 | | | | | GPIOI |
6464
-----+-------+-------+-------+-------+-------+-------+-------+-------+
6565
F8 | ER30 | ER31 | ER32 | ER33 | | | | |
6666
-----+-------+-------+-------+-------+-------+-------+-------+-------+
@@ -97,6 +97,18 @@ ER32 - Extended Register 3, byte 2
9797

9898
ER33 - Extended Register 3, byte 3
9999

100+
SDUN1 - Modifying this register affects the SD pins in an unknown fashion.
101+
102+
SDUN2 - Modifying this register affects the SD pins in an unknown fashion.
103+
104+
SDUN3 - Modifying this register affects the SD pins in an unknown fashion.
105+
106+
SDUN4 - Modifying this register affects the SD pins in an unknown fashion.
107+
108+
SDUN5 - Modifying this register affects the SD pins in an unknown fashion.
109+
110+
SDUN6 - Modifying this register affects the SD pins in an unknown fashion.
111+
100112
SDXBL - SD Transmission byte count (low byte)
101113

102114
SDXBH - SD Transmission byte count (high byte)
@@ -130,6 +142,12 @@ GPIO2 - Seems to control values for GPIO pins. 1 sets pin high, 0 sets low.
130142
0x10 - DAT2
131143
0x08 - DAT1
132144

145+
GPIOI - GPIO input values:
146+
0x04 - DAT0
147+
0x08 - DAT1
148+
0x10 - DAT2
149+
0x20 - DAT3
150+
133151
0xf0 -> Can be set to 0, stays 0
134152
0xf1 -> Can be set to 0, stays 0
135153
0xf2 -> Can be set to 0, stays 0

src/ax215/debugger.c

+31-4
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ static struct debug_command debug_commands[] = {
135135
" -d Dump internal ram\n"
136136
" -w addr:val Set RAM [addr] to value [val]\n"
137137
" -i addr Invert RAM contents\n"
138+
" -n addr Set register [addr] to random value\n"
138139
" -r addr Read RAM [addr]\n"
139140
" -x addr Read 32-bit register [addr]\n"
140141
,
@@ -147,6 +148,7 @@ static struct debug_command debug_commands[] = {
147148
" -d Dump special function registers\n"
148149
" -w sfr:val Set SFR [sfr] to value [val]\n"
149150
" -i addr Invert RAM contents\n"
151+
" -n addr Set register [addr] to random value\n"
150152
" -r sfr Read SFR [sfr]\n"
151153
" -x sfr Read extended (quad-wide-wide) sfr\n"
152154
,
@@ -173,7 +175,7 @@ static struct debug_command debug_commands[] = {
173175
{
174176
.name = "irq",
175177
.func = dbg_do_irq,
176-
.desc = "Manipulate IRQs on the AX215\n",
178+
.desc = "Manipulate IRQs on the AX215",
177179
.help = "Usage: irq [-r] [-m mask] [-p]\n"
178180
" -r Reset IRQ statistics\n"
179181
" -p Print IRQ statistics\n"
@@ -183,7 +185,7 @@ static struct debug_command debug_commands[] = {
183185
{
184186
.name = "gpio",
185187
.func = dbg_do_gpio,
186-
.desc = "Set/query GPIO values\n",
188+
.desc = "Set/query GPIO values",
187189
.help = "Usage: gpio [-d] [-i DATpin] [-o DATpin] [-s/-c DATpin]\n"
188190
" -d Dump GPIO values\n"
189191
" -i x Make DATx a GPIO input\n"
@@ -330,7 +332,7 @@ static int dbg_do_sfr(struct dbg *dbg, int argc, char **argv) {
330332
if (!strcmp(argv[0], "sfr"))
331333
offset = 0x80;
332334

333-
while ((ch = getopt(argc, argv, "di:w:r:x:")) != -1) {
335+
while ((ch = getopt(argc, argv, "di:w:r:x:n:")) != -1) {
334336
switch(ch) {
335337
case 'd':
336338
for (sfr = 0; sfr <= 127; sfr++) {
@@ -392,6 +394,27 @@ static int dbg_do_sfr(struct dbg *dbg, int argc, char **argv) {
392394
}
393395
break;
394396

397+
case 'n': {
398+
int sfr = strtoul(optarg, NULL, 0);
399+
int val;
400+
if (offset && (sfr < 0x80 || sfr > 0xff)) {
401+
printf("Invalid SFR. "
402+
"SFR addresses go between 0x80 and 0xff\n");
403+
return -EINVAL;
404+
}
405+
if (!offset && (sfr < 0x00 || sfr > 0x7f)) {
406+
printf("Invalid RAM address. "
407+
"RAM addresses go between 0x00 and 0x7f\n");
408+
return -EINVAL;
409+
}
410+
411+
val = rand() & 0xff;
412+
printf("Setting %s_%02x 0x%02x -> %02x\n",
413+
offset?"SFR":"RAM", sfr, ram_get(dbg, sfr), val);
414+
ram_set(dbg, sfr, val);
415+
}
416+
break;
417+
395418
case 'x':
396419
case 'r': {
397420
uint8_t cmd[4];
@@ -1067,7 +1090,11 @@ static int install_isrs(struct dbg *dbg) {
10671090
ram_set(dbg, 0xfb, 0); // Reset count
10681091
printf("UNK ");
10691092

1070-
printf("] Okay\n");
1093+
printf("] ");
1094+
printf("Enabling... ");
1095+
ram_set(dbg, 0xa8, 0xff);
1096+
1097+
printf("Okay\n");
10711098
return 0;
10721099
}
10731100

0 commit comments

Comments
 (0)