Code to load a LPC1114 over tx/rx. I have only tested with a 1114 chip but it should work with other LPC uControllers

Dependencies:   DirectoryList MODSERIAL mbed

Fork of ika_shouyu_poppoyaki by Tedd OKANO

Revision:
48:99cfe3a929ea
Parent:
47:e7d395119a63
Child:
52:afd15e54142f
--- a/isp.cpp	Tue Jan 06 11:05:29 2015 +0000
+++ b/isp.cpp	Thu Jan 29 10:48:57 2015 +0000
@@ -20,9 +20,10 @@
 unsigned int    read_crp( FILE *fp );
 unsigned int    crp_check( FILE *fp );
 void            success_indicator();
+void            user_action_waiting_indicator();
 
 
-int isp_flash_write( char *file_name )
+int isp_flash_write( const char *file_name )
 {
     FILE            *fp;
     target_param    *tpp;
@@ -40,6 +41,29 @@
     printf( "                        RAM size   =  %10d bytes\r\n", tpp->ram_size );
     printf( "                        flash size =  %10d bytes\r\n", tpp->flash_size );
 
+    //
+    //  If user selected "flash erase only"
+    //
+
+    if ( *file_name == 0xFF ) {
+        last_sector = find_sector( tpp->flash_size - 1, tpp );
+        
+        //  The file selector returns 0xFF as first character of the string
+        //      if user selected "flash erase".
+
+        printf( "\r\n  ==== flash erasing ====\r\n" );
+        
+        if ( erase_sectors( last_sector ) )
+            return ( ERROR_AT_SECTOR_ERASE );
+
+        printf( "  sectors from 0 to %d are erased. bye\r\n", last_sector );
+        exit ( 0 ); //  quit from app
+    }
+
+    //
+    //  Normal operation
+    //
+
     printf( "  opening file: \"%s\"\r\n", file_name );
 
     if ( NULL == (fp    = fopen( file_name, "rb" )) ) {
@@ -118,7 +142,7 @@
 
     post_writing_process( tpp );
 
-    return ( 0 );
+    return ( NO_ERROR );
 }
 
 
@@ -193,7 +217,6 @@
     leds    = 0x1 << (i++ & 0x3);
 }
 
-
 void toggle_led( char v )
 {
     leds    = leds ^ (0x1 << v);