Veethree D7 SDK
Loading...
Searching...
No Matches
analog_common.h
Go to the documentation of this file.
1
5#ifndef NAFE_COMMON_H
6#define NAFE_COMMON_H
7
8#include "io_common.h"
9
10#include <cstdint>
11#include <string>
12#include <vector>
13
17
18namespace vsdk::io::analog {
19
24
28static constexpr size_t max_virtual_channel_count = 16;
29
33enum viex_vi_t : uint8_t {
34 voltage = 0x0,
35 current = 0x1,
36};
37
43enum class gain_offset_coeff_pair_t : uint8_t {
59 one = 0x3,
63 two = 0x4,
67 four = 0x5,
71 eight = 0x6,
75 sixteen = 0x7,
76};
77
83enum class pga_gain_t : uint8_t {
84 zero_pt_two = 0x0,
85 zero_pt_four = 0x1,
86 zero_pt_eight = 0x2,
87 one = 0x3,
88 two = 0x4,
89 four = 0x5,
90 eight = 0x6,
91 sixteen = 0x7,
92};
93
97enum class hv_sel_t : uint8_t {
98 lvsig_in = 0x0,
99 hv_aip_hv_ain = 0x1,
100};
101
105enum class lv_sig_in_t : uint8_t {
106 ref_div_2_ref_div_2 = 0x0,
107 gpio0_gpio1 = 0x1,
108 ref_coarse_ref_div_2 = 0x2,
109 vadd_ref_div_2 = 0x3,
110 vhdd_ref_div_2 = 0x4,
111 ref_div_2_vhss = 0x5,
112};
113
117enum class hv_ain_t : uint8_t {
118 gnd = 0x0,
119 ai1n = 0x1,
120 ai2n = 0x2,
121 ai3n = 0x3,
122 ai4n = 0x4,
123 refh = 0x5,
124 refl = 0x6,
125 aicom = 0x7,
126};
127
131enum class hv_aip_t : uint8_t {
132 gnd = 0x0,
133 ai1p = 0x1,
134 ai2p = 0x2,
135 ai3p = 0x3,
136 ai4p = 0x4,
137 refh = 0x5,
138 refl = 0x6,
139 aicom = 0x7,
140};
141
145enum class pin_fn_t : uint8_t {
146 none,
147 reserved,
148 voltage,
149
150 resist_1_wr,
151 resist_2_wr,
152 resist_3_wr,
153 resist_4_wr,
154
155 thermocouple,
156
157 v_calib_h,
158 v_calib_l,
159 r_calib_common,
160 r_calib_unique,
161 rw_calib_unique,
162 cjc,
163 rref,
164};
165
169enum class pin_t : uint8_t {
170 none,
171 vrsns0,
172 vrsns1,
173 vrsns2,
174 vrsns3,
175 vrsns4,
176 vrsns5,
177 gpio0,
178 gpio1,
179 rref,
180};
181
185enum class sensor_t : uint8_t {
186 none,
187 thermocouple_type_b,
188 thermocouple_type_e,
189 thermocouple_type_j,
190 thermocouple_type_k,
191 thermocouple_type_n,
192 thermocouple_type_r,
193 thermocouple_type_s,
194 thermocouple_type_t,
195 voltage,
196 resist_1_wr,
197 resist_2_wr,
198 rtd_2_wr,
199 rtd_3_wr,
200 rtd_4_wr,
201};
202
206enum class thermocouple_t : uint8_t {
207 type_b,
208 type_e,
209 type_j,
210 type_k,
211 type_n,
212 type_r,
213 type_s,
214 type_t,
215};
216
220enum gpo_data_t : uint8_t {
224 none = 0x0,
228 vrsns0 = 0xE,
232 vrsns1 = 0xF,
236 vrsns2 = 0xC,
240 vrsns3 = 0xB,
244 vrsns4 = 0x9,
248 vrsns5 = 0x8,
252 rref = 0xA,
253};
254
326
330struct sensor {
334 std::string label;
335
340
344 std::vector<uint8_t> channels;
345};
346
347}; /* namespace vsdk::io::analog */
348
349namespace vsdk::io::analog::utility {
353constexpr const char *to_string(pin_t pin)
354{
355 switch (pin) {
356 case pin_t::none:
357 return "none";
358 case pin_t::vrsns0:
359 return "vrsns0";
360 case pin_t::vrsns1:
361 return "vrsns1";
362 case pin_t::vrsns2:
363 return "vrsns2";
364 case pin_t::vrsns3:
365 return "vrsns3";
366 case pin_t::vrsns4:
367 return "vrsns4";
368 case pin_t::vrsns5:
369 return "vrsns5";
370 case pin_t::gpio0:
371 return "gpio0";
372 case pin_t::gpio1:
373 return "gpio1";
374 case pin_t::rref:
375 return "rref";
376 default:
377 return "unknown";
378 }
379}
380
384constexpr const char *to_string(sensor_t sensor)
385{
386 switch (sensor) {
387 case sensor_t::none:
388 return "none";
389 case sensor_t::resist_1_wr:
390 return "resistance 1 wire";
391 case sensor_t::resist_2_wr:
392 return "resistance 2 wire";
393 case sensor_t::rtd_2_wr:
394 return "rtd 2 wire";
395 case sensor_t::rtd_3_wr:
396 return "rtd 3 wire";
397 case sensor_t::rtd_4_wr:
398 return "rtd 4 wire";
399 case sensor_t::thermocouple_type_b:
400 return "thermocouple type b";
401 case sensor_t::thermocouple_type_e:
402 return "thermocouple type e";
403 case sensor_t::thermocouple_type_j:
404 return "thermocouple type j";
405 case sensor_t::thermocouple_type_k:
406 return "thermocouple type k";
407 case sensor_t::thermocouple_type_n:
408 return "thermocouple type n";
409 case sensor_t::thermocouple_type_r:
410 return "thermocouple type r";
411 case sensor_t::thermocouple_type_s:
412 return "thermocouple type s";
413 case sensor_t::thermocouple_type_t:
414 return "thermocouple type k";
415 case sensor_t::voltage:
416 return "voltage";
417 default:
418 return "unknown";
419 }
420}
421
426constexpr double to_value(pga_gain_t gain)
427{
428 // NOLINTBEGIN(*-magic-numbers)
429 switch (gain) {
430 case pga_gain_t::zero_pt_two:
431 return 0.2;
432 case pga_gain_t::zero_pt_four:
433 return 0.4;
434 case pga_gain_t::zero_pt_eight:
435 return 0.8;
436 default:
437 return 0.0;
438 }
439 // NOLINTEND(*-magic-numbers)
440}
441
443
444} /* namespace vsdk::io::analog::utility */
445
446#endif /* NAFE_COMMON_H */
viex_vi_t excitation_source
Excitation source.
Definition analog_common.h:309
bool enable_vexc_routing
Enable vexc internal excitation routing.
Definition analog_common.h:319
hv_sel_t hv_sel
Value for CH_CONFIG0 -> HV_HV_SEL.
Definition analog_common.h:272
hv_aip_t
AIP Pin selection.
Definition analog_common.h:131
lv_sig_in_t lv_sig_in
Value for CH_CONFIG0 -> LVSIG_IN.
Definition analog_common.h:277
gpo_data_t gpo_data
GPO data register assignment for a given channel.
Definition analog_common.h:282
lv_sig_in_t
lv sig selection
Definition analog_common.h:105
constexpr const char * to_string(pin_t pin)
Definition analog_common.h:353
bool enable_ai1p_iexc
Enable excitation on AI1P.
Definition analog_common.h:314
hv_ain_t
AIN Pin selection.
Definition analog_common.h:117
constexpr double to_value(pga_gain_t gain)
Definition analog_common.h:426
hv_aip_t hv_aip
Value for CH_CONFIG0 -> HV_AIP.
Definition analog_common.h:267
pga_gain_t pga_gain
Definition analog_common.h:304
hv_sel_t
hv select
Definition analog_common.h:97
std::vector< uint8_t > channels
Define the virtual channels involved in the function.
Definition analog_common.h:344
pga_gain_t
Channel pga gain.
Definition analog_common.h:83
sensor_t
Supported sensor types.
Definition analog_common.h:185
uint16_t excitation_source_magnitude
Excitation source magnitude.
Definition analog_common.h:299
sensor_t sensor
What type of sensor is this?
Definition analog_common.h:339
thermocouple_t
Thermocouple type.
Definition analog_common.h:206
std::string label
User readable label to use when getting a handle.
Definition analog_common.h:334
pin_fn_t function
Useful function type for calculations when reading values.
Definition analog_common.h:287
gpo_data_t
GPO data settings.
Definition analog_common.h:220
viex_vi_t
Excitation source (VIEX_VI)
Definition analog_common.h:33
pin_t
Pin designations.
Definition analog_common.h:169
gain_offset_coeff_pair_t
Pointer to system gain and offset calibration register pairs.
Definition analog_common.h:43
gain_offset_coeff_pair_t gain_offset_pair
Choose the pointer index of a calibrated gain/offset coefficient pair.
Definition analog_common.h:293
bool tcc_off
True to disable NXPs proprietary Temperature Coefficient Correction.
Definition analog_common.h:324
pin_fn_t
Function of a given pin.
Definition analog_common.h:145
hv_ain_t hv_ain
Value for CH_CONFIG0 -> HV_AIN.
Definition analog_common.h:262
@ vrsns3
Definition analog_common.h:240
@ vrsns5
Definition analog_common.h:248
@ vrsns0
Definition analog_common.h:228
@ vrsns1
Definition analog_common.h:232
@ rref
Definition analog_common.h:252
@ vrsns2
Definition analog_common.h:236
@ vrsns4
Definition analog_common.h:244
@ none
Definition analog_common.h:224
@ zero_pt_four
Gain = 0.4 V/V, single-ended AIxx-AICOM.
Definition analog_common.h:51
@ eight
Gain = 8 V/V, single-ended AIxx-AICOM.
Definition analog_common.h:71
@ four
Gain = 4 V/V, single-ended AIxx-AICOM.
Definition analog_common.h:67
@ zero_pt_two
Gain = 0.2 V/V, single-ended AIxx-AICOM.
Definition analog_common.h:47
@ zero_pt_eight
Gain = 0.8 V/V, single-ended AIxx-AICOM.
Definition analog_common.h:55
@ two
Gain = 2 V/V, single-ended AIxx-AICOM.
Definition analog_common.h:63
@ sixteen
Gain = 16 V/V, single-ended AIxx-AICOM.
Definition analog_common.h:75
@ one
Gain = 1 V/V, single-ended AIxx-AICOM.
Definition analog_common.h:59
Common IO types and structures.
Anything related to configuring or reading analog sensors.
Representation of a NAFE channel. These are required by sensors.
Definition analog_common.h:258
Represents a sensor.
Definition analog_common.h:330