Add to 11U68 11E68
Dependencies: DirectoryList MODSERIAL mbed
Fork of ika_shouyu_poppoyaki by
Diff: isp.cpp
- Revision:
- 32:3700d5df4e18
- Parent:
- 30:e0d7524661ca
- Child:
- 33:ce9fff4cbf09
--- 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 );