Subversion Repositories svnkaklik

Rev

Rev 470 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log

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