Ika Shouyu Poppoyaki - LPC82x supported

Dependencies:   MODSERIAL mbed

Fork of ika_shouyu_poppoyaki by Tedd OKANO

Files at this revision

API Documentation at this revision

Comitter:
okano
Date:
Thu Sep 19 01:08:20 2013 +0000
Parent:
26:a63e73885b21
Child:
28:689c3880e0e4
Commit message:
{cannot be build} an a precess of clean-up

Changed in this revision

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
main.cpp Show annotated file Show diff for this revision Revisions of this file
target_table.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
writing.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/command_interface.cpp	Fri Sep 13 12:56:23 2013 +0000
+++ b/command_interface.cpp	Thu Sep 19 01:08:20 2013 +0000
@@ -68,24 +68,26 @@
 }
 
 
-void send_RAM_transfer_checksum( int checksum )
+int send_RAM_transfer_checksum( int checksum )
 {
     char    command[ 16 ];
 
     sprintf( command, "%d\n", checksum );
-    try_and_check( command, "OK", 0 );
+    
+    return ( try_and_check( command, "OK", 0 ) );
 }
 
 
-void erase_sectors( int last_sector )
+int erase_sectors( int last_sector )
 {
     char    command_str[ STR_BUFF_SIZE ];
 
     sprintf( command_str, "P 0 %d\r\n", last_sector );
-    try_and_check( command_str, "0", 0 );
+    if ( try_and_check( command_str, "0", 0 ) )
+        return ( 1 );
 
     *(command_str)  = 'E';
-    try_and_check( command_str, "0", 0 );
+    return ( try_and_check( command_str, "0", 0 ) );
 }
 
 
--- a/command_interface.h	Fri Sep 13 12:56:23 2013 +0000
+++ b/command_interface.h	Thu Sep 19 01:08:20 2013 +0000
@@ -5,6 +5,6 @@
 int     try_and_check2( char *command, char *expected_return_str, int mode );
 void    print_command( char *command );
 void    print_result( int r );
-void    send_RAM_transfer_checksum( int checksum );
-void    erase_sectors( int last_sector );
+int     send_RAM_transfer_checksum( int checksum );
+int     erase_sectors( int last_sector );
 
--- a/main.cpp	Fri Sep 13 12:56:23 2013 +0000
+++ b/main.cpp	Thu Sep 19 01:08:20 2013 +0000
@@ -58,8 +58,8 @@
         return ( 1 );
     }
 
-    printf( "  target device found : type       = \"%s\"\r\n",   tpp->type_name );
-    printf( "                        ID         = 0x%08X\r\n", tpp->id );
+    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 );
 
--- a/target_table.cpp	Fri Sep 13 12:56:23 2013 +0000
+++ b/target_table.cpp	Thu Sep 19 01:08:20 2013 +0000
@@ -12,6 +12,7 @@
     { "LPC812M101JDH20",        0x00008122, 4096,   16384, 1024, BINARY,   0x10000300 },
 };
 
+
 target_param *find_target_param( char *device_id_string )
 {
     int     id;
--- a/verification.cpp	Fri Sep 13 12:56:23 2013 +0000
+++ b/verification.cpp	Thu Sep 19 01:08:20 2013 +0000
@@ -14,11 +14,9 @@
 int verify_flash( FILE *fp, target_param *tpp )
 {
     if ( tpp->write_type == BINARY )
-        verify_binary_data( fp );
+        return ( verify_binary_data( fp ) );
     else
-        verify_uucoded_data( fp );
-
-    return ( 0 );   //  this is temporallry return code
+        return ( verify_uucoded_data( fp ) );
 }
 
 
@@ -65,7 +63,8 @@
 
         sprintf( command_str, "R %ld %ld\r\n", read_size, size );
 //        try_and_check( command_str, "0", MODE_SILENT );
-        try_and_check( command_str, "0", 0 );
+        if ( try_and_check( command_str, "0", 0 ) )
+            return ( ERROR_AT_READ_COMMAND );
 
         get_binary( br, 1 );
         get_binary( br, size );
@@ -94,7 +93,7 @@
     free( bf );
     free( br );
 
-    return ( read_size );
+    return ( error_flag ? ERROR_DATA_DOES_NOT_MATCH : NO_ERROR );
 }
 
 
@@ -129,7 +128,8 @@
         }
 
         sprintf( command_str, "R %ld %ld\r\n", read_size, size );
-        try_and_check( command_str, "0", 0 );
+        if ( try_and_check( command_str, "0", 0 ) )
+            return ( ERROR_AT_READ_COMMAND );
 
         get_binary_from_uucode_str( br, size );
 
@@ -156,7 +156,7 @@
     free( bf );
     free( br );
 
-    return ( read_size );
+    return ( error_flag ? ERROR_DATA_DOES_NOT_MATCH : NO_ERROR );
 }
 
 
--- a/writing.cpp	Fri Sep 13 12:56:23 2013 +0000
+++ b/writing.cpp	Thu Sep 19 01:08:20 2013 +0000
@@ -15,11 +15,9 @@
 int write_flash( FILE *fp, target_param *tpp )
 {
     if ( tpp->write_type == BINARY )
-        write_binary_data( fp, tpp->ram_size, tpp->sector_size, tpp->ram_start_address );
+        return ( write_binary_data( fp, tpp->ram_size, tpp->sector_size, tpp->ram_start_address ) );
     else // UUENCODE
-        write_uuencoded_data(  fp, tpp->ram_size, tpp->sector_size, tpp->ram_start_address );
-        
-    return ( 0 );   //  this is temporallry return code 
+        return ( write_uuencoded_data(  fp, tpp->ram_size, tpp->sector_size, tpp->ram_start_address ) );
 }
 
 
@@ -61,7 +59,8 @@
         }
 
         sprintf( command_str, "W %ld %ld\r\n", ram_start, transfer_size );
-        try_and_check( command_str, "0", 0 );
+        if ( try_and_check( command_str, "0", 0 ) )
+            return ( ERROR_AT_WRITE_COMMAND );
 
         for ( int i = 0; i < lines_per_transfer; i++ ) {
 
@@ -81,17 +80,19 @@
         checksum   = 0;
 
         sprintf( command_str, "P %d %d\r\n", total_size / sector_size, total_size / sector_size );
-        try_and_check( command_str, "0", 0 );
+        if ( try_and_check( command_str, "0", 0 ) )
+            return ( ERROR_AT_P_COMMAND );
 
         sprintf( command_str, "C %d %d %d\r\n", total_size, ram_start, flash_writing_size );
-        try_and_check( command_str, "0", 0 );
+        if ( try_and_check( command_str, "0", 0 ) )
+            return ( ERROR_AT_COPY_COMMAND );
 
         total_size  += size;
     }
 
     free( b );
 
-    return ( total_size );
+    return ( NO_ERROR );
 }
 
 
@@ -117,16 +118,19 @@
         }
 
         sprintf( command_str, "W %ld %ld\r\n", ram_start, flash_writing_size );
-        try_and_check( command_str, "0", 0 );
+        if ( try_and_check( command_str, "0", 0 ) )
+            return ( ERROR_AT_WRITE_COMMAND );
 
         put_binary( b, flash_writing_size );
         put_string( "\r\n" );
 
         sprintf( command_str, "P %d %d\r\n", total_size / sector_size, total_size / sector_size );
-        try_and_check( command_str, "0", 0 );
+        if ( try_and_check( command_str, "0", 0 ) )
+            return ( ERROR_AT_P_COMMAND );
 
         sprintf( command_str, "C %d %d %d\r\n", total_size, ram_start, flash_writing_size );
-        try_and_check( command_str, "0", 0 );
+        if ( try_and_check( command_str, "0", 0 ) )
+            return ( ERROR_AT_COPY_COMMAND );
 
         total_size  += size;
         //printf( "  total %d bytes transferred\r", total_size );
@@ -135,7 +139,7 @@
 
     free( b );
 
-    return ( total_size );
+    return ( NO_ERROR );
 }