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

Files at this revision

API Documentation at this revision

Comitter:
okano
Date:
Sun Sep 29 03:54:06 2013 +0000
Parent:
38:cb95bfe0546a
Child:
40:615dc8275648
Commit message:
ver 0.98 : suppressed debug message in default setting. it improves speed of writing and verifying

Changed in this revision

_user_settings.h Show annotated file Show diff for this revision Revisions of this file
command_interface.cpp Show annotated file Show diff for this revision Revisions of this file
command_interface.h Show annotated file Show diff for this revision Revisions of this file
isp.cpp Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
serial_utilities.cpp Show annotated file Show diff for this revision Revisions of this file
target_handling.cpp Show annotated file Show diff for this revision Revisions of this file
verification.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/_user_settings.h	Fri Sep 27 14:48:17 2013 +0000
+++ b/_user_settings.h	Sun Sep 29 03:54:06 2013 +0000
@@ -8,6 +8,11 @@
 #define     ISP_BAUD_RATE       115200
 
 
+//  suppress "command and result" monitoring output to terminal
+//  the "command and result" monitoring feature is made for debugging. 
+#define     SUPPRESS_COMMAND_RESULT_MESSAGE
+
+
 //  "TARGET_OPERATION_BAUD_RATE" is baud rate for USB-serial bridge operation after 
 //  ISP completion. 
 //  if the target application uses serial(UART) and you use the bridge feature, 
--- a/command_interface.cpp	Fri Sep 27 14:48:17 2013 +0000
+++ b/command_interface.cpp	Sun Sep 29 03:54:06 2013 +0000
@@ -43,6 +43,8 @@
 
 void print_command( char *command )
 {
+#ifndef SUPPRESS_COMMAND_RESULT_MESSAGE
+
     char    s[ STR_BUFF_SIZE ];
     char    *pos;
 
@@ -54,13 +56,17 @@
     if ( pos    = strchr( s, '\n' ) )
         *pos    = '\0';
 
-    printf( "  command-\"%s\" : ", s );
+    printf( "  command - %-22s : ", s );
+
+#endif  //SUPPRESS_COMMAND_RESULT_MESSAGE
 }
 
 
 void print_result( int r )
 {
+#ifndef SUPPRESS_COMMAND_RESULT_MESSAGE
     printf( "%s\r\n", r ? "Fail" : "Pass" );
+#endif  //SUPPRESS_COMMAND_RESULT_MESSAGE
 }
 
 
@@ -69,7 +75,7 @@
     char    command[ 16 ];
 
     sprintf( command, "%d\n", checksum );
-    
+
     return ( try_and_check( command, "OK" ) );
 }
 
--- a/command_interface.h	Fri Sep 27 14:48:17 2013 +0000
+++ b/command_interface.h	Sun Sep 29 03:54:06 2013 +0000
@@ -1,5 +1,5 @@
 
-#define     STR_BUFF_SIZE       64
+#define     STR_BUFF_SIZE       128
 
 int     try_and_check( char *command, char *expected_return_str );
 int     try_and_check2( char *command, char *expected_return_str );
--- a/isp.cpp	Fri Sep 27 14:48:17 2013 +0000
+++ b/isp.cpp	Sun Sep 29 03:54:06 2013 +0000
@@ -35,9 +35,9 @@
     }
 
     printf( "  target device found : type       = \"%s\"\r\n",     tpp->type_name );
-    printf( "                        ID         = 0x%08X\r\n",     tpp->id );
-    printf( "                        RAM size   = %10d bytes\r\n", tpp->ram_size );
-    printf( "                        flash size = %10d bytes\r\n", tpp->flash_size );
+    printf( "                        ID         =  0x%08X\r\n",     tpp->id );
+    printf( "                        RAM size   =  %10d bytes\r\n", tpp->ram_size );
+    printf( "                        flash size =  %10d bytes\r\n", tpp->flash_size );
 
     printf( "  opening file: \"%s\"\r\n", file_name );
 
--- a/main.cpp	Fri Sep 27 14:48:17 2013 +0000
+++ b/main.cpp	Sun Sep 29 03:54:06 2013 +0000
@@ -2,7 +2,7 @@
  *  Sample of ISP operation for NXP MCUs
  *
  *  @author  Tedd OKANO
- *  @version 0.97
+ *  @version 0.98
  *  @date    Sep-2013
  *
  *  This program programs MCU flash memory through UART. It uses
@@ -37,7 +37,7 @@
 {
     int     err;
 
-    printf( "\r\n\r\n\r\nmbed ISP program : programming LPC device from mbed (v0.97)\r\n" );
+    printf( "\r\n\r\n\r\nmbed ISP program : programming LPC device from mbed (v0.98)\r\n" );
 
     err     = isp_flash_write( SOURCE_FILE );
 
--- a/serial_utilities.cpp	Fri Sep 27 14:48:17 2013 +0000
+++ b/serial_utilities.cpp	Sun Sep 29 03:54:06 2013 +0000
@@ -101,9 +101,10 @@
     timeout_flag    = 0;
     timeout.attach( &set_flag, 1 );
 
-    for ( i = 0; i < length; i++ ) {
+    for ( i = 0; i < length; ) {
         if ( target.readable() ) {
             *b++    = target.getc();
+            i++;
             toggle_led( 1 );
         }
 
--- a/target_handling.cpp	Fri Sep 27 14:48:17 2013 +0000
+++ b/target_handling.cpp	Sun Sep 29 03:54:06 2013 +0000
@@ -3,10 +3,13 @@
 #include    "target_table.h"
 #include    "command_interface.h"
 #include    "serial_utilities.h"
+#include    "_user_settings.h"
+
 
 DigitalOut      reset_pin( p26 );
 DigitalOut      isp_pin( p25 );
 
+
 target_param *open_target( int baud_date )
 {
     target_param    *tpp;
@@ -35,12 +38,16 @@
     get_string( str_buf0 );
     get_string( str_buf1 );
 
+#ifndef SUPPRESS_COMMAND_RESULT_MESSAGE
     printf( "    result of \"K\" = %s %s\r\n", str_buf0, str_buf1 );
+#endif
 
     try_and_check( "J\r\n", "0" );
     get_string( str_buf0 );
 
+#ifndef SUPPRESS_COMMAND_RESULT_MESSAGE
     printf( "    result of \"J\" = %s\r\n", str_buf0 );
+#endif
 
     tpp  = find_target_param( str_buf0 );
 
--- a/verification.cpp	Fri Sep 27 14:48:17 2013 +0000
+++ b/verification.cpp	Sun Sep 29 03:54:06 2013 +0000
@@ -67,6 +67,7 @@
         if ( try_and_check( command_str, "0" ) )
             return ( ERROR_AT_READ_COMMAND );
 
+        wait_ms( 1 );
         get_binary( br, 1 );
         get_binary( br, size );