Make read_memory debug output use ccdbg_debug.
authorKeith Packard <keithp@keithp.com>
Tue, 23 Dec 2008 03:10:27 +0000 (19:10 -0800)
committerKeith Packard <keithp@keithp.com>
Tue, 23 Dec 2008 03:10:27 +0000 (19:10 -0800)
This makes it default to not being presented, which makes s51 much happier

Signed-off-by: Keith Packard <keithp@keithp.com>
lib/ccdbg-debug.c
lib/ccdbg-io.c
lib/ccdbg-memory.c
lib/ccdbg.h

index 2e67bc8d9d00181ff0ee3e2f7ddebb485c6098dd..8f6f9e11a800c20bec8d764d0b87678fc6c19d7d 100644 (file)
@@ -45,3 +45,9 @@ ccdbg_debug(int level, char *format, ...)
                va_end(ap);
        }
 }
+
+void
+ccdbg_flush(void)
+{
+       fflush(stdout);
+}
index 6999dbecb1503684f77532259488a006660c8c84..5ecea769c6b4f9c6b1340067ba8be4709f211128 100644 (file)
@@ -129,6 +129,7 @@ ccdbg_recv_bit(struct ccdbg *dbg, int first)
 
        ccdbg_send(dbg, CC_CLOCK|mask|CC_RESET_N, CC_CLOCK|CC_DATA|CC_RESET_N);
        read = ccdbg_read(dbg);
+       ccdbg_print("#\t%c %c %c\n", CC_DATA, read);
        ccdbg_send(dbg, CC_CLOCK|     CC_RESET_N,                  CC_RESET_N);
        return (read & CC_DATA) ? 1 : 0;
 }
index 105295db7c8dc238606a84f859ba1c4b5f76bb31..3406a1b17a1d48a1dafec3e8449fdceccc484281 100644 (file)
@@ -54,10 +54,18 @@ ccdbg_write_memory(struct ccdbg *dbg, uint16_t addr, uint8_t *bytes, int nbytes)
        for (i = 0; i < nbytes; i++) {
                write8[DATA_BYTE] = *bytes++;
                ccdbg_execute(dbg, write8);
-               if ((i & 0xf) == 0xf) { printf ("."); fflush(stdout); nl = 1; }
-               if ((i & 0xff) == 0xff) { printf ("\n"); nl = 0; }
+               if ((i & 0xf) == 0xf) {
+                       ccdbg_debug(CC_DEBUG_MEMORY, ".");
+                       ccdbg_flush();
+                       nl = 1;
+               }
+               if ((i & 0xff) == 0xff) {
+                       ccdbg_debug(CC_DEBUG_MEMORY, "\n");
+                       nl = 0;
+               }
        }
-       if (nl) printf ("\n");
+       if (nl)
+               ccdbg_debug(CC_DEBUG_MEMORY, "\n");
        return 0;
 }
 
@@ -70,10 +78,18 @@ ccdbg_read_memory(struct ccdbg *dbg, uint16_t addr, uint8_t *bytes, int nbytes)
        (void) ccdbg_execute(dbg, memory_init);
        for (i = 0; i < nbytes; i++) {
                *bytes++ = ccdbg_execute(dbg, read8);
-               if ((i & 0xf) == 0xf) { printf ("."); fflush(stdout); nl = 1; }
-               if ((i & 0xff) == 0xff) { printf ("\n"); nl = 0; }
+               if ((i & 0xf) == 0xf) {
+                       ccdbg_debug(CC_DEBUG_MEMORY, ".");
+                       ccdbg_flush();
+                       nl = 1;
+               }
+               if ((i & 0xff) == 0xff) {
+                       ccdbg_debug(CC_DEBUG_MEMORY, "\n");
+                       nl = 0;
+               }
        }
-       if (nl) printf ("\n");
+       if (nl)
+               ccdbg_debug(CC_DEBUG_MEMORY, "\n");
        return 0;
 }
 
index 4d4a648d41ccf61c8d6c0729bf43bb1d21ddf678..e0e58104049ba1826e45c0b2043310020adf6063 100644 (file)
@@ -160,6 +160,7 @@ struct hex_image {
 #define CC_DEBUG_INSTRUCTIONS  0x00000004
 #define CC_DEBUG_EXECUTE       0x00000008
 #define CC_DEBUG_FLASH         0x00000010
+#define CC_DEBUG_MEMORY                0x00000020
 
 /* ccdbg-command.c */
 void
@@ -223,6 +224,9 @@ ccdbg_add_debug(int level);
 void
 ccdbg_clear_debug(int level);
 
+void
+ccdbg_flush(void);
+
 /* ccdbg-flash.c */
 uint8_t
 ccdbg_flash_hex_image(struct ccdbg *dbg, struct hex_image *image);