// This function assumes the read in data of the DS1820 to be present in parameter Buff[0..8]. // Returns 0 if the contents of "Buff" gives a correct CRC. function DS1820_CheckCRC: byte; var I, J: byte; TmpBit: boolean; begin Result := 0; // temporary CRC for I := 0 to 8 do // for each byte begin Result := Result xor __DS1820Buffer[I]; for J := 0 to 7 do // for each bit begin if Result.0 = 1 then Result := (Result shr 1) xor $8c else Result := Result shr 1; end; end; end; function DS1820_CheckCRCRomCode(var RomCode: array[8] of byte): byte; var I, J: byte; TmpBit: boolean; begin Result := 0; // temporary CRC for I := 0 to 7 do // for each byte begin Result := Result xor RomCode[I]; for J := 0 to 7 do // for each bit begin if Result.0 = 1 then Result := (Result shr 1) xor $8c else Result := Result shr 1; end; end; end;