/Designs/Measuring_instruments/AWS01A/SW/ds1820.c
35,7 → 35,7
 
float ds1820_read()
{
unsigned int1 busy=0;
unsigned int1 ready=0;
int8 SN[10];
unsigned int8 n;
float result;
44,7 → 44,12
onewire_write(0xCC);
onewire_write(0x44);
 
while (busy == 0) busy = onewire_read();
for(n=0;n<200;n++) // wait until sensor is busy or timeout will be over
{
ready = onewire_read();
if(ready == TRUE) break;
delay_ms(1);
}
 
onewire_reset();
onewire_write(0xCC);
58,7 → 63,7
}
else
{
result=-273.15;
result=-27315;
}
return(result);
}