17#ifndef SFM_FLOW_METER_REGISTERS_HPP
18#define SFM_FLOW_METER_REGISTERS_HPP
123constexpr uint8_t
Crc8(uint8_t init, uint8_t high, uint8_t low)
noexcept {
125 for (uint32_t
byte = 0U;
byte < 2U; ++byte) {
126 crc ^= (
byte == 0U) ?
static_cast<uint32_t
>(high) :
static_cast<uint32_t
>(low);
127 for (uint32_t bit = 0U; bit < 8U; ++bit) {
128 crc = ((crc & 0x80U) != 0U) ? ((crc << 1U) ^ 0x31U) : (crc << 1U);
132 return static_cast<uint8_t
>(crc);
141 using detail::operator
""_u8;
143 bool ok =
Crc8(0xFF_u8, 0xBE_u8, 0xEF_u8) == 0x92_u8;
145 ok = ok && (
Crc8(0x00_u8, 0xBE_u8, 0xEF_u8) == 0x13_u8);
147 ok = ok && (
Crc8(0xFF_u8, 0x36_u8, 0x08_u8) == 0xD0_u8);
150 ok = ok && (
Crc8(0xFF_u8, 0x36_u8, 0x03_u8) == 0x3A_u8);
153 ok = ok && (
Crc8(0xFF_u8, 0x00_u8, 0x00_u8) == 0x81_u8);
156 return ok && (
Crc8(0x00_u8, 0x00_u8, 0x00_u8) == 0x00_u8);
constexpr uint16_t kSf05Reset
Soft reset (SFM3x00).
Definition sfm_flow_meter_registers.hpp:69
constexpr uint16_t kSf05ScaleFlow
Flow scale factor.
Definition sfm_flow_meter_registers.hpp:70
constexpr uint16_t kCmdAveragingDual
SFM3505: configure averaging.
Definition sfm_flow_meter_registers.hpp:53
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
detail::Field< uint16_t, 0U, 10U > StatusConcentration
Definition sfm_flow_meter_registers.hpp:107
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 uint8_t kSf04ReadOnly2
Read read-only register 2.
Definition sfm_flow_meter_registers.hpp:81
detail::Field< uint16_t, 0U, 9U > StatusAverages
SFM3304 status word, bits 8:0: the configured number of averages.
Definition sfm_flow_meter_registers.hpp:111
constexpr uint16_t kCmdStartMixture2
Start, mixture 2.
Definition sfm_flow_meter_registers.hpp:46
constexpr uint8_t kSf04Eeprom
Read the EEPROM.
Definition sfm_flow_meter_registers.hpp:82
constexpr uint16_t kCmdReadScale
Read scale factor, offset and unit (argument).
Definition sfm_flow_meter_registers.hpp:54
constexpr uint16_t kSf05Flow
Start flow measurement / point at the flow.
Definition sfm_flow_meter_registers.hpp:67
constexpr uint16_t kCmdProductId
Read the product identifier (idle).
Definition sfm_flow_meter_registers.hpp:57
constexpr uint8_t kSf04UserRegister
Read the user register.
Definition sfm_flow_meter_registers.hpp:80
constexpr uint16_t kSf04EepromSerial
EEPROM address of the product serial number.
Definition sfm_flow_meter_registers.hpp:83
constexpr uint16_t kSf05Serial
Definition sfm_flow_meter_registers.hpp:72
constexpr uint8_t Crc8(uint8_t init, uint8_t high, uint8_t low) noexcept
CRC-8 of one 16-bit word as the chip computes it: polynomial 0x31 (x^8.
Definition sfm_flow_meter_registers.hpp:123
constexpr bool CrcVectorsHold() noexcept
The CRC vectors of the datasheets, proved at build time (see the static_assert below).
Definition sfm_flow_meter_registers.hpp:140
detail::Field< uint16_t, 10U, 1U > StatusFixedN
Status word, bit 10: fixed-N averaging is active (SF06 and SFM3304).
Definition sfm_flow_meter_registers.hpp:104
constexpr uint16_t kCmdStartGas3
Start continuous measurement, gas 3.
Definition sfm_flow_meter_registers.hpp:40
constexpr uint8_t kGeneralCallReset
Byte sent to address 0x00 to reset.
Definition sfm_flow_meter_registers.hpp:63
constexpr uint16_t kCmdSfxTemperature
SFx6000: point the read at the temperature.
Definition sfm_flow_meter_registers.hpp:61
constexpr uint16_t kCmdStartGas4
Start, gas 4 (SFx6000 argon; reserved on SF06).
Definition sfm_flow_meter_registers.hpp:41
constexpr uint16_t kCmdSfxScalePointer
SFx6000: point the read at the gas information.
Definition sfm_flow_meter_registers.hpp:59
detail::Field< uint16_t, 11U, 1U > StatusSmoothing
Status word, bit 11: exponential smoothing is active (SF06 and SFM3304).
Definition sfm_flow_meter_registers.hpp:102
constexpr uint8_t kSf04TriggerTemperature
Trigger a temperature measurement.
Definition sfm_flow_meter_registers.hpp:78
constexpr uint16_t kCmdStartGas2
Start continuous measurement, gas 2.
Definition sfm_flow_meter_registers.hpp:39
detail::Field< uint16_t, 12U, 4U > StatusCommand
Definition sfm_flow_meter_registers.hpp:100
constexpr uint16_t kSf04EepromUnit
EEPROM address of the flow-unit word.
Definition sfm_flow_meter_registers.hpp:86
detail::Field< uint16_t, 9U, 1U > StatusFilterArg
SFM3304 status word, bit 9: a filter argument was received.
Definition sfm_flow_meter_registers.hpp:109
constexpr uint16_t kSf04EepromScale
EEPROM address of the scale factor.
Definition sfm_flow_meter_registers.hpp:85
constexpr uint16_t kCmdAveraging
SF06 and SFM3304: configure averaging.
Definition sfm_flow_meter_registers.hpp:52
constexpr uint16_t kCmdStartSfxMixture0
SFx6000: start, mixture 0.
Definition sfm_flow_meter_registers.hpp:47
constexpr uint16_t kStatusPureGas
Status bits 9:0 of a pure gas.
Definition sfm_flow_meter_registers.hpp:96
constexpr uint16_t kCmdSleep
Enter sleep mode.
Definition sfm_flow_meter_registers.hpp:56
constexpr uint16_t kSf05SerialLow
Serial number, least significant word.
Definition sfm_flow_meter_registers.hpp:74
constexpr uint16_t kSf04FieldStride
EEPROM size of one calibration field.
Definition sfm_flow_meter_registers.hpp:87
constexpr uint8_t kSf04SoftReset
Soft reset.
Definition sfm_flow_meter_registers.hpp:79
constexpr uint8_t kGeneralCallAddress
The I2C general-call address.
Definition sfm_flow_meter_registers.hpp:64
constexpr uint16_t kCmdDeviceIdDual
SFM3505: read the device identifier.
Definition sfm_flow_meter_registers.hpp:58
constexpr uint16_t kSf05Temperature
Point at the temperature.
Definition sfm_flow_meter_registers.hpp:68
constexpr uint16_t kCmdResultPointer
Point the read at the result buffer.
Definition sfm_flow_meter_registers.hpp:50
constexpr uint16_t kCmdStop
Stop continuous measurement.
Definition sfm_flow_meter_registers.hpp:51
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 uint16_t kCmdUpdateConcentration
Update concentration, part 1 (argument).
Definition sfm_flow_meter_registers.hpp:48
constexpr uint8_t kSf04TriggerFlow
Trigger a flow measurement.
Definition sfm_flow_meter_registers.hpp:77
constexpr uint16_t kSf05OffsetFlow
Flow offset.
Definition sfm_flow_meter_registers.hpp:71
Command codes and field helpers.
Definition sfm_flow_meter_registers.hpp:27
Compile-time helpers of the SFM_FLOW_METER driver: typed integer literals, exact hook matching,...