Add to 11U68 11E68

Dependencies:   DirectoryList MODSERIAL mbed

Fork of ika_shouyu_poppoyaki by Tedd OKANO

Committer:
Hapi_Tech
Date:
Sat Jul 04 05:29:32 2015 +0000
Revision:
50:57ad8e04f063
Parent:
39:f68f9fa1e88e
Adding LPC11U68,11E68.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
okano 23:017f306cf3ca 1 #include "mbed.h"
okano 23:017f306cf3ca 2 #include "target_handling.h"
okano 23:017f306cf3ca 3 #include "target_table.h"
okano 23:017f306cf3ca 4 #include "command_interface.h"
okano 23:017f306cf3ca 5 #include "serial_utilities.h"
okano 39:f68f9fa1e88e 6 #include "_user_settings.h"
okano 39:f68f9fa1e88e 7
okano 23:017f306cf3ca 8
okano 23:017f306cf3ca 9 DigitalOut reset_pin( p26 );
okano 23:017f306cf3ca 10 DigitalOut isp_pin( p25 );
okano 23:017f306cf3ca 11
okano 39:f68f9fa1e88e 12
okano 23:017f306cf3ca 13 target_param *open_target( int baud_date )
okano 23:017f306cf3ca 14 {
okano 23:017f306cf3ca 15 target_param *tpp;
okano 23:017f306cf3ca 16 char str_buf0[ STR_BUFF_SIZE ];
okano 23:017f306cf3ca 17 char str_buf1[ STR_BUFF_SIZE ];
okano 28:689c3880e0e4 18 int retry_count = 3;
okano 23:017f306cf3ca 19
okano 23:017f306cf3ca 20 set_target_baud_rate( baud_date );
okano 28:689c3880e0e4 21
okano 28:689c3880e0e4 22 while ( retry_count-- ) {
okano 28:689c3880e0e4 23 reset_target( ENTER_TO_ISP_MODE );
okano 28:689c3880e0e4 24
okano 35:0b434ef4af49 25 if ( !try_and_check( "?", "Synchronized" ) )
okano 28:689c3880e0e4 26 break;
okano 28:689c3880e0e4 27 }
okano 28:689c3880e0e4 28
okano 28:689c3880e0e4 29 if ( !retry_count )
okano 28:689c3880e0e4 30 return ( NULL );
okano 28:689c3880e0e4 31
okano 35:0b434ef4af49 32 try_and_check2( "Synchronized\r\n", "OK" );
okano 35:0b434ef4af49 33 try_and_check2( "12000\r\n", "OK" );
okano 35:0b434ef4af49 34 try_and_check2( "U 23130\r\n", "0" );
okano 35:0b434ef4af49 35 try_and_check2( "A 0\r\n", "0" );
okano 28:689c3880e0e4 36
okano 35:0b434ef4af49 37 try_and_check( "K\r\n", "0" );
okano 23:017f306cf3ca 38 get_string( str_buf0 );
okano 23:017f306cf3ca 39 get_string( str_buf1 );
okano 28:689c3880e0e4 40
okano 39:f68f9fa1e88e 41 #ifndef SUPPRESS_COMMAND_RESULT_MESSAGE
okano 23:017f306cf3ca 42 printf( " result of \"K\" = %s %s\r\n", str_buf0, str_buf1 );
okano 39:f68f9fa1e88e 43 #endif
okano 28:689c3880e0e4 44
okano 35:0b434ef4af49 45 try_and_check( "J\r\n", "0" );
okano 23:017f306cf3ca 46 get_string( str_buf0 );
okano 28:689c3880e0e4 47
okano 39:f68f9fa1e88e 48 #ifndef SUPPRESS_COMMAND_RESULT_MESSAGE
okano 23:017f306cf3ca 49 printf( " result of \"J\" = %s\r\n", str_buf0 );
okano 39:f68f9fa1e88e 50 #endif
okano 28:689c3880e0e4 51
okano 23:017f306cf3ca 52 tpp = find_target_param( str_buf0 );
okano 28:689c3880e0e4 53
okano 23:017f306cf3ca 54 return ( tpp );
okano 23:017f306cf3ca 55 }
okano 23:017f306cf3ca 56
okano 23:017f306cf3ca 57
okano 23:017f306cf3ca 58 void reset_target( int isp_pin_state )
okano 23:017f306cf3ca 59 {
okano 23:017f306cf3ca 60 reset_pin = 1;
okano 23:017f306cf3ca 61 isp_pin = isp_pin_state;
okano 23:017f306cf3ca 62 wait_ms( 100 );
okano 28:689c3880e0e4 63
okano 23:017f306cf3ca 64 reset_pin = 0;
okano 23:017f306cf3ca 65 wait_ms( 100 );
okano 28:689c3880e0e4 66
okano 23:017f306cf3ca 67 reset_pin = 1;
okano 23:017f306cf3ca 68 wait_ms( 100 );
okano 23:017f306cf3ca 69 }
okano 26:a63e73885b21 70