]> cloudbase.mooo.com Git - z180-stamp.git/commitdiff
loadi cosmetic changes
authorLeo C <erbl259-lmu@yahoo.de>
Tue, 5 May 2015 13:41:33 +0000 (15:41 +0200)
committerLeo C <erbl259-lmu@yahoo.de>
Tue, 5 May 2015 13:41:33 +0000 (15:41 +0200)
avr/cmd_loadihex.c
avr/command_tbl.c

index aaee064974e15371d2e5c389f1f38739be0787bc..18d5331d8b2a0d9f8fc025cae787943ccf571d4b 100644 (file)
@@ -93,11 +93,17 @@ int ihex_get_record(ihex_t *rec) {
        uint8_t sum;
 
        rec->status = IHX_BROKEN;
+       rec->len = 0;
+       rec->type = 0xff;
 
-
-       while ((c = my_getchar(0)) != ':')
+       while ((c = my_getchar(0)) != ':') {
                if (c == 0x03)
-                       return -1;
+                       return -1;                                      /* Control-C */
+               if (c == 0x04) {
+                       rec->status = IHX_OK;
+                       return 0;                                       /*Control-D, EOF */
+               }
+       }
 
        if ((c = get_hexbyte()) < 0)            /* Start code */
                        return -1;
@@ -154,6 +160,7 @@ command_ret_t do_loadihex(cmd_tbl_t *cmdtp, int flag, int argc, char * const arg
        uint32_t address_low = address_max;
        command_ret_t rcode = CMD_RET_FAILURE;
        ihex_t rec;
+       bool firstrec = true;
 
        (void) cmdtp; (void) flag;
 
@@ -161,12 +168,18 @@ command_ret_t do_loadihex(cmd_tbl_t *cmdtp, int flag, int argc, char * const arg
        if (argc > 1)
                offset = strtol(argv[1], NULL, 16);
 
+       printf_P(PSTR("Waiting for Intel Hex Records...\n"));
+
        while (ihex_get_record(&rec) > 0 &&
                                rec.status == IHX_OK &&
                                rec.type != 1 ) {
 
                switch (rec.type) {
                case 0: /* Data record */
+                       if (firstrec) {
+                               printf_P(PSTR("Loading: 0x....."));
+                               firstrec = false;
+                       }
                        if (rec.len) {
                                uint32_t addr = base_address + rec.address + offset;
                                if (addr < address_low)
@@ -176,7 +189,7 @@ command_ret_t do_loadihex(cmd_tbl_t *cmdtp, int flag, int argc, char * const arg
 
 //                             debug("low: 0x%.5lX, high: 0x%.5lX, max: 0x%.5lX, addr: 0x%.5lX, len: %d\n",
 //                                     address_low, address_high, address_max, addr, rec.len);
-
+                               printf_P(PSTR("\b\b\b\b\b%.5lX"), addr);
                                if (addr < address_max) {
                                        uint32_t tmplen = address_max - addr;
                                        if (rec.len > tmplen)
@@ -224,11 +237,16 @@ command_ret_t do_loadihex(cmd_tbl_t *cmdtp, int flag, int argc, char * const arg
                break;
        }
 
-       /* flush input buffer */
-       while (my_getchar(0) > 0)
-               ;
 
-       printf_P(PSTR("Data loaded: "));
+       for (uint_fast8_t i=0; i<100; ++i) {
+               /* flush input buffer */
+               while (my_getchar(0) > 0)
+                       ;
+               udelay(1000);
+       }
+
+
+       printf_P(PSTR("\nData loaded: "));
        if (address_low >= MIN(address_high, address_max))
                printf_P(PSTR("None.\n"));
        else
index b3c401ce14b9e7fedafcf68dd3adde1ea5307a2d..23d080372dd2db3fa950e5a63f410a27b5438de5 100644 (file)
@@ -128,8 +128,9 @@ CMD_TBL_ITEM(
 ),
 CMD_TBL_ITEM(
        loadi,  2,      0,      do_loadihex,
-       "load intel hex file",
-       "[[-]offset]"
+       "load intel hex file over serial line",
+       "[[-]offset]\n"
+       "    - load Intel-Hex-Record file over serial line with offset 'offset'"
 ),
 CMD_TBL_ITEM(
        go,     2,      0,      do_go,