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_table.cpp@51:981107d4e84f, 2015-07-05 (annotated)
- Committer:
- okano
- Date:
- Sun Jul 05 01:41:12 2015 +0000
- Revision:
- 51:981107d4e84f
- Parent:
- 50:57ad8e04f063
- Child:
- 52:afd15e54142f
comment added; indent adjusted
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
okano | 5:ff30f5b58617 | 1 | #include "mbed.h" |
okano | 5:ff30f5b58617 | 2 | #include "target_table.h" |
okano | 5:ff30f5b58617 | 3 | |
okano | 44:568799eac6df | 4 | #define SECTOR_SIZE_VALIABLE4Kx16_AND_32KxN 1 |
Hapi_Tech | 50:57ad8e04f063 | 5 | #define SECTOR_SIZE_VALIABLE4Kx24_AND_32KxN 2 |
okano | 51:981107d4e84f | 6 | |
okano | 5:ff30f5b58617 | 7 | target_param target_table[] = { |
okano | 12:5a33b5d39792 | 8 | { "unknown ttarget", 0xFFFFFFFF, 1024, 4096, 4096, UUENCODE, 0x10000200 }, |
okano | 12:5a33b5d39792 | 9 | { "LPC1114FN28(FDH28)/102", 0x0A40902B, 4096, 32768, 4096, UUENCODE, 0x10000200 }, |
okano | 12:5a33b5d39792 | 10 | { "LPC1114FN28(FDH28)/102", 0x1A40902B, 4096, 32768, 4096, UUENCODE, 0x10000200 }, |
okano | 12:5a33b5d39792 | 11 | { "LPC810M021FN8", 0x00008100, 1024, 4096, 1024, BINARY, 0x10000300 }, |
okano | 12:5a33b5d39792 | 12 | { "LPC811M001JDH16", 0x00008110, 2048, 8192, 1024, BINARY, 0x10000300 }, |
okano | 12:5a33b5d39792 | 13 | { "LPC812M101JDH16", 0x00008120, 4096, 16384, 1024, BINARY, 0x10000300 }, |
okano | 12:5a33b5d39792 | 14 | { "LPC812M101JD20", 0x00008121, 4096, 16384, 1024, BINARY, 0x10000300 }, |
okano | 12:5a33b5d39792 | 15 | { "LPC812M101JDH20", 0x00008122, 4096, 16384, 1024, BINARY, 0x10000300 }, |
k4zuki | 42:2b40666d8177 | 16 | ///added for LPC82x series |
k4zuki | 42:2b40666d8177 | 17 | { "LPC824M201JHI33", 0x00008241, 8192, 32768, 1024, BINARY, 0x10000300 }, |
k4zuki | 42:2b40666d8177 | 18 | { "LPC822M101JHI33", 0x00008221, 4096, 16384, 1024, BINARY, 0x10000300 }, |
k4zuki | 42:2b40666d8177 | 19 | { "LPC824M201JDH20", 0x00008242, 8192, 32768, 1024, BINARY, 0x10000300 }, |
k4zuki | 42:2b40666d8177 | 20 | { "LPC822M101JDH20", 0x00008222, 4096, 16384, 1024, BINARY, 0x10000300 }, |
okano | 44:568799eac6df | 21 | ///added for LPC176x series |
okano | 44:568799eac6df | 22 | { "LPC1769FBD100", 0x26113F37, 65536, 524288, SECTOR_SIZE_VALIABLE4Kx16_AND_32KxN, UUENCODE, 0x10000200 }, |
okano | 44:568799eac6df | 23 | { "LPC1768FBD100", 0x26013F37, 65536, 524288, SECTOR_SIZE_VALIABLE4Kx16_AND_32KxN, UUENCODE, 0x10000200 }, |
Hapi_Tech | 50:57ad8e04f063 | 24 | ///added for LPC11U(E)68x series |
Hapi_Tech | 50:57ad8e04f063 | 25 | { "LPC11U68JBD100", 0x00007C00, 36864, 262144, SECTOR_SIZE_VALIABLE4Kx24_AND_32KxN, UUENCODE, 0x10000300 }, |
Hapi_Tech | 50:57ad8e04f063 | 26 | { "LPC11E68JBD100", 0x00007C01, 36864, 262144, SECTOR_SIZE_VALIABLE4Kx24_AND_32KxN, UUENCODE, 0x10000300 }, |
okano | 5:ff30f5b58617 | 27 | }; |
okano | 5:ff30f5b58617 | 28 | |
okano | 5:ff30f5b58617 | 29 | target_param *find_target_param( char *device_id_string ) |
okano | 5:ff30f5b58617 | 30 | { |
okano | 5:ff30f5b58617 | 31 | int id; |
okano | 44:568799eac6df | 32 | |
okano | 5:ff30f5b58617 | 33 | id = atoi( device_id_string ); |
okano | 44:568799eac6df | 34 | |
okano | 44:568799eac6df | 35 | for ( int i = 1; i < (sizeof( target_table ) / sizeof( target_param )); i++ ) { |
okano | 5:ff30f5b58617 | 36 | if ( id == target_table[ i ].id ) |
okano | 5:ff30f5b58617 | 37 | return ( &(target_table[ i ]) ); |
okano | 5:ff30f5b58617 | 38 | } |
okano | 44:568799eac6df | 39 | |
okano | 28:689c3880e0e4 | 40 | // return ( target_table ); |
okano | 28:689c3880e0e4 | 41 | return ( NULL ); |
okano | 5:ff30f5b58617 | 42 | } |
okano | 26:a63e73885b21 | 43 | |
okano | 44:568799eac6df | 44 | int find_sector( int data_size, target_param *tpp ) |
okano | 44:568799eac6df | 45 | { |
okano | 51:981107d4e84f | 46 | int result; |
okano | 51:981107d4e84f | 47 | |
okano | 44:568799eac6df | 48 | switch ( tpp->sector_size ) { |
okano | 44:568799eac6df | 49 | case SECTOR_SIZE_VALIABLE4Kx16_AND_32KxN : |
okano | 44:568799eac6df | 50 | if ( data_size <= (4096 * 16) ) { |
okano | 51:981107d4e84f | 51 | result = ( data_size / 4096 ); |
okano | 44:568799eac6df | 52 | } else { |
okano | 44:568799eac6df | 53 | data_size -= (4096 * 16); |
okano | 51:981107d4e84f | 54 | result = ( (data_size / (4096 * 8)) + 16 ); |
okano | 44:568799eac6df | 55 | } |
Hapi_Tech | 50:57ad8e04f063 | 56 | break; |
Hapi_Tech | 50:57ad8e04f063 | 57 | case SECTOR_SIZE_VALIABLE4Kx24_AND_32KxN : |
Hapi_Tech | 50:57ad8e04f063 | 58 | if ( data_size <= (4096 * 24) ) { |
okano | 51:981107d4e84f | 59 | result = ( data_size / 4096 ); |
Hapi_Tech | 50:57ad8e04f063 | 60 | } else { |
Hapi_Tech | 50:57ad8e04f063 | 61 | data_size -= (4096 * 24); |
okano | 51:981107d4e84f | 62 | result = ( (data_size / (4096 * 12)) + 24 ); |
Hapi_Tech | 50:57ad8e04f063 | 63 | } |
okano | 51:981107d4e84f | 64 | break; |
okano | 51:981107d4e84f | 65 | |
okano | 51:981107d4e84f | 66 | |
okano | 44:568799eac6df | 67 | default : |
Hapi_Tech | 50:57ad8e04f063 | 68 | result = ( data_size / tpp->sector_size ); |
okano | 44:568799eac6df | 69 | //break; |
okano | 44:568799eac6df | 70 | } |
okano | 51:981107d4e84f | 71 | return (result); |
okano | 44:568799eac6df | 72 | } |
okano | 44:568799eac6df | 73 |