1944 |
kaklik |
1 |
#include "1wire.c" |
|
|
2 |
|
|
|
3 |
float ds1820_read() |
|
|
4 |
{ |
|
|
5 |
int8 busy=0, temp1, temp2; |
|
|
6 |
signed int16 temp3; |
|
|
7 |
float result; |
|
|
8 |
|
|
|
9 |
onewire_reset(); |
|
|
10 |
onewire_write(0xCC); |
|
|
11 |
onewire_write(0x44); |
|
|
12 |
|
|
|
13 |
while (busy == 0) busy = onewire_read(); |
|
|
14 |
|
|
|
15 |
onewire_reset(); |
|
|
16 |
onewire_write(0xCC); |
|
|
17 |
onewire_write(0xBE); |
|
|
18 |
temp1 = onewire_read(); |
|
|
19 |
temp2 = onewire_read(); |
|
|
20 |
temp3 = make16(temp2, temp1); |
|
|
21 |
|
|
|
22 |
result = (float) temp3 / 16.0; //calculation pro DS18B20 with 0.1 deg C |
|
|
23 |
|
|
|
24 |
return(result); |
|
|
25 |
} |