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 22:bd98a782fba6 1 #include "mbed.h"
okano 22:bd98a782fba6 2 #include "command_interface.h"
okano 22:bd98a782fba6 3 #include "serial_utilities.h"
okano 29:96e28bc1bd99 4 #include "_user_settings.h"
okano 22:bd98a782fba6 5
okano 22:bd98a782fba6 6
okano 35:0b434ef4af49 7 int try_and_check( char *command, char *expected_return_str )
okano 22:bd98a782fba6 8 {
okano 22:bd98a782fba6 9 char rtn_str[ STR_BUFF_SIZE ];
okano 22:bd98a782fba6 10 int result = 1;
okano 22:bd98a782fba6 11
okano 22:bd98a782fba6 12 print_command( command );
okano 22:bd98a782fba6 13 put_string( command );
okano 22:bd98a782fba6 14
okano 22:bd98a782fba6 15 get_string( rtn_str );
okano 22:bd98a782fba6 16 print_result( result = strcmp( expected_return_str, rtn_str ) );
okano 22:bd98a782fba6 17
okano 35:0b434ef4af49 18 // if ( result && !mode )
okano 35:0b434ef4af49 19 // error( "command failed\r\n" );
okano 22:bd98a782fba6 20
okano 22:bd98a782fba6 21 return ( result );
okano 22:bd98a782fba6 22 }
okano 22:bd98a782fba6 23
okano 22:bd98a782fba6 24
okano 35:0b434ef4af49 25 int try_and_check2( char *command, char *expected_return_str )
okano 22:bd98a782fba6 26 {
okano 22:bd98a782fba6 27 char rtn_str[ STR_BUFF_SIZE ];
okano 22:bd98a782fba6 28 int result = 1;
okano 22:bd98a782fba6 29
okano 22:bd98a782fba6 30 print_command( command );
okano 22:bd98a782fba6 31 put_string( command );
okano 22:bd98a782fba6 32
okano 22:bd98a782fba6 33 get_string( rtn_str ); // just readout echoback
okano 22:bd98a782fba6 34 get_string( rtn_str );
okano 22:bd98a782fba6 35 print_result( result = strcmp( expected_return_str, rtn_str ) );
okano 22:bd98a782fba6 36
okano 35:0b434ef4af49 37 // if ( result && !mode )
okano 35:0b434ef4af49 38 // error( "command failed\r\n" );
okano 22:bd98a782fba6 39
okano 22:bd98a782fba6 40 return ( result );
okano 22:bd98a782fba6 41 }
okano 22:bd98a782fba6 42
okano 22:bd98a782fba6 43
okano 22:bd98a782fba6 44 void print_command( char *command )
okano 22:bd98a782fba6 45 {
okano 39:f68f9fa1e88e 46 #ifndef SUPPRESS_COMMAND_RESULT_MESSAGE
okano 39:f68f9fa1e88e 47
okano 22:bd98a782fba6 48 char s[ STR_BUFF_SIZE ];
okano 22:bd98a782fba6 49 char *pos;
okano 22:bd98a782fba6 50
okano 22:bd98a782fba6 51 strcpy( s, command );
okano 22:bd98a782fba6 52
okano 22:bd98a782fba6 53 if ( pos = strchr( s, '\r' ) )
okano 22:bd98a782fba6 54 *pos = '\0';
okano 22:bd98a782fba6 55
okano 22:bd98a782fba6 56 if ( pos = strchr( s, '\n' ) )
okano 22:bd98a782fba6 57 *pos = '\0';
okano 22:bd98a782fba6 58
okano 39:f68f9fa1e88e 59 printf( " command - %-22s : ", s );
okano 39:f68f9fa1e88e 60
okano 39:f68f9fa1e88e 61 #endif //SUPPRESS_COMMAND_RESULT_MESSAGE
okano 22:bd98a782fba6 62 }
okano 22:bd98a782fba6 63
okano 22:bd98a782fba6 64
okano 22:bd98a782fba6 65 void print_result( int r )
okano 22:bd98a782fba6 66 {
okano 39:f68f9fa1e88e 67 #ifndef SUPPRESS_COMMAND_RESULT_MESSAGE
okano 22:bd98a782fba6 68 printf( "%s\r\n", r ? "Fail" : "Pass" );
okano 39:f68f9fa1e88e 69 #endif //SUPPRESS_COMMAND_RESULT_MESSAGE
okano 22:bd98a782fba6 70 }
okano 22:bd98a782fba6 71
okano 22:bd98a782fba6 72
okano 27:2b5c1eb39bb5 73 int send_RAM_transfer_checksum( int checksum )
okano 22:bd98a782fba6 74 {
okano 22:bd98a782fba6 75 char command[ 16 ];
okano 22:bd98a782fba6 76
okano 22:bd98a782fba6 77 sprintf( command, "%d\n", checksum );
okano 39:f68f9fa1e88e 78
okano 35:0b434ef4af49 79 return ( try_and_check( command, "OK" ) );
okano 22:bd98a782fba6 80 }
okano 22:bd98a782fba6 81
okano 22:bd98a782fba6 82
okano 27:2b5c1eb39bb5 83 int erase_sectors( int last_sector )
okano 26:a63e73885b21 84 {
okano 26:a63e73885b21 85 char command_str[ STR_BUFF_SIZE ];
okano 22:bd98a782fba6 86
okano 26:a63e73885b21 87 sprintf( command_str, "P 0 %d\r\n", last_sector );
okano 35:0b434ef4af49 88 if ( try_and_check( command_str, "0" ) )
okano 27:2b5c1eb39bb5 89 return ( 1 );
okano 26:a63e73885b21 90
okano 26:a63e73885b21 91 *(command_str) = 'E';
okano 35:0b434ef4af49 92 return ( try_and_check( command_str, "0" ) );
okano 26:a63e73885b21 93 }
okano 26:a63e73885b21 94
okano 26:a63e73885b21 95