Ika Shouyu Poppoyaki - LPC82x supported
Fork of ika_shouyu_poppoyaki by
Revision 32:3700d5df4e18, committed 2013-09-24
- Comitter:
- okano
- Date:
- Tue Sep 24 21:35:25 2013 +0000
- Parent:
- 31:1a4d59d7bd72
- Child:
- 33:ce9fff4cbf09
- Commit message:
- CRP checking code added (not tested yet)
Changed in this revision
isp.cpp | Show annotated file Show diff for this revision Revisions of this file |
isp.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/isp.cpp Fri Sep 20 02:26:57 2013 +0000 +++ b/isp.cpp Tue Sep 24 21:35:25 2013 +0000 @@ -15,8 +15,9 @@ Ticker success; -int file_size( FILE *fp ); -void success_indicator(); +int file_size( FILE *fp ); +unsigned int crp_check( FILE *fp ); +void success_indicator(); int isp_flash_write( char *file_name ) { @@ -44,6 +45,11 @@ data_size = file_size( fp ); last_sector = data_size / tpp->sector_size; + + if ( crp_check( fp ) ) + { + // warn CRP + } printf( " data size = %d bytes, it takes %d secotrs in flash area\r\n", data_size, last_sector + 1 ); printf( " resetting target\r\n" ); @@ -86,6 +92,32 @@ } +unsigned int crp_check( FILE *fp ) +{ + unsigned int crp; + + fseek( fp, 0x2FC, SEEK_SET ); // seek back to beginning of file + + if ( 1 != fread( &crp, sizeof( crp ), 1, fp ) ) + return ( CRP_CHECK_ERROR ); + + fseek( fp, 0, SEEK_SET ); // seek back to beginning of file + + switch ( crp ) { + case NO_ISP : + case CRP1 : + case CRP2 : + case CRP3 : + /* do nothing */ + break; + default : + crp = 0x0; + } + + return ( crp ); +} + + void start_target_in_normal_mode( int baud_rate ) { set_target_baud_rate( baud_rate );
--- a/isp.h Fri Sep 20 02:26:57 2013 +0000 +++ b/isp.h Tue Sep 24 21:35:25 2013 +0000 @@ -29,5 +29,14 @@ }; +enum { + NO_ISP = 0x4E697370, + CRP1 = 0x12345678, + CRP2 = 0x87654321, + CRP3 = 0x43218765, + CRP_CHECK_ERROR = 0xFFFFFFFF +}; + + #endif // MBED_ISP__ISP__