summaryrefslogtreecommitdiff
path: root/avr/cmd_boot.c
diff options
context:
space:
mode:
authorLeo C2018-09-10 20:55:21 +0200
committerLeo C2018-09-10 20:55:21 +0200
commit9403f93922ea096bfdea4a81f1c34c5c044fcbbb (patch)
treef976a30629b21683a93d8e31c64beeaca6281895 /avr/cmd_boot.c
parentd66348b4fb147eb01c30aa9b3a8904ce6c59a4c1 (diff)
downloadz180-stamp-9403f93922ea096bfdea4a81f1c34c5c044fcbbb.zip
command go: new option -h
Diffstat (limited to 'avr/cmd_boot.c')
-rw-r--r--avr/cmd_boot.c32
1 files changed, 27 insertions, 5 deletions
diff --git a/avr/cmd_boot.c b/avr/cmd_boot.c
index f4a6183..e26a8b1 100644
--- a/avr/cmd_boot.c
+++ b/avr/cmd_boot.c
@@ -254,10 +254,26 @@ command_ret_t do_busreq_pulse(cmd_tbl_t *cmdtp UNUSED, uint_fast8_t flag UNUSED,
command_ret_t do_go(cmd_tbl_t *cmdtp UNUSED, uint_fast8_t flag UNUSED, int argc, char * const argv[])
{
uint32_t addr;
+ bool hold = 0;
- if (argc < 2)
+ /* reset getopt() */
+ optind = 0;
+
+ int opt;
+ while ((opt = getopt(argc, argv, PSTR("h"))) != -1) {
+ switch (opt) {
+ case 'h':
+ hold = 1;
+ break;
+ default: /* '?' */
+ return CMD_RET_USAGE;
+ }
+ }
+ argc -= optind; /* remaining arguments */
+
+ if (argc != 1)
return CMD_RET_USAGE;
- addr = eval_arg(argv[1], NULL);
+ addr = eval_arg(argv[optind], NULL);
if (addr >= (1UL<<16)) {
printf_P(PSTR("Invalid startaddress: 0x%05lx\n"
" (Out of logical address space (0x00000-0x0ffff))\n"),
@@ -282,13 +298,19 @@ command_ret_t do_go(cmd_tbl_t *cmdtp UNUSED, uint_fast8_t flag UNUSED, int argc,
z80_write(2, (addr >> 8));
z80_bus_cmd(Run);
+ _delay_us(10);
z80_bus_cmd(M_Cycle);
+ _delay_us(10);
z80_bus_cmd(M_Cycle);
+ _delay_us(10);
z80_write_block(tmp, 0, 3);
- } else
+ } else {
+ if (!hold)
+ z80_bus_cmd(Request);
z80_bus_cmd(Run);
-
- z80_bus_cmd(Release);
+ }
+ if (!hold)
+ z80_bus_cmd(Release);
return CMD_RET_SUCCESS;
}