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
target_handling.cpp@26:a63e73885b21, 2013-09-13 (annotated)
- Committer:
- okano
- Date:
- Fri Sep 13 12:56:23 2013 +0000
- Revision:
- 26:a63e73885b21
- Parent:
- 23:017f306cf3ca
- Child:
- 28:689c3880e0e4
code is still dirty but it works. I hope I will have chance to clean up some day...
Who changed what in which revision?
User | Revision | Line number | New 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 | 23:017f306cf3ca | 6 | |
okano | 23:017f306cf3ca | 7 | DigitalOut reset_pin( p26 ); |
okano | 23:017f306cf3ca | 8 | DigitalOut isp_pin( p25 ); |
okano | 23:017f306cf3ca | 9 | |
okano | 23:017f306cf3ca | 10 | target_param *open_target( int baud_date ) |
okano | 23:017f306cf3ca | 11 | { |
okano | 23:017f306cf3ca | 12 | target_param *tpp; |
okano | 23:017f306cf3ca | 13 | char str_buf0[ STR_BUFF_SIZE ]; |
okano | 23:017f306cf3ca | 14 | char str_buf1[ STR_BUFF_SIZE ]; |
okano | 23:017f306cf3ca | 15 | |
okano | 23:017f306cf3ca | 16 | set_target_baud_rate( baud_date ); |
okano | 23:017f306cf3ca | 17 | |
okano | 23:017f306cf3ca | 18 | reset_target( ENTER_TO_ISP_MODE ); |
okano | 23:017f306cf3ca | 19 | |
okano | 23:017f306cf3ca | 20 | try_and_check( "?", "Synchronized", 0 ); |
okano | 23:017f306cf3ca | 21 | |
okano | 23:017f306cf3ca | 22 | try_and_check2( "Synchronized\r\n", "OK", 0 ); |
okano | 23:017f306cf3ca | 23 | try_and_check2( "12000\r\n", "OK", 0 ); |
okano | 23:017f306cf3ca | 24 | try_and_check2( "U 23130\r\n", "0", 0 ); |
okano | 23:017f306cf3ca | 25 | try_and_check2( "A 0\r\n", "0", 0 ); |
okano | 23:017f306cf3ca | 26 | |
okano | 23:017f306cf3ca | 27 | try_and_check( "K\r\n", "0", 0 ); |
okano | 23:017f306cf3ca | 28 | get_string( str_buf0 ); |
okano | 23:017f306cf3ca | 29 | get_string( str_buf1 ); |
okano | 23:017f306cf3ca | 30 | |
okano | 23:017f306cf3ca | 31 | printf( " result of \"K\" = %s %s\r\n", str_buf0, str_buf1 ); |
okano | 23:017f306cf3ca | 32 | |
okano | 23:017f306cf3ca | 33 | try_and_check( "J\r\n", "0", 0 ); |
okano | 23:017f306cf3ca | 34 | get_string( str_buf0 ); |
okano | 23:017f306cf3ca | 35 | |
okano | 23:017f306cf3ca | 36 | printf( " result of \"J\" = %s\r\n", str_buf0 ); |
okano | 23:017f306cf3ca | 37 | |
okano | 23:017f306cf3ca | 38 | tpp = find_target_param( str_buf0 ); |
okano | 23:017f306cf3ca | 39 | |
okano | 23:017f306cf3ca | 40 | return ( tpp ); |
okano | 23:017f306cf3ca | 41 | } |
okano | 23:017f306cf3ca | 42 | |
okano | 23:017f306cf3ca | 43 | |
okano | 23:017f306cf3ca | 44 | void reset_target( int isp_pin_state ) |
okano | 23:017f306cf3ca | 45 | { |
okano | 23:017f306cf3ca | 46 | reset_pin = 1; |
okano | 23:017f306cf3ca | 47 | isp_pin = isp_pin_state; |
okano | 23:017f306cf3ca | 48 | wait_ms( 100 ); |
okano | 23:017f306cf3ca | 49 | |
okano | 23:017f306cf3ca | 50 | reset_pin = 0; |
okano | 23:017f306cf3ca | 51 | wait_ms( 100 ); |
okano | 23:017f306cf3ca | 52 | |
okano | 23:017f306cf3ca | 53 | reset_pin = 1; |
okano | 23:017f306cf3ca | 54 | wait_ms( 100 ); |
okano | 23:017f306cf3ca | 55 | } |
okano | 26:a63e73885b21 | 56 |