Add to 11U68 11E68

Dependencies:   DirectoryList MODSERIAL mbed

Fork of ika_shouyu_poppoyaki by Tedd OKANO

Files at this revision

API Documentation at this revision

Comitter:
okano
Date:
Fri Sep 13 03:41:11 2013 +0000
Parent:
22:bd98a782fba6
Child:
24:9830b4f1207b
Commit message:
dividing code into modules

Changed in this revision

main.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
target_handling.h Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Fri Sep 13 03:34:43 2013 +0000
+++ b/main.cpp	Fri Sep 13 03:41:11 2013 +0000
@@ -27,12 +27,11 @@
 #include    "command_interface.h"
 #include    "writing.h"
 #include    "uu_coding.h"
+#include    "target_handling.h"
 #include    "ika.h"
 
 
 BusOut          leds( LED4, LED3, LED2, LED1 );
-DigitalOut      reset_pin( p26 );
-DigitalOut      isp_pin( p25 );
 LocalFileSystem local( "local" );
 Ticker          success;
 
@@ -40,9 +39,6 @@
 
 
 
-#define     ENTER_TO_ISP_MODE   0
-#define     NO_ISP_MODE         1
-
 #define     SOURCE_FILE         "/local/bin"
 
 //  "ISP_BAUD_RATE" is baud rate for ISP operation
@@ -60,12 +56,10 @@
 
 int     error_state         = 0;
 
-target_param *open_target( int baud_date );
 int     verify_flash( FILE *fp, target_param *tpp );
 int     post_writing_process( target_param *tpp );
 
 int     file_size( FILE *fp );
-void    reset_target( int isp_pin_state );
 char    read_byte( void );
 void    erase_sectors( int last_sector );
 int     verify_binary_data( FILE *fp );
@@ -174,53 +168,6 @@
 }
 
 
-target_param *open_target( int baud_date )
-{
-    target_param    *tpp;
-    char            str_buf0[ STR_BUFF_SIZE ];
-    char            str_buf1[ STR_BUFF_SIZE ];
-
-    set_target_baud_rate( baud_date );
-    
-    reset_target( ENTER_TO_ISP_MODE );
-    
-    try_and_check( "?", "Synchronized", 0 );
-    
-    try_and_check2( "Synchronized\r\n", "OK", 0 );
-    try_and_check2( "12000\r\n", "OK", 0 );
-    try_and_check2( "U 23130\r\n", "0", 0 );
-    try_and_check2( "A 0\r\n", "0", 0 );
-    
-    try_and_check( "K\r\n", "0", 0 );
-    get_string( str_buf0 );
-    get_string( str_buf1 );
-    
-    printf( "    result of \"K\" = %s %s\r\n", str_buf0, str_buf1 );
-    
-    try_and_check( "J\r\n", "0", 0 );
-    get_string( str_buf0 );
-    
-    printf( "    result of \"J\" = %s\r\n", str_buf0 );
-    
-    tpp  = find_target_param( str_buf0 );
-    
-    return ( tpp );
-}
-
-
-void reset_target( int isp_pin_state )
-{
-    reset_pin   = 1;
-    isp_pin     = isp_pin_state;
-    wait_ms( 100 );
-    
-    reset_pin   = 0;
-    wait_ms( 100 );
-    
-    reset_pin   = 1;
-    wait_ms( 100 );
-}
-
 
 
 void erase_sectors( int last_sector )
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/target_handling.cpp	Fri Sep 13 03:41:11 2013 +0000
@@ -0,0 +1,55 @@
+#include    "mbed.h"
+#include    "target_handling.h"
+#include    "target_table.h"
+#include    "command_interface.h"
+#include    "serial_utilities.h"
+
+DigitalOut      reset_pin( p26 );
+DigitalOut      isp_pin( p25 );
+
+target_param *open_target( int baud_date )
+{
+    target_param    *tpp;
+    char            str_buf0[ STR_BUFF_SIZE ];
+    char            str_buf1[ STR_BUFF_SIZE ];
+
+    set_target_baud_rate( baud_date );
+    
+    reset_target( ENTER_TO_ISP_MODE );
+    
+    try_and_check( "?", "Synchronized", 0 );
+    
+    try_and_check2( "Synchronized\r\n", "OK", 0 );
+    try_and_check2( "12000\r\n", "OK", 0 );
+    try_and_check2( "U 23130\r\n", "0", 0 );
+    try_and_check2( "A 0\r\n", "0", 0 );
+    
+    try_and_check( "K\r\n", "0", 0 );
+    get_string( str_buf0 );
+    get_string( str_buf1 );
+    
+    printf( "    result of \"K\" = %s %s\r\n", str_buf0, str_buf1 );
+    
+    try_and_check( "J\r\n", "0", 0 );
+    get_string( str_buf0 );
+    
+    printf( "    result of \"J\" = %s\r\n", str_buf0 );
+    
+    tpp  = find_target_param( str_buf0 );
+    
+    return ( tpp );
+}
+
+
+void reset_target( int isp_pin_state )
+{
+    reset_pin   = 1;
+    isp_pin     = isp_pin_state;
+    wait_ms( 100 );
+    
+    reset_pin   = 0;
+    wait_ms( 100 );
+    
+    reset_pin   = 1;
+    wait_ms( 100 );
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/target_handling.h	Fri Sep 13 03:41:11 2013 +0000
@@ -0,0 +1,10 @@
+
+#include    "target_table.h"
+
+
+#define     ENTER_TO_ISP_MODE   0
+#define     NO_ISP_MODE         1
+
+
+target_param    *open_target( int baud_date );
+void            reset_target( int isp_pin_state );