Subversion Repositories svnkaklik

Rev

Go to most recent revision | 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
output_low(ONE_WIRE_PIN);
482 kaklik 6
delay_us(240);
470 kaklik 7
output_float(ONE_WIRE_PIN);
482 kaklik 8
delay_us(150);
470 kaklik 9
output_float(ONE_WIRE_PIN);
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
 
482 kaklik 22
   delay_us( 40 );
470 kaklik 23
   output_float(ONE_WIRE_PIN);
24
   delay_us( 2 );
25
}
26
}
27
 
28
int onewire_read()
29
{
30
int count, data;
31
 
32
for (count=0; count<8; ++count)
33
{
34
output_low(ONE_WIRE_PIN);
35
delay_us( 2 );
36
output_float(ONE_WIRE_PIN);
37
delay_us( 8 );
38
shift_right(&data,1,input(ONE_WIRE_PIN));
482 kaklik 39
    delay_us(5);
470 kaklik 40
}
41
 
42
return( data );
43
}