changeset 26:74efdb21ae5d

Use a 32 bit var to hold address from atoi().
author Daniel O'Connor <darius@dons.net.au>
date Sat, 17 Nov 2012 18:03:48 +1030
parents a9cc07caa801
children 5c9d2e3d6591
files flash.c
diffstat 1 files changed, 12 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/flash.c	Sat Nov 17 12:18:24 2012 +1030
+++ b/flash.c	Sat Nov 17 18:03:48 2012 +1030
@@ -32,7 +32,8 @@
 void
 flashcmd(char **argv, int argc) {
     uint8_t status, tmp;
-
+    uint32_t addr;
+    
     if (argc == 0) {
 	fputs("No command specified\r\n", stdout);
 	return;
@@ -61,20 +62,21 @@
 	    fputs("Incorrect number of arguments\r\n", stdout);
 	    return;
 	}
-	tmp = atoi(argv[1]);
-	flash4kerase(tmp);
-	printf("Erased 0x%x\r\n", tmp);
+	addr = atoi(argv[1]);
+	flash4kerase(addr);
+	printf("Erased 0x%x\r\n", (unsigned int)addr);
     } else if (!strcmp(argv[0], "rd")) {
 	if (argc != 2) {
 	    fputs("Incorrect number of arguments\r\n", stdout);
 	    return;
 	}
-	tmp = atoi(argv[1]);
 
-	flashstartread(tmp);
+	addr = atoi(argv[1]);
+
+	flashstartread(addr);
 	
 	for (int i = 0; i < 16; i++)
-	    printf("Read 0x%02x from 0x%06x\r\n", flashreadbyte(), tmp + i);
+	    printf("Read 0x%02x from 0x%06x\r\n", flashreadbyte(), (unsigned int)(addr + i));
 	flashstopread();
 	
 	fputs("\r\n", stdout);
@@ -84,15 +86,15 @@
 	    return;
 	}
 
-	tmp = atoi(argv[1]);
+	addr = atoi(argv[1]);
 
 	for (int i = 0; i < 16; i += 2) {
 	    uint16_t data;
 	    data = ((i + 1) << 8) | i;
-	    printf("Writing 0x%04x to 0x%06x\r\n", data, tmp + i);
+	    printf("Writing 0x%04x to 0x%06x\r\n", data, (unsigned int)(addr + i));
 
 	    if (i == 0)
-		flashstartwrite(tmp, data);
+		flashstartwrite(addr, data);
 	    else
 		flashwriteword(data);
 	}