Rev Author Line No. Line
1944 kaklik 1  
2 void onewire_reset()
3 {
4 output_low(ONE_WIRE_PIN);
5 delay_us(500);
6 output_float(ONE_WIRE_PIN);
7 delay_us(500);
8 output_float(ONE_WIRE_PIN);
9 }
10  
11  
12 void onewire_write(int data)
13 {
14 int count;
15  
16 for (count=0; count<8; ++count)
17 {
18 output_low(ONE_WIRE_PIN);
19 delay_us( 2 );
20 output_bit(ONE_WIRE_PIN, shift_right(&data,1,1));
21  
22 delay_us( 60 );
23 output_float(ONE_WIRE_PIN);
24 delay_us( 2 );
25 }
26 }
27  
28  
29 int onewire_read()
30 {
31 int count, data;
32  
33 for (count=0; count<8; ++count)
34 {
35 output_low(ONE_WIRE_PIN);
36 delay_us( 2 );
37 output_float(ONE_WIRE_PIN);
38 delay_us( 8 );
39 shift_right(&data,1,input(ONE_WIRE_PIN));
40 delay_us( 120 );
41 }
42 return( data );
43 }