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 Tedd OKANO

target_handling.cpp

Committer:
okano
Date:
2013-09-13
Revision:
26:a63e73885b21
Parent:
23:017f306cf3ca
Child:
28:689c3880e0e4

File content as of revision 26:a63e73885b21:

#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 );
}