| PDM-IR SDK 3.0.2 PDM-IR SDK

common.h
1 #pragma once
2
3 #define SERIAL_VERSION 0x01 //3 bits
4 #define SERIAL_ID 0x04 //5 bits
5 #define SERIAL_HEAD ((SERIAL_ID<<3) | (SERIAL_VERSION))
6
7 #define SERIALCOM_ERR 0x18
8 #define SERIALCOM_OK 0x20
9
10 #define MAX_FTDI_MANAGED 16
11
12 #define AMPLI_MAX_GATED_mV 8000
13 #define AMPLI_MAX_FR_mV 5000
14 #define AMPLI_MIN_mV 2000
15
16 #define HOLD_OFF_MIN 1000
17 #define HOLD_OFF_MAX 100000000
18
19 #define FREQ_MIN 100
20 #define FREQ_MAX 100000000
21
22 #define TON_MIN 1000
23 #define TON_MAX 100000000000
24
25 #define TRIGGER_TH_MAX 2000
26 #define TRIGGER_TH_MIN -2000
27
28 #define DELAY_MIN 0
29 #define DELAY_MAX 100
30
31 #define INT_TIME_MIN 10
32 #define INT_TIME_MAX 60000
33
34 typedef enum {
35 PDM_COMMAND_SetAmpiTemp = 1,
36 PDM_COMMAND_SetHoldOff = 2,
37 PDM_COMMAND_SetGateMode = 3,
38 PDM_COMMAND_SetGateShape = 4,
39 PDM_COMMAND_SetTriggerInEdge = 5,
40 PDM_COMMAND_SetTriggerInTh = 6,
41 PDM_COMMAND_SetTriggerAuxEdge = 7,
42 PDM_COMMAND_SetTriggerAuxTh = 8,
43 PDM_COMMAND_SetTriggerFunction = 9,
44 PDM_COMMAND_SetFrequency = 10,
45 PDM_COMMAND_SetTon = 11,
46 PDM_COMMAND_SetTonFrequency = 12,
47 PDM_COMMAND_SetTtlOut = 13,
48 PDM_COMMAND_SetNimOut = 14,
49 PDM_COMMAND_SetDelayTriggerIn = 15,
50 PDM_COMMAND_SetDelayTriggerInternal = 16,
51 PDM_COMMAND_SetDelayTriggerAux = 17,
52 PDM_COMMAND_SetDelayGate = 18,
53 PDM_COMMAND_SetDelayNimOut = 19,
54 PDM_COMMAND_SetDelayTtlOut = 20,
55 PDM_COMMAND_SetCounterIntTime = 21,
56 PDM_COMMAND_SetCounter1Enable = 22,
57 PDM_COMMAND_SetCounter2Enable = 23,
58 PDM_COMMAND_SetCounter3Enable = 24,
59 PDM_COMMAND_SetModuleOnOff = 25,
60
61 PDM_COMMAND_GetAmpi = 64, //datalength = 2 bytes
62 PDM_COMMAND_GetTemp = 65, //datalength = 1 byte
63 PDM_COMMAND_GetHoldOff = 66, //datalength = 4 bytes
64 PDM_COMMAND_GetGateMode = 67, //datalength = 1 byte
65 PDM_COMMAND_GetGateShape = 68, //datalength = 1 byte
66 PDM_COMMAND_GetTriggerInEdge = 69, //datalength = 1 byte
67 PDM_COMMAND_GetTriggerInTh = 70, //datalength = 2 bytes
68 PDM_COMMAND_GetTriggerAuxEdge = 71, //datalength = 1 byte
69 PDM_COMMAND_GetTriggerAuxTh = 72, //datalength = 2 bytes
70 PDM_COMMAND_GetTriggerFunction = 73, //datalength = 1 byte
71 PDM_COMMAND_GetFrequency = 74, //datalength = 4 bytes
72 PDM_COMMAND_GetTon = 75, //datalength = 4 bytes
73 PDM_COMMAND_GetTtlOut = 77, //datalength = 1 byte
74 PDM_COMMAND_GetNimOut = 78, //datalength = 1 byte
75 PDM_COMMAND_GetDelayTriggerIn = 79, //datalength = 1 byte
76 PDM_COMMAND_GetDelayTriggerInternal = 80, //datalength = 1 byte
77 PDM_COMMAND_GetDelayTriggerAux = 81, //datalength = 1 byte
78 PDM_COMMAND_GetDelayGate = 82, //datalength = 1 byte
79 PDM_COMMAND_GetDelayNimOut = 83, //datalength = 1 byte
80 PDM_COMMAND_GetDelayTtlOut = 84, //datalength = 1 byte
81 PDM_COMMAND_GetCounterIntTime = 85, //datalength = 1 byte
82 PDM_COMMAND_GetCounter1Enable = 86, //datalength = 1 byte
83 PDM_COMMAND_GetCounter2Enable = 87, //datalength = 1 byte
84 PDM_COMMAND_GetCounter3Enable = 88, //datalength = 1 byte
85 PDM_COMMAND_GetCounter1Value = 89, //datalength = 5 bytes
86 PDM_COMMAND_GetCounter2Value = 90, //datalength = 5 bytes
87 PDM_COMMAND_GetCounter3Value = 91, //datalength = 5 bytes
88 PDM_COMMAND_GetCounter1ValueAtIter = 92, //datalength = 5 bytes
89 PDM_COMMAND_GetCounter2ValueAtIter = 93, //datalength = 5 bytes
90 PDM_COMMAND_GetCounter3ValueAtIter = 94, //datalength = 5 bytes
91 PDM_COMMAND_GetCurrentConfigPart1 = 95, //Ampi+Temp+HO+GM+GS+TrInEdge+TrInTh+TrAuxEdge+TrAuxTh=2+1+4+4+1+1+1+2+1+2 = 19 bytes
92 PDM_COMMAND_GetCurrentConfigPart2 = 96, //TriggerFunction+Freq+Ton+TtlOut+NimOut+DelayTriggerIn+DelayTriggerInternal+DelayTriggerAux+DelayGate+DelayNimOut+DelayTtlOut=1+4+4+1+1+1+1+1+1+1+1=17bites
93 PDM_COMMAND_GetModuleConfigCounters = 97, //CounterIntegrationTime+Counter1Status+Counter2Status+Counter3Status = 2+1+1+1 = 5 bytes
94 PDM_COMMAND_GetModuleInfoSN = 98, //1 byte
95 PDM_COMMAND_GetModuleInfoSPADType = 99, //1 byte
96 PDM_COMMAND_GetModuleInfoSPADName = 100, //20 bytes
97 PDM_COMMAND_GetModuleInfoFpgaHWver = 101, //15 bytes
98 PDM_COMMAND_GetModuleInfoFpgaSWver = 102, //15 bytes
99 PDM_COMMAND_GetModuleInfoMCUHWver = 103, //15 bytes
100 PDM_COMMAND_GetModuleInfoMCUSWver = 104, //15 bytes
101 PDM_COMMAND_GetModuleStatus = 105, // Temperature+StatusBitModule+StatusBitTEC+StatusBitVpol+StatusBitAmpi+StatusBitGate+ErrorStatus = 3+1+1+1+1+1+3 = 11 bytes
102 PDM_COMMAND_GetPowerVoltages = 106, // ADC3V3CMOS+ADC3V3+ADC4V+ADC5V+ADC5VTEC+ADC11V+ADC5Vneg+ADCVpol_code+ADCAmpi_code = 2+2+2+2+2+2+2+4+2 = 20 bytes
103 PDM_COMMAND_GetModuleConfigXPart1 = 107, //Ampi+Temp+HO+GM+GS+TrInEdge+TrInTh+TrAuxEdge+TrAuxTh=2+1+4+4+1+1+1+2+1+2 = 19 bytes
104 PDM_COMMAND_GetModuleConfigXPart2 = 108, //TriggerFunction+Freq+Ton+TtlOut+NimOut+DelayTriggerIn+DelayTriggerInternal+DelayTriggerAux+DelayGate+DelayNimOut+DelayTtlOut=1+4+4+1+1+1+1+1+1+1+1=17bites PDM_COMMAND_GetMappingArrayAtPos = 245,
105 } PDM_COMMAND;
106
107 static int SendCommandLength[128] = {
108 255,
109 4,
110 4,
111 2,
112 2,
113 2,
114 3,
115 2,
116 3,
117 2,
118 5,
119 5,
120 9,
121 2,
122 2,
123 2,
124 2,
125 2,
126 2,
127 2,
128 2,
129 5,
130 2,
131 2,
132 2,
133 2,
134 255,255,255,255,255,255,255,255,255,
135 255,255,255,255,255,255,255,255,255,255,
136 255,255,255,255,255,255,255,255,255,255,
137 255,255,255,255,255,255,255,255,255, //up to 63 no commands
138 1,1,1,1,1,1,1,1,1,1,
139 1,1,255,1,1,1,1,1,1,1,
140 1,1,1,1,1,1,1,1,2,2,
141 2,1,1,1,1,1,1,1,1,1,1,1,1,//from 64 to 106 only CKSUM bytes, 76 no command
142 2,
143 2,
144 255,255,255,255,255,255,255,255,255,
145 255,255,255,255,255,255,255,255,255,255 //from 107 to 127 no commands
146 };
147
148
149 static int ReceivedCommandLength[127] = {
150 255,
151 3,
152 3,
153 3,
154 3,
155 3,
156 3,
157 3,
158 3,
159 3,
160 3,
161 3,
162 3,
163 3,
164 3,
165 3,
166 3,
167 3,
168 3,
169 3,
170 3,
171 3,
172 3,
173 3,
174 3,
175 3,
176 255,255,255,255,255,255,255,255,255,
177 255,255,255,255,255,255,255,255,255,255,
178 255,255,255,255,255,255,255,255,255,255,
179 255,255,255,255,255,255,255,255,255, //up to 63 no commands
180
181 5,
182 4,
183 7,
184 4,
185 4,
186 4,
187 5,
188 4,
189 5,
190 4,
191 7,
192 7,
193 4,
194 4,
195 4,
196 4,
197 4,
198 4,
199 4,
200 4,
201 4,
202 4,
203 4,
204 4,
205 8,
206 8,
207 8,
208 8,
209 8,
210 8,
211 22,
212 20,
213 10,
214 4,
215 4,
216 23,
217 18,
218 18,
219 18,
220 18,
221 14,
222 23,
223 22,
224 19,
225 255,255,255,255,255,255,255,255,255,
226 255,255,255,255,255,255,255,255,255,255 //from 109 to 127 no commands
227 };