|
SFM Flow Meter Driver 1.0.0
API reference
|
SF06 flow-meter client. More...
#include <sfm_driver.hpp>
Public Member Functions | |
| Driver (I2cT &i2c, uint8_t address=addr::kSfm4300Default, Family family=Family::Sf06) noexcept | |
| uint8_t | Address () const noexcept |
| void | SetAddress (uint8_t address) noexcept |
| Variant | KnownVariant () const noexcept |
Variant learned from the last successful ReadProductIdentifier(). | |
| void | AssumeVariant (Variant v) noexcept |
| Let the caller assert a variant when the identifier cannot be read (already measuring). | |
| Family | PartFamily () const noexcept |
Family in use (from the identifier, AssumeVariant, or the constructor). | |
| Gas | ActiveGas () const noexcept |
Gas selected by the last successful StartContinuous(). | |
| bool | Measuring () const noexcept |
| const Scaling & | ActiveScaling () const noexcept |
| Scaling captured for the active gas. | |
| DriverResult< ProductInfo > | ReadProductIdentifier () noexcept |
| Read product identifier and serial number (§4.3.9). | |
| DriverResult< Scaling > | ReadScaleOffsetUnit (Gas g) noexcept |
| Query scale factor, offset and unit for a gas table (§4.3.6). | |
| DriverResult< void > | StartContinuous (Gas g, uint16_t o2_permille=0) noexcept |
Start continuous measurement for g (§4.3.1). | |
| DriverResult< void > | Stop () noexcept |
| Stop continuous measurement → idle (§4.3.4). | |
| DriverResult< Measurement > | ReadMeasurement () noexcept |
| Read one flow / temperature / status frame (§4.3.1). | |
| DriverResult< float > | ReadTemperature () noexcept |
| SFx6000: read the flow-chip temperature while measuring (pointer 0xE102 → one word → pointer back to results 0xE000). | |
| DriverResult< float > | ReadFlowOnly () noexcept |
| Flow-only read (2 words + CRC) for the tightest loop; status not refreshed. | |
| DriverResult< void > | ConfigureAveraging (uint16_t window) noexcept |
| Configure on-sensor averaging (§4.3.5). | |
| DriverResult< void > | UpdateConcentration (uint16_t o2_permille) noexcept |
| Update the O2 fraction of a running mixture measurement (§4.3.3). | |
| DriverResult< void > | EnterSleep () noexcept |
| Enter sleep (idle mode only, §4.3.8). | |
| DriverResult< void > | ExitSleep () noexcept |
| Exit sleep: any write header wakes the part; it does not ACK (§4.3.8). Polls up to ~20 ms until the address is acknowledged again. | |
| DriverResult< void > | SoftReset () noexcept |
| I2C general-call soft reset (§4.3.7): 0x06 to address 0x00, then ~20 ms. | |
Static Public Member Functions | |
| static DriverResult< Measurement > | DecodeMeasurement (Family family, const Scaling &scaling, const uint8_t frame[9]) noexcept |
| Decode one 9-byte continuous-mode frame (3 × word + CRC). | |
| static void | EncodeWord (uint16_t word, uint8_t out[3]) noexcept |
| Encode a 16-bit word + CRC-8 into 3 bytes. | |
| static DriverError | DecodeWords (const uint8_t *in, std::size_t count, uint16_t *out) noexcept |
Decode count (word, crc) triplets; returns Crc on the first mismatch. | |
SF06 flow-meter client.
| I2cT | Concrete type inheriting I2cInterface<I2cT>. |
|
inlineexplicitnoexcept |
| i2c | Transport adapter (must outlive the driver). |
| address | 7-bit device address (default SFM4300 0x2A). |
| family | Family assumed until the product identifier is read. |
|
inlinenoexcept |
Gas selected by the last successful StartContinuous().
|
inlinenoexcept |
Scaling captured for the active gas.
|
inlinenoexcept |
|
inlinenoexcept |
Let the caller assert a variant when the identifier cannot be read (already measuring).
|
inlinenoexcept |
Configure on-sensor averaging (§4.3.5).
| window | 0 = average-until-read (default), 1…128 = fixed-N. |
|
inlinestaticnoexcept |
Decode one 9-byte continuous-mode frame (3 × word + CRC).
Pure: the same decode serves the blocking read above and an interrupt / DMA reader that fetched the frame itself. SF06: flow, temperature, status. SFx6000: flow, reserved, status (temperature through ReadTemperature()).
|
inlinestaticnoexcept |
Decode count (word, crc) triplets; returns Crc on the first mismatch.
|
inlinestaticnoexcept |
Encode a 16-bit word + CRC-8 into 3 bytes.
|
inlinenoexcept |
Enter sleep (idle mode only, §4.3.8).
|
inlinenoexcept |
Exit sleep: any write header wakes the part; it does not ACK (§4.3.8). Polls up to ~20 ms until the address is acknowledged again.
|
inlinenoexcept |
Variant learned from the last successful ReadProductIdentifier().
|
inlinenoexcept |
|
inlinenoexcept |
Family in use (from the identifier, AssumeVariant, or the constructor).
|
inlinenoexcept |
Flow-only read (2 words + CRC) for the tightest loop; status not refreshed.
|
inlinenoexcept |
Read one flow / temperature / status frame (§4.3.1).
Requires a running continuous measurement. A NACK on the read header (no fresh sample yet, or idle) is reported as DriverError::NoData.
|
inlinenoexcept |
Read product identifier and serial number (§4.3.9).
StartContinuous() or after Stop().
|
inlinenoexcept |
Query scale factor, offset and unit for a gas table (§4.3.6).
| g | Gas selector whose start command is passed as the argument. |
|
inlinenoexcept |
SFx6000: read the flow-chip temperature while measuring (pointer 0xE102 → one word → pointer back to results 0xE000).
NotSupported on SF06 (temperature is in every frame).
|
inlinenoexcept |
|
inlinenoexcept |
I2C general-call soft reset (§4.3.7): 0x06 to address 0x00, then ~20 ms.
NotSupported when the transport has no general-call write.
|
inlinenoexcept |
Start continuous measurement for g (§4.3.1).
Reads the gas table scaling first (so ReadMeasurement() can convert), refuses gases the known variant does not calibrate, refuses a scaling reply it cannot use (UnexpectedUnit: scale 0, or a unit other than 0x0148 on a known SF06 part), then issues the start command and waits timing::kFirstResultAfterStartMs. If this driver started a measurement that is still running (Measuring()), it sends Stop() first: the sensor takes no other command while measuring (§4.3.4), so switching gas needs stop, 0.5 ms, query, start.
| g | Gas or mixture. |
| o2_permille | O2 volume fraction for mixtures (ignored for pure gases). |
|
inlinenoexcept |
Stop continuous measurement → idle (§4.3.4).
Waits timing::kStopToIdleMs after the command: the sensor needs up to 0.5 ms to enter idle mode before the next command.
|
inlinenoexcept |
Update the O2 fraction of a running mixture measurement (§4.3.3).
| o2_permille | New O2 volume fraction (‰). |