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