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
Revision 5:ff30f5b58617, committed 2013-08-25
- Comitter:
- okano
- Date:
- Sun Aug 25 01:49:08 2013 +0000
- Parent:
- 4:55f1977bd11a
- Child:
- 6:0ae6fe8c8512
- Commit message:
- target_table_added
Changed in this revision
--- a/main.cpp Sun Aug 25 00:41:56 2013 +0000 +++ b/main.cpp Sun Aug 25 01:49:08 2013 +0000 @@ -1,4 +1,5 @@ -#include "mbed.h" +#include "mbed.h" +#include "target_table.h" BusOut leds( LED4, LED3, LED2, LED1 ); DigitalOut reset_pin( p26 ); @@ -12,11 +13,12 @@ #define BAUD_RATE 115200 #define STR_BUFF_SIZE 64 -#define RAM_START_ADDRESS 0x10000300L -//#define RAM_START_ADDRESS 0x10000100L +//#define RAM_START_ADDRESS 0x10000300L +#define RAM_START_ADDRESS 0x10000200L #define SECTOR_SIZE 4096 -#define FLASH_WRITING_SIZE 1024 // This value should be 256, 512, 1024 or 4096 +//#define FLASH_WRITING_SIZE 1024 // This value should be 256, 512, 1024 or 4096 +#define FLASH_WRITING_SIZE 256 // This value should be 256, 512, 1024 or 4096 #define LINES_PER_TRANSFER (((FLASH_WRITING_SIZE / 45) + 3) & ~0x3) #define TRANSFER_SIZE (LINES_PER_TRANSFER * 45) @@ -245,11 +247,12 @@ int main() { - FILE *fp; - char str_buf0[ STR_BUFF_SIZE ]; - char str_buf1[ STR_BUFF_SIZE ]; - int data_size; - int last_sector; + FILE *fp; + char str_buf0[ STR_BUFF_SIZE ]; + char str_buf1[ STR_BUFF_SIZE ]; + int data_size; + int last_sector; + target_param *tpp; target.baud( BAUD_RATE ); @@ -281,6 +284,12 @@ get_string( str_buf0 ); printf( " result of \"J\" = %s\r\n", str_buf0 ); + tpp = find_target_param( str_buf0 ); + printf( "target device found : type = \"%s\"\r\n", tpp->type_name ); + printf( " ID = 0x%08X\r\n", tpp->id ); + printf( " RAM size = %7d bytes\r\n", tpp->ram_size ); + printf( " flash size = %7d bytes\r\n", tpp->flash_size ); + erase_sectors( last_sector ); write_binary_data( fp );
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/target_table.cpp Sun Aug 25 01:49:08 2013 +0000 @@ -0,0 +1,28 @@ +#include "mbed.h" +#include "target_table.h" + +target_param target_table[] = { + { "unknown ttarget", 0xFFFFFFFF, 1024, 4096 }, + { "LPC1114FN28(FDH28)/102", 0x0A40902B, 4096, 32768 }, + { "LPC1114FN28(FDH28)/102", 0x1A40902B, 4096, 32768 }, + { "LPC810M021FN8", 0x00008100, 1024, 4096 }, + { "LPC811M001JDH16", 0x00008110, 2048, 8192 }, + { "LPC812M101JDH16", 0x00008120, 4096, 16384 }, + { "LPC812M101JD20", 0x00008121, 4096, 16384 }, + { "LPC812M101JDH20", 0x00008122, 4096, 16384 }, +}; + +target_param *find_target_param( char *device_id_string ) +{ + int id; + + id = atoi( device_id_string ); + + for ( int i = 1; i < (sizeof( target_table ) / sizeof( target_param )); i++ ) + { + if ( id == target_table[ i ].id ) + return ( &(target_table[ i ]) ); + } + + return ( target_table ); +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/target_table.h Sun Aug 25 01:49:08 2013 +0000 @@ -0,0 +1,16 @@ + +#define NOT_FOUND 0 + + +typedef struct taget_param_st { + char *type_name; + int id; + int ram_size; + int flash_size; +} +target_param; + +extern target_param target_table[]; + +target_param *find_target_param( char *device_id_string ); +