1744 |
kakl |
1 |
void TDC_init() |
|
|
2 |
{ |
1745 |
kakl |
3 |
output_low(TDC_ENABLE); |
1744 |
kakl |
4 |
spi_xfer(TDC_stream,0x70); |
1745 |
kakl |
5 |
output_high(TDC_ENABLE); |
1744 |
kakl |
6 |
} |
|
|
7 |
|
|
|
8 |
void TDC_reset() |
|
|
9 |
{ |
1745 |
kakl |
10 |
output_low(TDC_ENABLE); |
1744 |
kakl |
11 |
spi_xfer(TDC_stream,0x50); |
1745 |
kakl |
12 |
output_high(TDC_ENABLE); |
1744 |
kakl |
13 |
} |
|
|
14 |
|
|
|
15 |
void TDC_start_cycle() |
|
|
16 |
{ |
1745 |
kakl |
17 |
output_low(TDC_ENABLE); |
1744 |
kakl |
18 |
spi_xfer(TDC_stream,0x01); |
1745 |
kakl |
19 |
output_high(TDC_ENABLE); |
1744 |
kakl |
20 |
} |
|
|
21 |
|
|
|
22 |
void TDC_start_temp() |
|
|
23 |
{ |
1745 |
kakl |
24 |
output_low(TDC_ENABLE); |
1744 |
kakl |
25 |
spi_xfer(TDC_stream,0x02); |
1745 |
kakl |
26 |
output_high(TDC_ENABLE); |
1744 |
kakl |
27 |
} |
|
|
28 |
|
|
|
29 |
void TDC_start_cal_resonator() |
|
|
30 |
{ |
1745 |
kakl |
31 |
output_low(TDC_ENABLE); |
1744 |
kakl |
32 |
spi_xfer(TDC_stream,0x03); |
1745 |
kakl |
33 |
output_high(TDC_ENABLE); |
1744 |
kakl |
34 |
} |
|
|
35 |
|
|
|
36 |
void TDC_start_cal() |
|
|
37 |
{ |
1745 |
kakl |
38 |
output_low(TDC_ENABLE); |
1744 |
kakl |
39 |
spi_xfer(TDC_stream,0x04); |
1745 |
kakl |
40 |
output_high(TDC_ENABLE); |
1744 |
kakl |
41 |
} |
|
|
42 |
|
|
|
43 |
unsigned int32 TDC_get_measurement(int num) |
|
|
44 |
{ |
1745 |
kakl |
45 |
unsigned int32 ret; |
|
|
46 |
|
|
|
47 |
output_low(TDC_ENABLE); |
1744 |
kakl |
48 |
spi_xfer(TDC_stream,0xB0 + num - 1); |
1745 |
kakl |
49 |
ret=spi_xfer(TDC_stream,0,32); |
|
|
50 |
output_high(TDC_ENABLE); |
|
|
51 |
return ret; |
1744 |
kakl |
52 |
} |
|
|
53 |
|
|
|
54 |
unsigned int16 TDC_get_status() |
|
|
55 |
{ |
1745 |
kakl |
56 |
unsigned int16 ret; |
|
|
57 |
|
|
|
58 |
output_low(TDC_ENABLE); |
|
|
59 |
spi_xfer(TDC_stream,0xB4,8); |
|
|
60 |
ret=spi_xfer(TDC_stream,0,16); |
|
|
61 |
output_high(TDC_ENABLE); |
|
|
62 |
return ret; |
1744 |
kakl |
63 |
} |
|
|
64 |
|
|
|
65 |
unsigned int8 TDC_get_reg1() |
|
|
66 |
{ |
1745 |
kakl |
67 |
unsigned int8 ret; |
|
|
68 |
|
|
|
69 |
output_low(TDC_ENABLE); |
|
|
70 |
spi_xfer(TDC_stream,0xB5,8); |
|
|
71 |
ret=spi_xfer(TDC_stream,0,8); |
|
|
72 |
output_high(TDC_ENABLE); |
|
|
73 |
return ret; |
1744 |
kakl |
74 |
} |
|
|
75 |
|
|
|
76 |
void TDC_setup_reg1() |
|
|
77 |
{ |
1745 |
kakl |
78 |
output_low(TDC_ENABLE); |
|
|
79 |
spi_xfer(TDC_stream,0x81,8); |
|
|
80 |
spi_xfer(TDC_stream,0x224000,24); |
|
|
81 |
output_high(TDC_ENABLE); |
1744 |
kakl |
82 |
|
1745 |
kakl |
83 |
output_low(TDC_ENABLE); |
1744 |
kakl |
84 |
spi_xfer(TDC_stream,0xB1); |
1745 |
kakl |
85 |
output_high(TDC_ENABLE); |
1744 |
kakl |
86 |
|
1745 |
kakl |
87 |
output_low(TDC_ENABLE); |
1744 |
kakl |
88 |
spi_xfer(TDC_stream,0xB2); |
1745 |
kakl |
89 |
output_high(TDC_ENABLE); |
1744 |
kakl |
90 |
|
1745 |
kakl |
91 |
output_low(TDC_ENABLE); |
1744 |
kakl |
92 |
spi_xfer(TDC_stream,0xB3); |
1745 |
kakl |
93 |
output_high(TDC_ENABLE); |
1744 |
kakl |
94 |
|
1745 |
kakl |
95 |
output_low(TDC_ENABLE); |
1744 |
kakl |
96 |
spi_xfer(TDC_stream,0xB4); |
1745 |
kakl |
97 |
output_high(TDC_ENABLE); |
1744 |
kakl |
98 |
} |