Logo Search packages:      
Sourcecode: s51dude version File versions  Download package

uint8_t Checksum_IHexRecord ( const IHexRecord  ihexRecord  ) 

Calculates the checksum of an Intel HEX IHexRecord structure. See the Intel HEX specifications for more details on the checksum calculation.

ihexRecord The Intel HEX record structure that the checksum will be calculated of.
The 8-bit checksum.

Definition at line 144 of file ihex.c.

References _IHexRecord::address, _IHexRecord::data, _IHexRecord::dataLen, and _IHexRecord::type.

      uint8_t checksum;
      int i;

      /* Add the data count, type, address, and data bytes together */
      checksum = ihexRecord.dataLen;
      checksum += ihexRecord.type;
      checksum += (uint8_t)ihexRecord.address;
      checksum += (uint8_t)((ihexRecord.address & 0xFF00)>>8);
      for (i = 0; i < ihexRecord.dataLen; i++)
            checksum += ihexRecord.data[i];
      /* Two's complement on checksum */
      checksum = ~checksum + 1;

      return checksum;

Generated by  Doxygen 1.6.0   Back to index