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
Diff: command_interface.cpp
- Revision:
- 22:bd98a782fba6
- Child:
- 26:a63e73885b21
diff -r e149d0bdbf4a -r bd98a782fba6 command_interface.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/command_interface.cpp Fri Sep 13 03:34:43 2013 +0000 @@ -0,0 +1,80 @@ +#include "mbed.h" +#include "command_interface.h" +#include "serial_utilities.h" +#include "ika.h" + + +int try_and_check( char *command, char *expected_return_str, int mode ) +{ + char rtn_str[ STR_BUFF_SIZE ]; + int result = 1; + + print_command( command ); + put_string( command ); + + get_string( rtn_str ); + print_result( result = strcmp( expected_return_str, rtn_str ) ); + + if ( result && !mode ) + error( "command failed\r\n" ); + + error_state |= result; + + return ( result ); +} + + +int try_and_check2( char *command, char *expected_return_str, int mode ) +{ + char rtn_str[ STR_BUFF_SIZE ]; + int result = 1; + + print_command( command ); + put_string( command ); + + get_string( rtn_str ); // just readout echoback + get_string( rtn_str ); + print_result( result = strcmp( expected_return_str, rtn_str ) ); + + if ( result && !mode ) + error( "command failed\r\n" ); + + error_state |= result; + + return ( result ); +} + + +void print_command( char *command ) +{ + char s[ STR_BUFF_SIZE ]; + char *pos; + + strcpy( s, command ); + + if ( pos = strchr( s, '\r' ) ) + *pos = '\0'; + + if ( pos = strchr( s, '\n' ) ) + *pos = '\0'; + + printf( " command-\"%s\" : ", s ); +} + + +void print_result( int r ) +{ + printf( "%s\r\n", r ? "Fail" : "Pass" ); +} + + +void send_RAM_transfer_checksum( int checksum ) +{ + char command[ 16 ]; + + sprintf( command, "%d\n", checksum ); + try_and_check( command, "OK", 0 ); +} + + +