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