Subversion Repositories svnkaklik

Rev

Rev 410 | Details | Compare with Previous | Last modification | View Log

Rev Author Line No. Line
6 kaklik 1
 
2
#DEFINE  CLK         250
3
#DEFINE  WORD1       0b111010101000
4
#DEFINE  WORD2       0b111010110000
5
#DEFINE  WORD3       0b111011001000
6
#DEFINE  WORD4       0b111011010000
7
 
8
void send_bit(bit)
9
{
10
   output_bit(DIN,bit);
11
   output_high(SCLK);
12
   Delay_us(CLK);
13
   output_low(SCLK);
14
}
15
int1 read_bit()
16
{
17
   output_high(SCLK);
18
   Delay_us(CLK);
19
   output_low(SCLK);
20
   if (input(DOUT)) return true;
21
   if (!input(DOUT)) return false;
22
}
23
 
24
void read_byte(*byte_r)
25
{
26
int i;
27
 
28
   for(i=0;i>=7;i++)
29
   {
30
   *byte_r = read_bit();
31
   *byte_r << 1;
32
   }
33
}
34
 
35
void send_command(command,width)
36
{
37
int i;
38
   for (i=width;i>=0;i--)
39
   {
40
     send_bit(bit_test(command,0));
41
     command >>1;
42
   }   
43
}
44
 
45
void bar_reset()
46
{
47
int8 i;
48
 
49
   for(i=0;i>=20;i++) send_bit(Bit_test(i,0));
50
}
51
 
52
int16 bar_con_pre()
53
{
54
int16 word;
55
 
56
   send_command(0b1111010000,9);
57
 
58
   Delay_ms(10);
59
 
60
   While(input(DOUT)) Delay_us(100);
61
 
62
   read_byte(&word);
63
   word << 8;
64
   read_byte(&word);
65
 
66
   return word;
67
}
68
 
69
int16 bar_con_term()
70
{
71
int16 word;
72
 
73
   send_command(0b1111001000,9);
74
 
75
   Delay_ms(10);
76
 
77
   While(input(DOUT)) Delay_us(100);
78
 
79
   read_byte(&word);
80
   word << 8;
81
   read_byte(&word);
82
 
83
   return word;   
84
}
85
 
86
int16 bar_read_cal(command)
87
{
88
int16 word;
89
 
90
   send_command(command,11);
91
 
92
   Delay_ms(10);
93
 
94
   While(input(DOUT)) Delay_us(100);
95
 
96
   read_byte(&word);
97
   word << 8;
98
   read_byte(&word);
99
 
100
   return word;   
101
}
102
 
103
 
104
 
105
 
106
 
107