From: Leo C Date: Mon, 10 Sep 2018 18:55:21 +0000 (+0200) Subject: command go: new option -h X-Git-Url: http://cloudbase.mooo.com/gitweb/z180-stamp.git/commitdiff_plain/9403f93922ea096bfdea4a81f1c34c5c044fcbbb command go: new option -h --- 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; } diff --git a/avr/command_tbl.c b/avr/command_tbl.c index 4ed37b7..c526199 100644 --- a/avr/command_tbl.c +++ b/avr/command_tbl.c @@ -201,12 +201,10 @@ CMD_TBL_ITEM( #endif /* CONFIG_CMD_LOADB */ CMD_TBL_ITEM( - go, 2, 0, do_go, + go, CONFIG_SYS_MAXARGS, 0, do_go, "start application at address 'addr'", - "addr\n" + "[-h] addr\n" " - start application at address 'addr'" -// "\n" -// " passing 'arg' as arguments" ), CMD_TBL_ITEM( reset, 1, 0, do_reset,