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