File tree Expand file tree Collapse file tree 2 files changed +7
-2
lines changed Expand file tree Collapse file tree 2 files changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -63,7 +63,7 @@ uint8_t ihx_check_line(char line[]) {
6363 if (byte_count > IHX_MAX_LEN )
6464 return IHX_RECORD_TOO_LONG ;
6565
66- checksum = hex8 ( & line [ 9 + 2 * byte_count ] );
66+ checksum = ihx_data_byte ( line , byte_count );
6767
6868 if (record_type > 1 )
6969 return IHX_BAD_RECORD_TYPE ;
@@ -87,6 +87,10 @@ uint8_t ihx_record_type(char line[]) {
8787 return hex8 (& line [7 ]);
8888}
8989
90+ uint8_t ihx_data_byte (char line [], uint8_t n ) {
91+ return hex8 (& line [9 + n * 2 ]);
92+ }
93+
9094void ihx_readline (char line []) {
9195 char c ;
9296 uint8_t len ;
@@ -117,7 +121,7 @@ void ihx_write(char line[]) {
117121 case IHX_RECORD_DATA :
118122 buff [0 ] = 0xFF ; // Padding in case the flash start address is not even.
119123 for (i = 0 ; i < byte_count ; i ++ )
120- buff [i + 1 ] = hex8 ( & line [ 9 + i * 2 ] );
124+ buff [i + 1 ] = ihx_data_byte ( line , i );
121125 buff [byte_count + 1 ] = 0xFF ; // If there are not an even no. of bytes, pad with 0xFF to preserve flash.
122126
123127 if (address & 1 ) {
Original file line number Diff line number Diff line change @@ -42,5 +42,6 @@ uint8_t ihx_check_line(char line[]);
4242void ihx_readline (char line []);
4343void ihx_write (char line []);
4444uint8_t ihx_record_type (char line []);
45+ uint8_t ihx_data_byte (char line [], uint8_t n );
4546
4647#endif // _INTEL_HEX_H_
You can’t perform that action at this time.
0 commit comments