/Designs/Measuring_instruments/AWS01A/SW/ds1820.c
3,7 → 3,8
// compute CRC
// *sn - pointer to the byte array
// num - length of array
inline int8 TM_check_CRC(unsigned int8 *sn, unsigned int8 num)
 
int8 TM_check_CRC(unsigned int8 *sn, unsigned int8 num)
{
// CRC table
const int8 TouchCRC[256]= {
56,7 → 57,8
onewire_write(0xBE);
 
for(n=0;n<9;n++) SN[n]=onewire_read();
if ((SN[8]==TM_check_CRC(SN,8))&&(SN[7]==0x10)) // Check CRC and family code to prevent O's error
// if ((SN[8]==TM_check_CRC(SN,8))&&(SN[7]==0x10)) // Check CRC and family code to prevent O's error
if ((SN[7]==0x10)) // Check CRC and family code to prevent O's error
{
result=make16(SN[1],SN[0]);
result=result*6+result/4; // 1bit = 0,0625gradC recalculate to 1/100gradC