Line -... |
Line 1... |
- |
|
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; |
- |
|
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); |
7 |
|
21 |
|
8 |
onewire_reset(); |
- |
|
9 |
onewire_write(0xCC); |
- |
|
10 |
onewire_write(0x44); |
22 |
result = (float) temp3 / 16.0; //calculation pro DS18B20 with 0.1 deg C |
11 |
|
23 |
|
12 |
while (busy == 0) |
- |
|
13 |
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 |
|
- |
|
25 |
delay_ms(200); |
- |
|
26 |
return(result); |
24 |
return(result); |
27 |
|
- |
|
28 |
} |
25 |
} |