SFM_FLOW_METER Driver 0.1.0
API reference
Loading...
Searching...
No Matches
sfm_flow_meter_parts.hpp
Go to the documentation of this file.
1
20#ifndef SFM_FLOW_METER_PARTS_HPP
21#define SFM_FLOW_METER_PARTS_HPP
22
23#include <algorithm>
24#include <array>
25#include <cstddef>
26#include <cstdint>
27
31
32namespace sfm {
33
37namespace feature {
38inline constexpr uint32_t kScaleRead = 1U << 0;
39inline constexpr uint32_t kAveraging = 1U << 1;
40inline constexpr uint32_t kAveragingZero = 1U << 2;
41inline constexpr uint32_t kConcentration = 1U << 3;
42inline constexpr uint32_t kSleep = 1U << 4;
43inline constexpr uint32_t kStatusWord = 1U << 5;
44inline constexpr uint32_t kTemperatureFrame = 1U << 6;
45inline constexpr uint32_t kTemperatureRead = 1U
46 << 7;
47inline constexpr uint32_t kGeneralCallReset = 1U << 8;
48inline constexpr uint32_t kSoftResetCommand = 1U
49 << 9;
50inline constexpr uint32_t kResetPin = 1U << 10;
51inline constexpr uint32_t kClockStretch = 1U << 11;
52inline constexpr uint32_t kFilterArg = 1U << 12;
53inline constexpr uint32_t kFirstByteAck = 1U << 13;
54inline constexpr uint32_t kTwoFlows = 1U << 14;
55inline constexpr uint32_t kRestartBeforeRead = 1U << 15;
56inline constexpr uint32_t kPowerCycle = 1U
57 << 16;
58inline constexpr uint32_t kWakeByte = 1U << 17;
59inline constexpr uint32_t kIrqPin = 1U << 18;
60} // namespace feature
61
64struct Scaling {
65 uint32_t num{1};
66 uint32_t den{1};
67 int32_t offset{0};
68 uint16_t unit{0};
69};
70
73struct GasRow {
75 uint16_t code{0};
76 uint8_t status_index{0};
77 bool takes_argument{false};
79};
80
82struct TempRow {
83 int32_t scale{0};
84 int32_t offset{0};
85};
86
88struct Timing {
89 uint32_t power_up_us{0};
90 uint32_t soft_reset_us{0};
91 uint32_t first_sample_us{0};
92 uint32_t warm_up_us{0};
93 uint32_t stop_us{0};
94 uint32_t wake_us{0};
95 uint32_t id_read_us{0};
96 uint32_t hard_reset_us{0};
97};
98
101 std::array<uint8_t, 7> list{};
102 uint8_t count{0};
103};
104
106struct GasList {
107 std::array<GasRow, 7> rows{};
108 uint8_t count{0};
109};
110
112struct PartInfo {
115 const char* name{""};
116 uint32_t id_value{0};
117 uint32_t id_mask{0};
119 uint8_t crc_init{0xFF};
121 int32_t span_min_mlpm{0};
122 int32_t span_max_mlpm{0};
124 uint8_t raw_bits{16};
125 bool raw_signed{true};
127 uint32_t features{0};
128 uint32_t max_clock_hz{0};
129 uint16_t supply_mv_min{0};
130 uint16_t supply_mv_max{0};
131 uint8_t connector{0};
132 bool preliminary{false};
133};
134
137namespace parts {
138
140inline constexpr std::size_t kCount = 32;
141
143constexpr GasRow Row(Gas gas, uint16_t code, uint8_t idx, bool arg, Scaling s) noexcept {
144 return GasRow{.gas = gas, .code = code, .status_index = idx, .takes_argument = arg, .scaling = s};
145}
146
147template <typename... R>
148constexpr GasList Gases(R... rows) noexcept {
149 static_assert(sizeof...(R) <= 7U);
150 GasList list{};
151 const std::array<GasRow, sizeof...(R)> given{rows...};
152 for (std::size_t i = 0U; i < given.size(); ++i) {
153 list.rows[i] = given[i];
154 }
155 list.count = static_cast<uint8_t>(sizeof...(R));
156 return list;
157}
158
159template <typename... A>
160constexpr AddressSet Addresses(A... addr) noexcept {
161 static_assert(sizeof...(A) <= 7U);
162 AddressSet set{};
163 const std::array<uint8_t, sizeof...(A)> given{static_cast<uint8_t>(addr)...};
164 for (std::size_t i = 0U; i < given.size(); ++i) {
165 set.list[i] = given[i];
166 }
167 set.count = static_cast<uint8_t>(sizeof...(A));
168 return set;
169}
170
171constexpr uint32_t kSf06Common = feature::kScaleRead | feature::kAveraging |
175constexpr uint32_t kSf05Common = feature::kScaleRead | feature::kFirstByteAck |
177
178// Scalings: SFM4300-20 Table 15, SFM4300-50 Table 16, SFM3003 Table 15, SFM3304
179// Table 15, SFM3505 3.5.
180constexpr Scaling kS4300x20{.num = 2500, .den = 1, .offset = -28672, .unit = reg::kUnitSlm};
181constexpr Scaling kS4300x50{.num = 1000, .den = 1, .offset = -28672, .unit = reg::kUnitSlm};
182constexpr Scaling kS3xxx{.num = 170, .den = 1, .offset = -24576, .unit = reg::kUnitSlm};
183constexpr Scaling kS3xxxCe{.num = 120, .den = 1, .offset = -12288, .unit = reg::kUnitSlm};
184constexpr Scaling kS3304{.num = 120, .den = 1, .offset = 0, .unit = reg::kUnitSlm};
185constexpr Scaling kS3505{.num = 25600, .den = 1, .offset = 8388608, .unit = 0};
186// SF05: AN-05 and the datasheets (unit word not reported).
187constexpr Scaling kS3000{.num = 140, .den = 1, .offset = 32000, .unit = 0};
188constexpr Scaling kS3000O2{.num = 1428, .den = 10, .offset = 32000, .unit = 0};
189constexpr Scaling kS3200{.num = 120, .den = 1, .offset = 32768, .unit = 0};
190constexpr Scaling kS3400{.num = 800, .den = 1, .offset = 32768, .unit = 0};
191constexpr Scaling kS4200{.num = 256, .den = 1, .offset = 0, .unit = 0};
192constexpr Scaling kS4100{.num = 1000, .den = 1, .offset = 0, .unit = reg::kUnitSccm};
193// SFx6000 [P]: interface reference section 3.5.1.
194constexpr Scaling kS6000x50a{.num = 1024, .den = 1, .offset = -28672, .unit = reg::kUnitSlm};
195constexpr Scaling kS6000x50b{.num = 2560, .den = 1, .offset = -28672, .unit = reg::kUnitSlm};
196constexpr Scaling kS6000x20a{.num = 2560, .den = 1, .offset = -28672, .unit = reg::kUnitSlm};
197constexpr Scaling kS6000x20b{.num = 5120, .den = 1, .offset = -28672, .unit = reg::kUnitSlm};
198constexpr Scaling kS6000x5a{.num = 10240, .den = 1, .offset = -28672, .unit = reg::kUnitSlm};
199constexpr Scaling kS6000x5b{.num = 25600, .den = 1, .offset = -28672, .unit = reg::kUnitSlm};
200
201constexpr GasList Sf06Basic(Scaling s) noexcept {
202 return Gases(Row(Gas::O2, reg::kCmdStartGas0, 0, false, s),
203 Row(Gas::Air, reg::kCmdStartGas1, 1, false, s),
204 Row(Gas::AirO2, reg::kCmdStartMixture0, 6, true, s));
205}
206
207constexpr GasList Sf06Full(Scaling s) noexcept {
208 return Gases(Row(Gas::O2, reg::kCmdStartGas0, 0, false, s),
209 Row(Gas::Air, reg::kCmdStartGas1, 1, false, s),
210 Row(Gas::N2O, reg::kCmdStartGas2, 2, false, s),
211 Row(Gas::CO2, reg::kCmdStartGas3, 3, false, s),
212 Row(Gas::AirO2, reg::kCmdStartMixture0, 6, true, s),
213 Row(Gas::N2OO2, reg::kCmdStartMixture1, 7, true, s),
214 Row(Gas::CO2O2, reg::kCmdStartMixture2, 8, true, s));
215}
216
217constexpr GasList Sf06Heliox(Scaling s) noexcept {
218 return Gases(Row(Gas::O2, reg::kCmdStartGas0, 0, false, s),
219 Row(Gas::Air, reg::kCmdStartGas1, 1, false, s),
220 Row(Gas::HeOx, reg::kCmdStartGas2, 2, false, s),
221 Row(Gas::AirO2, reg::kCmdStartMixture0, 6, true, s),
222 Row(Gas::HeOxO2, reg::kCmdStartMixture1, 7, true, s));
223}
224
225constexpr GasList Sf05Gases(Scaling air, Scaling o2) noexcept {
226 return Gases(Row(Gas::Air, reg::kSf05Flow, 0, false, air),
227 Row(Gas::N2, reg::kSf05Flow, 0, false, air),
228 Row(Gas::O2, reg::kSf05Flow, 0, false, o2));
229}
230
235constexpr GasList Sf05AirN2(Scaling air) noexcept {
236 return Gases(Row(Gas::Air, reg::kSf05Flow, 0, false, air),
237 Row(Gas::N2, reg::kSf05Flow, 0, false, air));
238}
239
240constexpr GasList Sf04Gas(Gas gas) noexcept {
241 return Gases(Row(gas, reg::kSf04TriggerFlow, 0, false, kS4100));
242}
243
244constexpr GasList Sfx6000Gases(Scaling a, Scaling b) noexcept {
245 return Gases(
246 Row(Gas::O2, reg::kCmdStartGas0, 0, false, a), Row(Gas::Air, reg::kCmdStartGas1, 1, false, a),
247 Row(Gas::CO2, reg::kCmdStartGas2, 2, false, b),
248 Row(Gas::N2O, reg::kCmdStartGas3, 3, false, b), Row(Gas::Ar, reg::kCmdStartGas4, 4, false, b),
249 Row(Gas::AirO2, reg::kCmdStartSfxMixture0, 10, true, a));
250}
251
252// Timings in microseconds (datasheet maxima; see docs/hardware.md for the
253// section of each).
254constexpr Timing kT4300{.power_up_us = 20000,
255 .soft_reset_us = 20000,
256 .first_sample_us = 12000,
257 .warm_up_us = 30000,
258 .stop_us = 500,
259 .wake_us = 20000,
260 .id_read_us = 0,
261 .hard_reset_us = 0};
262constexpr Timing kT3xxx{.power_up_us = 2000,
263 .soft_reset_us = 2000,
264 .first_sample_us = 12000,
265 .warm_up_us = 30000,
266 .stop_us = 500,
267 .wake_us = 16000,
268 .id_read_us = 0,
269 .hard_reset_us = 0};
270constexpr Timing kT3304{.power_up_us = 2000,
271 .soft_reset_us = 2000,
272 .first_sample_us = 4000,
273 .warm_up_us = 50000,
274 .stop_us = 500,
275 .wake_us = 2000,
276 .id_read_us = 0,
277 .hard_reset_us = 0};
278constexpr Timing kT3505{.power_up_us = 2000,
279 .soft_reset_us = 2000,
280 .first_sample_us = 4000,
281 .warm_up_us = 50000,
282 .stop_us = 500,
283 .wake_us = 0,
284 .id_read_us = 60,
285 .hard_reset_us = 0};
286constexpr Timing kT3000{.power_up_us = 100000,
287 .soft_reset_us = 80000,
288 .first_sample_us = 30000,
289 .warm_up_us = 30000,
290 .stop_us = 0,
291 .wake_us = 0,
292 .id_read_us = 0,
293 .hard_reset_us = 0};
294constexpr Timing kT3x00{.power_up_us = 100000,
295 .soft_reset_us = 80000,
296 .first_sample_us = 100000,
297 .warm_up_us = 100000,
298 .stop_us = 0,
299 .wake_us = 0,
300 .id_read_us = 0,
301 .hard_reset_us = 0};
302constexpr Timing kT4200{.power_up_us = 2000,
303 .soft_reset_us = 0,
304 .first_sample_us = 100000,
305 .warm_up_us = 100000,
306 .stop_us = 0,
307 .wake_us = 0,
308 .id_read_us = 0,
309 .hard_reset_us = 1000};
310constexpr Timing kT4100{.power_up_us = 20000,
311 .soft_reset_us = 20000,
312 .first_sample_us = 0,
313 .warm_up_us = 500000,
314 .stop_us = 0,
315 .wake_us = 0,
316 .id_read_us = 0,
317 .hard_reset_us = 0};
318constexpr Timing kT6000{.power_up_us = 30000,
319 .soft_reset_us = 30000,
320 .first_sample_us = 12000,
321 .warm_up_us = 1000000,
322 .stop_us = 1000,
323 .wake_us = 0,
324 .id_read_us = 0,
325 .hard_reset_us = 0};
326
328
329// clang-format off: one field per line keeps each row readable against its datasheet table.
331inline constexpr std::array<PartInfo, kCount> kTable{{
332 {.variant = Variant::SFM4300_20_B, .family = Family::Sf06, .name = "SFM4300-20-B",
333 .id_value = 0x04030100, .id_mask = 0xFFFFFF00, .addresses = Addresses(0x2A, 0x2B, 0x2C, 0x2D),
334 .crc_init = 0xFF, .gases = Sf06Full(kS4300x20), .span_min_mlpm = 0, .span_max_mlpm = 20000,
335 .temperature = {.scale = 200, .offset = 0}, .timing = kT4300, .features = kSf06Common | feature::kIrqPin,
336 .max_clock_hz = 1000000, .supply_mv_min = 3000, .supply_mv_max = 5500, .connector = 1},
337 {.variant = Variant::SFM4300_20_O, .family = Family::Sf06, .name = "SFM4300-20-O",
338 .id_value = 0x04030200, .id_mask = 0xFFFFFF00, .addresses = Addresses(0x2A, 0x2B, 0x2C, 0x2D),
339 .crc_init = 0xFF, .gases = Sf06Full(kS4300x20), .span_min_mlpm = 0, .span_max_mlpm = 20000,
340 .temperature = {.scale = 200, .offset = 0}, .timing = kT4300, .features = kSf06Common | feature::kIrqPin,
341 .max_clock_hz = 1000000, .supply_mv_min = 3000, .supply_mv_max = 5500, .connector = 1},
342 {.variant = Variant::SFM4300_20_P, .family = Family::Sf06, .name = "SFM4300-20-P",
343 .id_value = 0x04030300, .id_mask = 0xFFFFFF00, .addresses = Addresses(0x2A, 0x2B, 0x2C, 0x2D),
344 .crc_init = 0xFF, .gases = Sf06Full(kS4300x20), .span_min_mlpm = 0, .span_max_mlpm = 20000,
345 .temperature = {.scale = 200, .offset = 0}, .timing = kT4300, .features = kSf06Common | feature::kIrqPin,
346 .max_clock_hz = 1000000, .supply_mv_min = 3000, .supply_mv_max = 5500, .connector = 1},
347 {.variant = Variant::SFM4300_50_B, .family = Family::Sf06, .name = "SFM4300-50-B",
348 .id_value = 0x04030900, .id_mask = 0xFFFFFF00, .addresses = Addresses(0x2A, 0x2B, 0x2C, 0x2D),
349 .crc_init = 0xFF, .gases = Sf06Basic(kS4300x50), .span_min_mlpm = 0, .span_max_mlpm = 50000,
350 .temperature = {.scale = 200, .offset = 0}, .timing = kT4300, .features = kSf06Common | feature::kIrqPin,
351 .max_clock_hz = 1000000, .supply_mv_min = 3000, .supply_mv_max = 5500, .connector = 1},
352 {.variant = Variant::SFM4300_50_O, .family = Family::Sf06, .name = "SFM4300-50-O",
353 .id_value = 0x04030700, .id_mask = 0xFFFFFF00, .addresses = Addresses(0x2A, 0x2B, 0x2C, 0x2D),
354 .crc_init = 0xFF, .gases = Sf06Basic(kS4300x50), .span_min_mlpm = 0, .span_max_mlpm = 50000,
355 .temperature = {.scale = 200, .offset = 0}, .timing = kT4300, .features = kSf06Common | feature::kIrqPin,
356 .max_clock_hz = 1000000, .supply_mv_min = 3000, .supply_mv_max = 5500, .connector = 1},
357 {.variant = Variant::SFM4300_50_P, .family = Family::Sf06, .name = "SFM4300-50-P",
358 .id_value = 0x04030600, .id_mask = 0xFFFFFF00, .addresses = Addresses(0x2A, 0x2B, 0x2C, 0x2D),
359 .crc_init = 0xFF, .gases = Sf06Basic(kS4300x50), .span_min_mlpm = 0, .span_max_mlpm = 50000,
360 .temperature = {.scale = 200, .offset = 0}, .timing = kT4300, .features = kSf06Common | feature::kIrqPin,
361 .max_clock_hz = 1000000, .supply_mv_min = 3000, .supply_mv_max = 5500, .connector = 1},
362 {.variant = Variant::SFM3003_300_CL, .family = Family::Sf06, .name = "SFM3003-300-CL",
363 .id_value = 0x04020100, .id_mask = 0xFFFFFF00, .addresses = Addresses(0x28),
364 .crc_init = 0xFF, .gases = Sf06Basic(kS3xxx), .span_min_mlpm = -30000, .span_max_mlpm = 300000,
365 .temperature = {.scale = 200, .offset = 0}, .timing = kT3xxx, .features = kSf06Common,
366 .max_clock_hz = 1000000, .supply_mv_min = 2700, .supply_mv_max = 5500, .connector = 2},
367 {.variant = Variant::SFM3003_300_CE, .family = Family::Sf06, .name = "SFM3003-300-CE",
368 .id_value = 0x04020700, .id_mask = 0xFFFFFF00, .addresses = Addresses(0x2D),
369 .crc_init = 0xFF, .gases = Sf06Basic(kS3xxxCe), .span_min_mlpm = -150000, .span_max_mlpm = 300000,
370 .temperature = {.scale = 200, .offset = 0}, .timing = kT3xxx, .features = kSf06Common,
371 .max_clock_hz = 1000000, .supply_mv_min = 2700, .supply_mv_max = 5500, .connector = 2},
372 {.variant = Variant::SFM3003_300_CET, .family = Family::Sf06, .name = "SFM3003-300-CET",
373 .id_value = 0x04020800, .id_mask = 0xFFFFFF00, .addresses = Addresses(0x2A),
374 .crc_init = 0xFF, .gases = Sf06Basic(kS3xxxCe), .span_min_mlpm = -150000, .span_max_mlpm = 300000,
375 .temperature = {.scale = 200, .offset = 0}, .timing = kT3xxx, .features = kSf06Common,
376 .max_clock_hz = 1000000, .supply_mv_min = 2700, .supply_mv_max = 5500, .connector = 2},
377 {.variant = Variant::SFM3013_300_CL, .family = Family::Sf06, .name = "SFM3013-300-CL",
378 .id_value = 0x04020500, .id_mask = 0xFFFFFF00, .addresses = Addresses(0x2F),
379 .crc_init = 0xFF, .gases = Sf06Basic(kS3xxx), .span_min_mlpm = -30000, .span_max_mlpm = 300000,
380 .temperature = {.scale = 200, .offset = 0}, .timing = kT3xxx, .features = kSf06Common,
381 .max_clock_hz = 1000000, .supply_mv_min = 2700, .supply_mv_max = 5500, .connector = 2},
382 {.variant = Variant::SFM3013_300_CLM, .family = Family::Sf06, .name = "SFM3013-300-CLM",
383 .id_value = 0x04020200, .id_mask = 0xFFFFFF00, .addresses = Addresses(0x2F),
384 .crc_init = 0xFF, .gases = Sf06Heliox(kS3xxx), .span_min_mlpm = -30000, .span_max_mlpm = 300000,
385 .temperature = {.scale = 200, .offset = 0}, .timing = kT3xxx, .features = kSf06Common,
386 .max_clock_hz = 1000000, .supply_mv_min = 2700, .supply_mv_max = 5500, .connector = 2},
387 {.variant = Variant::SFM3019_200_CL, .family = Family::Sf06, .name = "SFM3019-200-CL",
388 .id_value = 0x04020600, .id_mask = 0xFFFFFF00, .addresses = Addresses(0x2E),
389 .crc_init = 0xFF, .gases = Sf06Basic(kS3xxx), .span_min_mlpm = -10000, .span_max_mlpm = 240000,
390 .temperature = {.scale = 200, .offset = 0}, .timing = kT3xxx, .features = kSf06Common,
391 .max_clock_hz = 1000000, .supply_mv_min = 2700, .supply_mv_max = 5500, .connector = 2},
392 {.variant = Variant::SFM3119_240_CL, .family = Family::Sf06, .name = "SFM3119-240-CL",
393 .id_value = 0x04040100, .id_mask = 0xFFFFFF00, .addresses = Addresses(0x29),
394 .crc_init = 0xFF, .gases = Sf06Basic(kS3xxx), .span_min_mlpm = -10000, .span_max_mlpm = 240000,
395 .temperature = {.scale = 200, .offset = 0}, .timing = kT3xxx, .features = kSf06Common,
396 .max_clock_hz = 1000000, .supply_mv_min = 2700, .supply_mv_max = 5500, .connector = 2},
397 {.variant = Variant::SFM3304_250_D, .family = Family::Sf06Gen2, .name = "SFM3304-250-D",
398 .id_value = 0x04050100, .id_mask = 0xFFFFFF00, .addresses = Addresses(0x2E),
399 .crc_init = 0xFF, .gases = Gases(Row(Gas::Air, reg::kCmdStartGas0, 0, false, kS3304)),
400 .span_min_mlpm = -250000, .span_max_mlpm = 250000, .temperature = {.scale = 200, .offset = 0}, .timing = kT3304,
404 .max_clock_hz = 1000000, .supply_mv_min = 3150, .supply_mv_max = 3450, .connector = 7},
405 {.variant = Variant::SFM3505_300, .family = Family::Sf06Dual, .name = "SFM3505-300",
406 .id_value = 0x04060200, .id_mask = 0xFFFFFF00, .addresses = Addresses(0x2E),
407 .crc_init = 0xFF, .gases = Gases(Row(Gas::Air, reg::kCmdStartGas0, 0, false, kS3505)),
408 .span_min_mlpm = -150000, .span_max_mlpm = 300000, .temperature = {.scale = 0, .offset = 0}, .raw_bits = 24,
409 .raw_signed = false, .timing = kT3505,
412 .max_clock_hz = 1000000, .supply_mv_min = 3200, .supply_mv_max = 3400, .connector = 5},
413 {.variant = Variant::SFM3505_300_X, .family = Family::Sf06Dual, .name = "SFM3505-300-X",
414 .id_value = 0x04060100, .id_mask = 0xFFFFFF00, .addresses = Addresses(0x2E),
415 .crc_init = 0xFF, .gases = Gases(Row(Gas::Air, reg::kCmdStartGas0, 0, false, kS3505)),
416 .span_min_mlpm = -150000, .span_max_mlpm = 300000, .temperature = {.scale = 0, .offset = 0}, .raw_bits = 24,
417 .raw_signed = false, .timing = kT3505,
420 .max_clock_hz = 1000000, .supply_mv_min = 3200, .supply_mv_max = 3400, .connector = 5},
421 {.variant = Variant::SFM3000_200_C, .family = Family::Sf05, .name = "SFM3000-200-C",
422 .addresses = Addresses(0x40), .crc_init = 0x00, .gases = Sf05Gases(kS3000, kS3000O2),
423 .span_min_mlpm = -200000, .span_max_mlpm = 200000, .temperature = {.scale = 100, .offset = 20000},
424 .raw_signed = false, .timing = kT3000,
425 .features = kSf05Common | feature::kSoftResetCommand | feature::kTemperatureRead,
426 .max_clock_hz = 400000, .supply_mv_min = 4750, .supply_mv_max = 5250, .connector = 2},
427 {.variant = Variant::SFM3200, .family = Family::Sf05, .name = "SFM3200",
428 .addresses = Addresses(0x40), .crc_init = 0x00, .gases = Sf05AirN2(kS3200),
429 .span_min_mlpm = -100000, .span_max_mlpm = 250000, .temperature = {.scale = 0, .offset = 0},
430 .raw_signed = false, .timing = kT3x00, .features = kSf05Common | feature::kSoftResetCommand,
431 .max_clock_hz = 400000, .supply_mv_min = 4750, .supply_mv_max = 5250, .connector = 3},
432 {.variant = Variant::SFM3200_AW, .family = Family::Sf05, .name = "SFM3200-AW",
433 .addresses = Addresses(0x40), .crc_init = 0x00, .gases = Sf05AirN2(kS3200),
434 .span_min_mlpm = -100000, .span_max_mlpm = 250000, .temperature = {.scale = 100, .offset = 20000},
435 .raw_signed = false, .timing = kT3x00,
436 .features = kSf05Common | feature::kSoftResetCommand | feature::kTemperatureRead,
437 .max_clock_hz = 400000, .supply_mv_min = 4750, .supply_mv_max = 5250, .connector = 6},
438 {.variant = Variant::SFM3300_D, .family = Family::Sf05, .name = "SFM3300-D",
439 .addresses = Addresses(0x40), .crc_init = 0x00, .gases = Sf05AirN2(kS3200),
440 .span_min_mlpm = -250000, .span_max_mlpm = 250000, .temperature = {.scale = 0, .offset = 0},
441 .raw_signed = false, .timing = kT3x00, .features = kSf05Common | feature::kSoftResetCommand,
442 .max_clock_hz = 400000, .supply_mv_min = 4750, .supply_mv_max = 5250, .connector = 6},
443 {.variant = Variant::SFM3300_AW, .family = Family::Sf05, .name = "SFM3300-AW",
444 .addresses = Addresses(0x40), .crc_init = 0x00, .gases = Sf05AirN2(kS3200),
445 .span_min_mlpm = -250000, .span_max_mlpm = 250000, .temperature = {.scale = 100, .offset = 20000},
446 .raw_signed = false, .timing = kT3x00,
447 .features = kSf05Common | feature::kSoftResetCommand | feature::kTemperatureRead,
448 .max_clock_hz = 400000, .supply_mv_min = 4750, .supply_mv_max = 5250, .connector = 6},
449 {.variant = Variant::SFM3400_D, .family = Family::Sf05, .name = "SFM3400-D",
450 .addresses = Addresses(0x40), .crc_init = 0x00, .gases = Sf05AirN2(kS3400),
451 .span_min_mlpm = -33000, .span_max_mlpm = 33000, .temperature = {.scale = 0, .offset = 0},
452 .raw_signed = false, .timing = kT3x00, .features = kSf05Common | feature::kSoftResetCommand,
453 .max_clock_hz = 400000, .supply_mv_min = 4750, .supply_mv_max = 5250, .connector = 6},
454 {.variant = Variant::SFM3400_AW, .family = Family::Sf05, .name = "SFM3400-AW",
455 .addresses = Addresses(0x40), .crc_init = 0x00, .gases = Sf05AirN2(kS3400),
456 .span_min_mlpm = -33000, .span_max_mlpm = 33000, .temperature = {.scale = 100, .offset = 20000},
457 .raw_signed = false, .timing = kT3x00,
458 .features = kSf05Common | feature::kSoftResetCommand | feature::kTemperatureRead,
459 .max_clock_hz = 400000, .supply_mv_min = 4750, .supply_mv_max = 5250, .connector = 6},
460 {.variant = Variant::SFM4200, .family = Family::Sf05, .name = "SFM4200",
461 .addresses = Addresses(0x40), .crc_init = 0x00, .gases = Sf05AirN2(kS4200),
462 .span_min_mlpm = 0, .span_max_mlpm = 160000, .temperature = {.scale = 100, .offset = 20000},
463 .raw_signed = false, .timing = kT4200,
464 .features = kSf05Common | feature::kResetPin | feature::kTemperatureRead,
465 .max_clock_hz = 100000, .supply_mv_min = 4750, .supply_mv_max = 5250, .connector = 4},
466 {.variant = Variant::SFM4100_AIR, .family = Family::Sf04, .name = "SFM4100-Air",
467 .addresses = Addresses(1), .crc_init = 0x00, .gases = Sf04Gas(Gas::Air),
468 .span_min_mlpm = 0, .span_max_mlpm = 20000, .temperature = {.scale = 0, .offset = 0}, .timing = kT4100,
470 .max_clock_hz = 120000, .supply_mv_min = 3500, .supply_mv_max = 9000, .connector = 8},
471 {.variant = Variant::SFM4100_O2, .family = Family::Sf04, .name = "SFM4100-O2",
472 .addresses = Addresses(2), .crc_init = 0x00, .gases = Sf04Gas(Gas::O2),
473 .span_min_mlpm = 0, .span_max_mlpm = 20000, .temperature = {.scale = 0, .offset = 0}, .timing = kT4100,
475 .max_clock_hz = 120000, .supply_mv_min = 3500, .supply_mv_max = 9000, .connector = 8},
476 {.variant = Variant::SFM4100_CO2, .family = Family::Sf04, .name = "SFM4100-CO2",
477 .addresses = Addresses(3), .crc_init = 0x00, .gases = Sf04Gas(Gas::CO2),
478 .span_min_mlpm = 0, .span_max_mlpm = 20000, .temperature = {.scale = 0, .offset = 0}, .timing = kT4100,
480 .max_clock_hz = 120000, .supply_mv_min = 3500, .supply_mv_max = 9000, .connector = 8},
481 {.variant = Variant::SFM4100_N2O, .family = Family::Sf04, .name = "SFM4100-N2O",
482 .addresses = Addresses(4), .crc_init = 0x00, .gases = Sf04Gas(Gas::N2O),
483 .span_min_mlpm = 0, .span_max_mlpm = 20000, .temperature = {.scale = 0, .offset = 0}, .timing = kT4100,
485 .max_clock_hz = 120000, .supply_mv_min = 3500, .supply_mv_max = 9000, .connector = 8},
486 {.variant = Variant::SFM4100_AR, .family = Family::Sf04, .name = "SFM4100-Ar",
487 .addresses = Addresses(5), .crc_init = 0x00, .gases = Sf04Gas(Gas::Ar),
488 .span_min_mlpm = 0, .span_max_mlpm = 20000, .temperature = {.scale = 0, .offset = 0}, .timing = kT4100,
490 .max_clock_hz = 120000, .supply_mv_min = 3500, .supply_mv_max = 9000, .connector = 8},
491 {.variant = Variant::SFM6000D_50, .family = Family::Sfx6000, .name = "SFM6000D-50",
492 .id_value = 0x06021184, .id_mask = 0xFFFFFFFF,
493 .addresses = Addresses(0x24, 0x23, 0x22, 0x21, 0x20, 0x42, 0x41), .crc_init = 0xFF,
494 .gases = Sfx6000Gases(kS6000x50a, kS6000x50b), .span_min_mlpm = 0, .span_max_mlpm = 50000,
495 .temperature = {.scale = 200, .offset = 0}, .timing = kT6000,
498 .max_clock_hz = 1000000, .supply_mv_min = 22800, .supply_mv_max = 25200, .connector = 9,
499 .preliminary = true},
500 {.variant = Variant::SFM6000D_20, .family = Family::Sfx6000, .name = "SFM6000D-20",
501 .id_value = 0x06021284, .id_mask = 0xFFFFFFFF,
502 .addresses = Addresses(0x24, 0x23, 0x22, 0x21, 0x20, 0x42, 0x41), .crc_init = 0xFF,
503 .gases = Sfx6000Gases(kS6000x20a, kS6000x20b), .span_min_mlpm = 0, .span_max_mlpm = 20000,
504 .temperature = {.scale = 200, .offset = 0}, .timing = kT6000,
507 .max_clock_hz = 1000000, .supply_mv_min = 22800, .supply_mv_max = 25200, .connector = 9,
508 .preliminary = true},
509 {.variant = Variant::SFM6000D_5, .family = Family::Sfx6000, .name = "SFM6000D-5",
510 .id_value = 0x06021484, .id_mask = 0xFFFFFFFF,
511 .addresses = Addresses(0x24, 0x23, 0x22, 0x21, 0x20, 0x42, 0x41), .crc_init = 0xFF,
512 .gases = Sfx6000Gases(kS6000x5a, kS6000x5b), .span_min_mlpm = 0, .span_max_mlpm = 5000,
513 .temperature = {.scale = 200, .offset = 0}, .timing = kT6000,
516 .max_clock_hz = 1000000, .supply_mv_min = 22800, .supply_mv_max = 25200, .connector = 9,
517 .preliminary = true},
518}};
519// clang-format on
520
521} // namespace parts
522
529constexpr const PartInfo* FindPart(Variant variant) noexcept {
530 const auto index = static_cast<uint32_t>(detail::ToUnderlying(variant));
531 if ((index == 0U) || (index > parts::kCount)) {
532 return nullptr;
533 }
534 return &parts::kTable[index - 1U];
535}
536
546constexpr const PartInfo* FindById(Family family, uint32_t id, uint8_t address) noexcept {
547 for (const PartInfo& row : parts::kTable) {
548 if ((row.family != family) || (row.id_mask == 0U) || ((id & row.id_mask) != row.id_value)) {
549 continue;
550 }
551 for (uint8_t i = 0U; i < row.addresses.count; ++i) {
552 if (row.addresses.list[i] == address) {
553 return &row;
554 }
555 }
556 }
557 return nullptr;
558}
559
566constexpr const PartInfo* FamilyRow(Family family) noexcept {
567 for (const PartInfo& row : parts::kTable) {
568 if (row.family == family) {
569 return &row;
570 }
571 }
572 return nullptr;
573}
574
581constexpr const GasRow* FindGas(const PartInfo& part, Gas gas) noexcept {
582 for (uint8_t i = 0U; i < part.gases.count; ++i) {
583 if (part.gases.rows[i].gas == gas) {
584 return &part.gases.rows[i];
585 }
586 }
587 return nullptr;
588}
589
595constexpr bool Has(const PartInfo& part, uint32_t bits) noexcept {
596 return (part.features & bits) == bits;
597}
598
603constexpr Capabilities CapabilitiesOf(const PartInfo& part) noexcept {
604 Capabilities c{};
606 c.averaging = Has(part, feature::kAveraging);
607 c.concentration = Has(part, feature::kConcentration);
608 c.sleep = Has(part, feature::kSleep);
609 c.temperature_in_frame = Has(part, feature::kTemperatureFrame);
610 c.temperature_read = Has(part, feature::kTemperatureRead);
611 c.status_word = Has(part, feature::kStatusWord);
612 c.general_call_reset = Has(part, feature::kGeneralCallReset);
613 c.soft_reset_command = Has(part, feature::kSoftResetCommand);
614 c.hard_reset = Has(part, feature::kResetPin) || Has(part, feature::kPowerCycle);
615 c.filter = Has(part, feature::kFilterArg);
616 c.two_flows = Has(part, feature::kTwoFlows);
617 c.clock_stretch = Has(part, feature::kClockStretch);
618 c.preliminary = part.preliminary;
619 return c;
620}
621
628constexpr int64_t DivideRounded(int64_t value, int64_t divisor) noexcept {
629 const int64_t half = divisor / 2;
630 return (value >= 0) ? ((value + half) / divisor) : ((value - half) / divisor);
631}
632
642constexpr int32_t FlowMlPerMin(int32_t raw, const Scaling& scaling) noexcept {
643 const int64_t diff = static_cast<int64_t>(raw) - static_cast<int64_t>(scaling.offset);
644 const int64_t scaled = diff * int64_t{1000} * static_cast<int64_t>(scaling.den);
645 return static_cast<int32_t>(DivideRounded(scaled, static_cast<int64_t>(scaling.num)));
646}
647
656constexpr int32_t TemperatureMdegC(int32_t raw, const TempRow& row) noexcept {
657 if (row.scale == 0) {
658 return 0;
659 }
660 const int64_t diff = static_cast<int64_t>(raw) - static_cast<int64_t>(row.offset);
661 return static_cast<int32_t>(DivideRounded(diff * int64_t{1000}, static_cast<int64_t>(row.scale)));
662}
663
677constexpr Error Validate(const Config& config) noexcept;
678
685constexpr Config PresetFor(Variant variant) noexcept {
686 Config c{};
687 const PartInfo* row = FindPart(variant);
688 if (row != nullptr) {
689 c.variant = variant;
690 c.family = row->family;
691 c.address = row->addresses.list[0];
692 }
693 return c;
694}
695
696namespace detail {
699constexpr bool AveragingInRange(const PartInfo& part, uint16_t n) noexcept {
700 if (n == kAveragingDefault) {
701 return true;
702 }
703 if (!Has(part, feature::kAveraging)) {
704 return false;
705 }
706 if (n == 0U) {
707 return Has(part, feature::kAveragingZero);
708 }
709 return n <= 128U;
710}
711
713constexpr bool AddressAllowed(const PartInfo& part, uint8_t address) noexcept {
714 for (uint8_t i = 0U; i < part.addresses.count; ++i) {
715 if (part.addresses.list[i] == address) {
716 return true;
717 }
718 }
719 return false;
720}
721
724constexpr bool FamilyAddressAllowed(Family family, uint8_t address) noexcept {
725 return std::ranges::any_of(parts::kTable, [family, address](const PartInfo& row) {
726 return (row.family == family) && AddressAllowed(row, address);
727 });
728}
729
731constexpr bool ConfigScalarsValid(const Config& c) noexcept {
732 return IsEnumerator(c.variant) && IsEnumerator(c.family) && IsEnumerator(c.scaling_check) &&
733 IsEnumerator(c.range_policy) && IsEnumerator(c.timing) &&
734 (c.consecutive_error_limit != 0U) && (c.range_margin_permille <= 1000U);
735}
736} // namespace detail
737
738namespace detail {
742constexpr Error ValidateAuto(const Config& config) noexcept {
743 const PartInfo* part = FamilyRow(config.family);
744 if ((part == nullptr) || (config.timing == TimingPolicy::Datasheet) ||
745 ((config.address != 0U) && !FamilyAddressAllowed(config.family, config.address))) {
747 }
748 return ((config.family == Family::Sf05) || (config.family == Family::Sf04))
750 : Error::Ok;
751}
752} // namespace detail
753
754constexpr Error Validate(const Config& config) noexcept {
755 if (!detail::ConfigScalarsValid(config)) {
757 }
758 const PartInfo* part = FindPart(config.variant);
759 if (part == nullptr) {
760 return detail::ValidateAuto(config);
761 }
762 // A variant names its own family; the default family field is ignored.
763 const bool family_ok = (part->family == config.family) || (config.family == Family::Sf06);
764 const bool address_ok = (config.address == 0U) || detail::AddressAllowed(*part, config.address);
765 const bool options_ok = detail::AveragingInRange(*part, config.averaging) &&
766 (!config.filter_enabled || Has(*part, feature::kFilterArg));
767 return (family_ok && address_ok && options_ok) ? Error::Ok : Error::InvalidArgument;
768}
769
770// Config{} and every preset are valid, proved at build time (KB-CPP20-012).
771static_assert(Validate(Config{}) == Error::Ok);
772
778void ConfigIsInvalid() noexcept;
779
789public:
794 consteval explicit CheckedConfig(const Config& config) noexcept : config_(config) {
795 if (Validate(config) != Error::Ok) {
797 }
798 }
800 [[nodiscard]] constexpr const Config& Get() const& noexcept {
801 return config_;
802 }
804 void Get() const&& = delete;
805
806private:
807 Config config_;
808};
809
810namespace detail {
811
814constexpr bool RowIsConsistent(const PartInfo& row) noexcept {
815 bool ok = (row.addresses.count > 0U) && (row.gases.count > 0U) && (row.timing.power_up_us > 0U) &&
816 ((row.crc_init == 0xFFU) || (row.crc_init == 0x00U)) &&
817 (row.span_min_mlpm < row.span_max_mlpm);
818 for (uint8_t g = 0U; g < row.gases.count; ++g) {
819 const GasRow& gas = row.gases.rows[g];
820 ok = ok && (gas.code != 0U) && (gas.scaling.num != 0U) && (gas.scaling.den != 0U);
821 }
822 // A clock-stretching read exists only on the SF04 family, the first-byte rule
823 // only on SF05.
824 ok = ok && (Has(row, feature::kClockStretch) == (row.family == Family::Sf04));
825 ok = ok && (Has(row, feature::kFirstByteAck) == (row.family == Family::Sf05));
826 return ok && (row.preliminary == (row.family == Family::Sfx6000));
827}
828
831constexpr bool TableIsConsistent() noexcept {
832 for (std::size_t i = 0U; i < parts::kCount; ++i) {
833 const PartInfo& row = parts::kTable[i];
834 bool ok =
835 (static_cast<std::size_t>(ToUnderlying(row.variant)) == (i + 1U)) && RowIsConsistent(row);
836 for (std::size_t j = i + 1U; j < parts::kCount; ++j) {
837 const PartInfo& other = parts::kTable[j];
838 ok = ok && ((row.family != other.family) || (row.id_mask == 0U) ||
839 (row.id_value != other.id_value));
840 }
841 if (!ok) {
842 return false;
843 }
844 }
845 return true;
846}
847} // namespace detail
848
849static_assert(detail::TableIsConsistent());
850
851// One row per family pinned against hand-typed datasheet values: a mistyped
852// digit fails the build.
853static_assert(FindPart(Variant::SFM4300_20_B)->gases.rows[0].scaling.num == 2500U);
854static_assert(FindPart(Variant::SFM4300_20_B)->addresses.list[0] == 0x2AU);
855static_assert(FindPart(Variant::SFM3003_300_CE)->gases.rows[1].scaling.offset == -12288);
856static_assert(FindPart(Variant::SFM3304_250_D)->addresses.list[0] == 0x2EU);
857static_assert(FindPart(Variant::SFM3505_300)->gases.rows[0].scaling.offset == 0x800000);
858static_assert(FindPart(Variant::SFM3000_200_C)->gases.rows[2].scaling.num == 1428U);
859static_assert(FindPart(Variant::SFM4100_AR)->addresses.list[0] == 5U);
860static_assert(FindPart(Variant::SFM6000D_5)->gases.rows[2].scaling.num == 25600U);
861// The start code is data: 0x3615 is nitrous oxide, heliox or carbon dioxide
862// depending on the part.
863static_assert(FindGas(*FindPart(Variant::SFM4300_20_P), Gas::N2O)->code == 0x3615U);
864static_assert(FindGas(*FindPart(Variant::SFM3013_300_CLM), Gas::HeOx)->code == 0x3615U);
865static_assert(FindGas(*FindPart(Variant::SFM6000D_50), Gas::CO2)->code == 0x3615U);
866static_assert(FindGas(*FindPart(Variant::SFM4300_50_B), Gas::CO2) == nullptr);
867// The conversions at the documented extremes (SFM4300-20: -1.64 to +24.58 slm
868// raw span).
869static_assert(FlowMlPerMin(-32768, FindPart(Variant::SFM4300_20_B)->gases.rows[1].scaling) ==
870 -1638);
871static_assert(FlowMlPerMin(32767, FindPart(Variant::SFM4300_20_B)->gases.rows[1].scaling) == 24576);
872static_assert(FlowMlPerMin(32000, FindPart(Variant::SFM3000_200_C)->gases.rows[2].scaling) == 0);
873static_assert(TemperatureMdegC(20000, FindPart(Variant::SFM3200_AW)->temperature) == 0);
874namespace detail {
875static_assert(FindById(Family::Sf06, 0x04030100_u32, 0x2A_u8) == FindPart(Variant::SFM4300_20_B));
876// Another family's identifier never matches (a controller product is refused
877// the same way).
878static_assert(FindById(Family::Sf06, 0x06021184_u32, 0x24_u8) == nullptr);
879} // namespace detail
880
881} // namespace sfm
882
883#endif // SFM_FLOW_METER_PARTS_HPP
A configuration proven valid at build time.
Definition sfm_flow_meter_parts.hpp:788
consteval CheckedConfig(const Config &config) noexcept
Check config at build time.
Definition sfm_flow_meter_parts.hpp:794
constexpr const Config & Get() const &noexcept
Definition sfm_flow_meter_parts.hpp:800
void Get() const &&=delete
Not on a temporary: the reference would dangle (KB-CPP20-044).
constexpr uint16_t kUnitSccm
Definition sfm_flow_meter_registers.hpp:94
constexpr uint16_t kCmdStartGas0
Start continuous measurement, gas 0.
Definition sfm_flow_meter_registers.hpp:37
constexpr uint16_t kCmdStartMixture1
Start, mixture 1.
Definition sfm_flow_meter_registers.hpp:45
constexpr uint16_t kUnitSlm
Definition sfm_flow_meter_registers.hpp:91
constexpr uint16_t kCmdStartMixture2
Start, mixture 2.
Definition sfm_flow_meter_registers.hpp:46
constexpr uint16_t kSf05Flow
Start flow measurement / point at the flow.
Definition sfm_flow_meter_registers.hpp:67
constexpr uint16_t kCmdStartGas3
Start continuous measurement, gas 3.
Definition sfm_flow_meter_registers.hpp:40
constexpr uint16_t kCmdStartGas4
Start, gas 4 (SFx6000 argon; reserved on SF06).
Definition sfm_flow_meter_registers.hpp:41
constexpr uint16_t kCmdStartGas2
Start continuous measurement, gas 2.
Definition sfm_flow_meter_registers.hpp:39
constexpr uint16_t kCmdStartSfxMixture0
SFx6000: start, mixture 0.
Definition sfm_flow_meter_registers.hpp:47
constexpr uint16_t kCmdStartGas1
Start continuous measurement, gas 1.
Definition sfm_flow_meter_registers.hpp:38
constexpr uint16_t kCmdStartMixture0
Start, mixture 0 (argument: O2 in per mille).
Definition sfm_flow_meter_registers.hpp:43
constexpr uint8_t kSf04TriggerFlow
Trigger a flow measurement.
Definition sfm_flow_meter_registers.hpp:77
Gas
A calibrated gas or gas mixture. Which gases a part offers is in its table row.
Definition sfm_flow_meter_types.hpp:285
Error
Why a call failed. Every call of the driver returns one of these in its Result.
Definition sfm_flow_meter_types.hpp:41
Family
The command-set family of a part. One protocol policy per family; every part is a row of data that na...
Definition sfm_flow_meter_types.hpp:207
constexpr uint16_t kAveragingDefault
Marks Config::averaging as "the family's reset value".
Definition sfm_flow_meter_types.hpp:425
Variant
A part (one row of the table in sfm_flow_meter_parts.hpp). The names follow the vendor's ordering suf...
Definition sfm_flow_meter_types.hpp:245
@ CO2
Carbon dioxide.
@ CO2O2
Mixture of carbon dioxide and oxygen.
@ HeOxO2
Mixture of heliox and oxygen.
@ HeOx
Heliox 80/20 (SFM3013-300-CLM).
@ Air
Air.
@ Ar
Argon.
@ N2O
Nitrous oxide.
@ O2
Oxygen.
@ N2OO2
Mixture of nitrous oxide and oxygen.
@ N2
Nitrogen (every SF05 part, at the air scale).
@ AirO2
Mixture of air and oxygen; o2_permille is the oxygen fraction.
@ InvalidArgument
An argument or a Config field is out of range; nothing was sent.
@ Ok
The call succeeded.
@ Sf06Dual
SFM3505: two 24-bit flows (air and oxygen) in one frame.
@ Datasheet
The part's own maxima; needs a known variant.
@ SFM4300_20_O
SFM4300-20-O, O-ring connection.
@ SFM4300_20_B
SFM4300-20-B, 0 to 20 slm, base-mount flanges.
@ SFM4100_CO2
SFM4100-CO2, address 3.
@ SFM6000D_50
SFM6000D-50, preliminary protocol.
@ SFM3300_D
SFM3300-D.
@ SFM3200
SFM3200, 5 V, legacy.
@ SFM4200
SFM4200, 0 to 160 slm, /RES pin, 100 kHz, legacy.
@ SFM3013_300_CL
SFM3013-300-CL, address 0x2F.
@ SFM4100_AR
SFM4100-Ar, address 5.
@ SFM6000D_5
SFM6000D-5, preliminary protocol.
@ SFM4300_20_P
SFM4300-20-P, push-in fittings.
@ SFM3200_AW
SFM3200-AW, with temperature output.
@ SFM4100_AIR
SFM4100-Air, address 1, clock stretching, legacy.
@ SFM3013_300_CLM
SFM3013-300-CLM, adds heliox, address 0x2F.
@ SFM3019_200_CL
SFM3019-200-CL, address 0x2E.
@ SFM3400_AW
SFM3400-AW.
@ SFM3304_250_D
SFM3304-250-D, -250 to 250 slm, 3.3 V, address 0x2E.
@ SFM3505_300
SFM3505-300, air and oxygen channels.
@ SFM4300_50_O
SFM4300-50-O.
@ SFM3000_200_C
SFM3000-200-C, 5 V, address 0x40, legacy.
@ SFM4100_N2O
SFM4100-N2O, address 4.
@ SFM4300_50_P
SFM4300-50-P.
@ SFM6000D_20
SFM6000D-20, preliminary protocol.
@ SFM3505_300_X
SFM3505-300-X.
@ SFM3003_300_CL
SFM3003-300-CL, -30 to 300 slm, address 0x28.
@ SFM4300_50_B
SFM4300-50-B, 0 to 50 slm.
@ SFM3300_AW
SFM3300-AW.
@ SFM3119_240_CL
SFM3119-240-CL, address 0x29.
@ SFM4100_O2
SFM4100-O2, address 2.
@ SFM3400_D
SFM3400-D, -33 to 33 slm.
@ SFM3003_300_CE
SFM3003-300-CE, -150 to 300 slm, address 0x2D.
constexpr uint32_t kTwoFlows
The frame carries two flows (SFM3505).
Definition sfm_flow_meter_parts.hpp:54
constexpr uint32_t kSleep
Sleep() and WakeUp().
Definition sfm_flow_meter_parts.hpp:42
constexpr uint32_t kScaleRead
ReadScaling().
Definition sfm_flow_meter_parts.hpp:38
constexpr uint32_t kFirstByteAck
SF05: the first data byte must be ACKed.
Definition sfm_flow_meter_parts.hpp:53
constexpr uint32_t kIrqPin
The module has an IRQn or DRDY output.
Definition sfm_flow_meter_parts.hpp:59
constexpr uint32_t kSoftResetCommand
SoftReset() is a command to the device.
Definition sfm_flow_meter_parts.hpp:48
constexpr uint32_t kTemperatureRead
ReadTemperature() by a pointer sequence.
Definition sfm_flow_meter_parts.hpp:45
constexpr uint32_t kAveragingZero
N = 0 (average until read) is legal.
Definition sfm_flow_meter_parts.hpp:40
constexpr uint32_t kConcentration
UpdateConcentration().
Definition sfm_flow_meter_parts.hpp:41
constexpr uint32_t kGeneralCallReset
SoftReset() is the general call.
Definition sfm_flow_meter_parts.hpp:47
constexpr uint32_t kStatusWord
The frame carries a status word.
Definition sfm_flow_meter_parts.hpp:43
constexpr uint32_t kAveraging
SetAveraging().
Definition sfm_flow_meter_parts.hpp:39
constexpr uint32_t kResetPin
HardReset() pulses /RES (SFM4200).
Definition sfm_flow_meter_parts.hpp:50
constexpr uint32_t kWakeByte
Wake is address plus one dummy byte.
Definition sfm_flow_meter_parts.hpp:58
constexpr uint32_t kFilterArg
The start command takes a filter argument.
Definition sfm_flow_meter_parts.hpp:52
constexpr uint32_t kPowerCycle
HardReset() is a supply cycle (needs a hook).
Definition sfm_flow_meter_parts.hpp:56
constexpr uint32_t kTemperatureFrame
The frame carries the temperature.
Definition sfm_flow_meter_parts.hpp:44
constexpr uint32_t kRestartBeforeRead
SF05: start again around each read.
Definition sfm_flow_meter_parts.hpp:55
constexpr uint32_t kClockStretch
Reads need ReadStretch() (SFM4100).
Definition sfm_flow_meter_parts.hpp:51
constexpr std::size_t kCount
Rows in the table: one per variant but Auto.
Definition sfm_flow_meter_parts.hpp:140
constexpr std::array< PartInfo, kCount > kTable
The table, in Variant order after Auto.
Definition sfm_flow_meter_parts.hpp:331
The SFM flow meter driver: everything it declares lives here; internals in detail.
Definition sfm_flow_meter.hpp:35
constexpr const PartInfo * FindById(Family family, uint32_t id, uint8_t address) noexcept
The table row that a product identifier and address select inside one family.
Definition sfm_flow_meter_parts.hpp:546
constexpr Error Validate(const Config &config) noexcept
Check a configuration against the part it names, without touching the chip.
Definition sfm_flow_meter_parts.hpp:754
constexpr const GasRow * FindGas(const PartInfo &part, Gas gas) noexcept
The gas row of a part.
Definition sfm_flow_meter_parts.hpp:581
constexpr Capabilities CapabilitiesOf(const PartInfo &part) noexcept
Definition sfm_flow_meter_parts.hpp:603
constexpr int64_t DivideRounded(int64_t value, int64_t divisor) noexcept
Divide value by divisor rounding to nearest, ties away from zero.
Definition sfm_flow_meter_parts.hpp:628
constexpr int32_t FlowMlPerMin(int32_t raw, const Scaling &scaling) noexcept
A raw flow in millilitres per minute: (raw - offset) * 1000 * den / num, rounded.
Definition sfm_flow_meter_parts.hpp:642
constexpr const PartInfo * FindPart(Variant variant) noexcept
The table row of a variant.
Definition sfm_flow_meter_parts.hpp:529
constexpr bool Has(const PartInfo &part, uint32_t bits) noexcept
Definition sfm_flow_meter_parts.hpp:595
constexpr const PartInfo * FamilyRow(Family family) noexcept
The first row of a family: what Variant::Auto uses for waits before the part is known.
Definition sfm_flow_meter_parts.hpp:566
void ConfigIsInvalid() noexcept
Reached only when a CheckedConfig is built from an invalid configuration: it is never defined,...
constexpr int32_t TemperatureMdegC(int32_t raw, const TempRow &row) noexcept
A raw temperature in milli-degrees Celsius: (raw - offset) * 1000 / scale, rounded.
Definition sfm_flow_meter_parts.hpp:656
constexpr Config PresetFor(Variant variant) noexcept
A part's datasheet defaults as a configuration.
Definition sfm_flow_meter_parts.hpp:685
Compile-time helpers of the SFM_FLOW_METER driver: typed integer literals, exact hook matching,...
Command codes, status-word helpers and the CRC-8 of the SFM flow meters.
Public types of the SFM flow meter driver: errors, Result<T>, the families, variants and gases,...
The addresses a part may use; list[0] is the default.
Definition sfm_flow_meter_parts.hpp:100
uint8_t count
Entries in use.
Definition sfm_flow_meter_parts.hpp:102
std::array< uint8_t, 7 > list
The 7-bit addresses.
Definition sfm_flow_meter_parts.hpp:101
Which calls a part offers, from its table row.
Definition sfm_flow_meter_types.hpp:361
bool scale_read
ReadScaling() works.
Definition sfm_flow_meter_types.hpp:362
Everything EnsureInitialized() applies.
Definition sfm_flow_meter_types.hpp:437
The gases of a part.
Definition sfm_flow_meter_parts.hpp:106
std::array< GasRow, 7 > rows
The calibrated gases.
Definition sfm_flow_meter_parts.hpp:107
uint8_t count
Entries in use.
Definition sfm_flow_meter_parts.hpp:108
One calibrated gas of a part: its start code, its status index and its scaling.
Definition sfm_flow_meter_parts.hpp:73
bool takes_argument
A mixture: the start command carries the oxygen fraction.
Definition sfm_flow_meter_parts.hpp:77
uint16_t code
The start command (or pointer, or trigger byte).
Definition sfm_flow_meter_parts.hpp:75
uint8_t status_index
The status-word nibble that identifies the running command.
Definition sfm_flow_meter_parts.hpp:76
Scaling scaling
Scale, offset and unit.
Definition sfm_flow_meter_parts.hpp:78
Gas gas
The gas.
Definition sfm_flow_meter_parts.hpp:74
One row of the part table.
Definition sfm_flow_meter_parts.hpp:112
Family family
The command-set family.
Definition sfm_flow_meter_parts.hpp:114
GasList gases
The calibrated gases.
Definition sfm_flow_meter_parts.hpp:120
bool raw_signed
The flow word is two's complement.
Definition sfm_flow_meter_parts.hpp:125
uint8_t crc_init
CRC-8 initial value: 0xFF or 0x00.
Definition sfm_flow_meter_parts.hpp:119
uint16_t supply_mv_max
Highest supply voltage of the sensor.
Definition sfm_flow_meter_parts.hpp:130
uint8_t raw_bits
16, or 24 for the SFM3505.
Definition sfm_flow_meter_parts.hpp:124
uint16_t supply_mv_min
Lowest supply voltage of the sensor.
Definition sfm_flow_meter_parts.hpp:129
TempRow temperature
Temperature scaling.
Definition sfm_flow_meter_parts.hpp:123
Variant variant
The variant this row describes.
Definition sfm_flow_meter_parts.hpp:113
bool preliminary
The protocol document of the part is preliminary.
Definition sfm_flow_meter_parts.hpp:132
int32_t span_max_mlpm
Highest specified flow in ml/min.
Definition sfm_flow_meter_parts.hpp:122
uint32_t features
feature:: bits.
Definition sfm_flow_meter_parts.hpp:127
Timing timing
Datasheet timings.
Definition sfm_flow_meter_parts.hpp:126
AddressSet addresses
The permitted 7-bit addresses.
Definition sfm_flow_meter_parts.hpp:118
uint32_t id_value
Product identifier to match (SF06, SFM3505, SFx6000); 0 else.
Definition sfm_flow_meter_parts.hpp:116
int32_t span_min_mlpm
Lowest specified flow in ml/min.
Definition sfm_flow_meter_parts.hpp:121
uint32_t max_clock_hz
Highest SCL frequency of the part.
Definition sfm_flow_meter_parts.hpp:128
uint8_t connector
Connector id of the hardware page (informational).
Definition sfm_flow_meter_parts.hpp:131
uint32_t id_mask
Bits of the identifier that are compared; 0 when not used.
Definition sfm_flow_meter_parts.hpp:117
const char * name
The vendor's part name.
Definition sfm_flow_meter_parts.hpp:115
Counts per slm as the rational num / den, the offset and the unit word of one gas.
Definition sfm_flow_meter_parts.hpp:64
uint32_t num
Numerator of the scale factor in counts per slm.
Definition sfm_flow_meter_parts.hpp:65
uint32_t den
Denominator (10 for the SFM3000's 142.8).
Definition sfm_flow_meter_parts.hpp:66
uint16_t unit
The 16-bit flow-unit word; 0 for SF05.
Definition sfm_flow_meter_parts.hpp:68
int32_t offset
Offset in counts.
Definition sfm_flow_meter_parts.hpp:67
The temperature scaling of a part.
Definition sfm_flow_meter_parts.hpp:82
int32_t offset
Counts.
Definition sfm_flow_meter_parts.hpp:84
int32_t scale
Counts per degree Celsius; 0 when the part has no temperature.
Definition sfm_flow_meter_parts.hpp:83
Timings of a part in microseconds: the datasheet maxima.
Definition sfm_flow_meter_parts.hpp:88
uint32_t wake_us
Wake from sleep until the sensor answers.
Definition sfm_flow_meter_parts.hpp:94
uint32_t first_sample_us
Start command until the first result.
Definition sfm_flow_meter_parts.hpp:91
uint32_t warm_up_us
Start command until the result is accurate.
Definition sfm_flow_meter_parts.hpp:92
uint32_t power_up_us
Power-up until the sensor answers.
Definition sfm_flow_meter_parts.hpp:89
uint32_t id_read_us
Identifier command until the data can be read.
Definition sfm_flow_meter_parts.hpp:95
uint32_t stop_us
Stop command until the sensor accepts a command.
Definition sfm_flow_meter_parts.hpp:93
uint32_t soft_reset_us
Soft reset until the sensor answers.
Definition sfm_flow_meter_parts.hpp:90
uint32_t hard_reset_us
/RES low time (SFM4200), or the supply-off time of a power cycle.
Definition sfm_flow_meter_parts.hpp:96