Subversion Repositories svnkaklik

Rev

Details | Last modification | View Log

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