]> cloudbase.mooo.com Git - z180-stamp.git/commitdiff
command go: new option -h
authorLeo C <erbl259-lmu@yahoo.de>
Mon, 10 Sep 2018 18:55:21 +0000 (20:55 +0200)
committerLeo C <erbl259-lmu@yahoo.de>
Mon, 10 Sep 2018 18:55:21 +0000 (20:55 +0200)
avr/cmd_boot.c
avr/command_tbl.c

index f4a6183913bc9fe3df7d99ac4512c35a62831845..e26a8b1b3340226aa0730bd871a9a653a49b575a 100644 (file)
@@ -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;
 }
index 4ed37b7e825a083c3083ee1cd50b8c48bae2307d..c526199ec889a10ebbb77f7fb42e480d268bbea7 100644 (file)
@@ -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,