SFM_FLOW_METER Driver 0.1.0
API reference
Loading...
Searching...
No Matches
Classes | Enumerations | Functions | Variables
Driver types

Errors, results, families, variants, samples and configuration. More...

Classes

struct  sfm::Result< T >
 The value of a call, or why there is none. More...
 
struct  sfm::Result< void >
 The result of a call that returns no value. More...
 
struct  sfm::Wait
 A wait the caller owes the driver: delay us, then call Poll(). 0 means nothing to wait. More...
 
struct  sfm::ProductInfo
 The product identifier read at initialisation. More...
 
struct  sfm::ScalingInfo
 What the sensor reports about the scaling of a gas, and whether it matches the table. More...
 
struct  sfm::Capabilities
 Which calls a part offers, from its table row. More...
 
struct  sfm::Sample
 One measurement. Flow is in millilitres per minute at the part's reference conditions. More...
 
struct  sfm::RawReply
 The words of one reply, after their CRCs were checked and before anything was decoded. More...
 
struct  sfm::Stats
 Counters the driver keeps; none of them is cleared by a successful call. More...
 
struct  sfm::Config
 Everything EnsureInitialized() applies. More...
 

Enumerations

enum class  sfm::Error : uint8_t {
  sfm::Error::Ok = 0 , sfm::Error::NotInitialized = 1 , sfm::Error::InvalidArgument = 2 , sfm::Error::Bus = 3 ,
  sfm::Error::Timeout = 4 , sfm::Error::DeviceIdMismatch = 5 , sfm::Error::Crc = 6 , sfm::Error::Busy = 7 ,
  sfm::Error::DeviceFault = 8 , sfm::Error::Unsupported = 9 , sfm::Error::NoData = 16 , sfm::Error::NoDevice = 17 ,
  sfm::Error::OutOfRange = 18 , sfm::Error::StatusMismatch = 19 , sfm::Error::Stale = 20 , sfm::Error::DeviceReset = 21 ,
  sfm::Error::StateUnknown = 22 , sfm::Error::InvalidReply = 23
}
 Why a call failed. Every call of the driver returns one of these in its Result. More...
 
enum class  sfm::LogLevel : uint8_t { sfm::LogLevel::Error = 0 , sfm::LogLevel::Warning , sfm::LogLevel::Info , sfm::LogLevel::Debug }
 Severity passed to the optional Log() hook. More...
 
enum class  sfm::Family : uint8_t {
  sfm::Family::Sf06 = 0 , sfm::Family::Sf06Gen2 , sfm::Family::Sf06Dual , sfm::Family::Sf05 ,
  sfm::Family::Sf04 , sfm::Family::Sfx6000
}
 The command-set family of a part. One protocol policy per family; every part is a row of data that names its family. More...
 
enum class  sfm::Variant : uint8_t {
  sfm::Variant::Auto = 0 , sfm::Variant::SFM4300_20_B , sfm::Variant::SFM4300_20_O , sfm::Variant::SFM4300_20_P ,
  sfm::Variant::SFM4300_50_B , sfm::Variant::SFM4300_50_O , sfm::Variant::SFM4300_50_P , sfm::Variant::SFM3003_300_CL ,
  sfm::Variant::SFM3003_300_CE , sfm::Variant::SFM3003_300_CET , sfm::Variant::SFM3013_300_CL , sfm::Variant::SFM3013_300_CLM ,
  sfm::Variant::SFM3019_200_CL , sfm::Variant::SFM3119_240_CL , sfm::Variant::SFM3304_250_D , sfm::Variant::SFM3505_300 ,
  sfm::Variant::SFM3505_300_X , sfm::Variant::SFM3000_200_C , sfm::Variant::SFM3200 , sfm::Variant::SFM3200_AW ,
  sfm::Variant::SFM3300_D , sfm::Variant::SFM3300_AW , sfm::Variant::SFM3400_D , sfm::Variant::SFM3400_AW ,
  sfm::Variant::SFM4200 , sfm::Variant::SFM4100_AIR , sfm::Variant::SFM4100_O2 , sfm::Variant::SFM4100_CO2 ,
  sfm::Variant::SFM4100_N2O , sfm::Variant::SFM4100_AR , sfm::Variant::SFM6000D_50 , sfm::Variant::SFM6000D_20 ,
  sfm::Variant::SFM6000D_5
}
 A part (one row of the table in sfm_flow_meter_parts.hpp). The names follow the vendor's ordering suffixes; _B, _O and _P are the SFM4300 fittings. More...
 
enum class  sfm::Gas : uint8_t {
  sfm::Gas::Air = 0 , sfm::Gas::O2 , sfm::Gas::N2 , sfm::Gas::N2O ,
  sfm::Gas::CO2 , sfm::Gas::Ar , sfm::Gas::HeOx , sfm::Gas::AirO2 ,
  sfm::Gas::N2OO2 , sfm::Gas::CO2O2 , sfm::Gas::HeOxO2
}
 A calibrated gas or gas mixture. Which gases a part offers is in its table row. More...
 
enum class  sfm::ScalingCheck : uint8_t { sfm::ScalingCheck::Strict = 0 , sfm::ScalingCheck::Lenient , sfm::ScalingCheck::Off }
 What ReadScaling() does when the sensor's scale or offset differs from the datasheet. More...
 
enum class  sfm::RangePolicy : uint8_t { sfm::RangePolicy::Reject = 0 , sfm::RangePolicy::Flag }
 What ReadSample() does with a flow or temperature outside the part's span. More...
 
enum class  sfm::TimingPolicy : uint8_t { sfm::TimingPolicy::Conservative = 0 , sfm::TimingPolicy::Datasheet }
 Which waits the driver uses after a reset or a wake. More...
 
enum class  sfm::State : uint8_t {
  sfm::State::Uninitialized = 0 , sfm::State::Idle , sfm::State::Measuring , sfm::State::Asleep ,
  sfm::State::StateUnknown
}
 The driver's shadow of the chip's mode. More...
 

Functions

constexpr const char * sfm::ToString (Error error) noexcept
 The name of an error, for logs.
 
constexpr uint32_t sfm::FamilyBit (Family f) noexcept
 A bit in a family mask: SfmFlowMeter<Port, kFamilySf06 | kFamilySf05>.
 
constexpr const char * sfm::GetDriverVersion () noexcept
 
constexpr uint32_t sfm::GetDriverVersionMajor () noexcept
 
constexpr uint32_t sfm::GetDriverVersionMinor () noexcept
 
constexpr uint32_t sfm::GetDriverVersionPatch () noexcept
 

Variables

constexpr uint32_t sfm::kFamilySf06 = 1U << 0
 Family mask bits.
 
constexpr uint32_t sfm::kFamilySf06Gen2 = 1U << 1
 Family::Sf06Gen2.
 
constexpr uint32_t sfm::kFamilySf06Dual = 1U << 2
 Family::Sf06Dual.
 
constexpr uint32_t sfm::kFamilySf05 = 1U << 3
 Family::Sf05.
 
constexpr uint32_t sfm::kFamilySf04 = 1U << 4
 Family::Sf04.
 
constexpr uint32_t sfm::kFamilySfx6000 = 1U << 5
 
constexpr uint32_t sfm::kAllFamilies = 0x3FU
 Every family: the default mask.
 
constexpr uint16_t sfm::kAveragingDefault = 0xFFFFU
 Marks Config::averaging as "the family's reset value".
 
constexpr uint16_t sfm::kFilterDefault = 50961U
 The filter argument of the default 3 ms response (SFM3304, SFM3505).
 

Detailed Description

Errors, results, families, variants, samples and configuration.

Enumeration Type Documentation

◆ Error

enum class sfm::Error : uint8_t
strong

Why a call failed. Every call of the driver returns one of these in its Result.

Values 0 to 9 are the shared base set; chip-specific values start at 16. [[nodiscard]] on the type: a function that returns a bare Error cannot have it ignored either (KB-CPP20-037).

Enumerator
Ok 

The call succeeded.

NotInitialized 

EnsureInitialized() has not succeeded, or Deinitialize() ran since.

InvalidArgument 

An argument or a Config field is out of range; nothing was sent.

Bus 

A write hook returned false.

Timeout 

A bounded wait or poll ended: wake, reset, stretched read.

DeviceIdMismatch 

The product identifier is not the configured part (or a prototype).

Crc 

A received word failed its CRC-8; the whole transfer was discarded.

Busy 

The call is not allowed in the current mode, or a wait is pending.

DeviceFault 

The scaling the sensor reports differs from the part's datasheet value.

Unsupported 

The part, the port hook or the family mask does not offer this call.

NoData 

The read header was NACKed: no new sample yet (or the sensor is idle).

NoDevice 

The address is not acknowledged on a write, a poll or initialisation.

OutOfRange 

A flow or temperature outside the part's span plus margin.

StatusMismatch 

The status word does not describe the measurement the driver started.

Stale 

The sample may not be fresh enough (settling, smoothing or age).

DeviceReset 

The measurement is over (the sensor reset, or was silent for the whole bound): idle again.

StateUnknown 

A failed command left the chip's mode unknown; initialise again.

InvalidReply 

A CRC-valid reply the sensor cannot send (stuck line, reserved value).

◆ Family

enum class sfm::Family : uint8_t
strong

The command-set family of a part. One protocol policy per family; every part is a row of data that names its family.

Enumerator
Sf06 

SFM4300, SFM3003, SFM3013, SFM3019, SFM3119: 16-bit commands, 9-byte frame.

Sf06Gen2 

SFM3304: SF06 framing, one gas, optional filter argument, status with averaging.

Sf06Dual 

SFM3505: two 24-bit flows (air and oxygen) in one frame.

Sf05 

SFM3000, SFM3200, SFM3300, SFM3400, SFM4200: pointer registers, 5 V.

Sf04 

SFM4100: 8-bit commands, clock-stretching read, one gas per address.

Sfx6000 

SFM6000D: preliminary vendor protocol (every fact tagged [P] in the docs).

◆ Gas

enum class sfm::Gas : uint8_t
strong

A calibrated gas or gas mixture. Which gases a part offers is in its table row.

Enumerator
Air 

Air.

O2 

Oxygen.

N2 

Nitrogen (every SF05 part, at the air scale).

N2O 

Nitrous oxide.

CO2 

Carbon dioxide.

Ar 

Argon.

HeOx 

Heliox 80/20 (SFM3013-300-CLM).

AirO2 

Mixture of air and oxygen; o2_permille is the oxygen fraction.

N2OO2 

Mixture of nitrous oxide and oxygen.

CO2O2 

Mixture of carbon dioxide and oxygen.

HeOxO2 

Mixture of heliox and oxygen.

◆ LogLevel

enum class sfm::LogLevel : uint8_t
strong

Severity passed to the optional Log() hook.

Enumerator
Error 

A call failed.

Warning 

Something unexpected that the driver recovered from.

Info 

Lifecycle events: initialised, reset.

Debug 

Detail for bring-up.

◆ RangePolicy

enum class sfm::RangePolicy : uint8_t
strong

What ReadSample() does with a flow or temperature outside the part's span.

Enumerator
Reject 

OutOfRange, no value.

Flag 

The value is returned with Sample::out_of_range set; never clamped.

◆ ScalingCheck

enum class sfm::ScalingCheck : uint8_t
strong

What ReadScaling() does when the sensor's scale or offset differs from the datasheet.

Enumerator
Strict 

Any difference or a wrong unit is DeviceFault.

Lenient 

A scale within 1 % of the table is accepted; offset and unit still checked.

Off 

The sensor's values are used; only scale 0 and the unit are checked.

◆ State

enum class sfm::State : uint8_t
strong

The driver's shadow of the chip's mode.

Enumerator
Uninitialized 

EnsureInitialized() has not succeeded.

Idle 

Initialised, not measuring.

Measuring 

A measurement is running; ReadSample() is legal.

Asleep 

In sleep mode; only WakeUp() is legal.

StateUnknown 

A failed command left the mode unknown; only initialisation is legal.

◆ TimingPolicy

enum class sfm::TimingPolicy : uint8_t
strong

Which waits the driver uses after a reset or a wake.

Enumerator
Conservative 

At least 20 ms for every SF06 reset and wake (the longest in the family).

Datasheet 

The part's own maxima; needs a known variant.

◆ Variant

enum class sfm::Variant : uint8_t
strong

A part (one row of the table in sfm_flow_meter_parts.hpp). The names follow the vendor's ordering suffixes; _B, _O and _P are the SFM4300 fittings.

Enumerator
Auto 

Identify the part by its product identifier inside the configured family.

SFM4300_20_B 

SFM4300-20-B, 0 to 20 slm, base-mount flanges.

SFM4300_20_O 

SFM4300-20-O, O-ring connection.

SFM4300_20_P 

SFM4300-20-P, push-in fittings.

SFM4300_50_B 

SFM4300-50-B, 0 to 50 slm.

SFM4300_50_O 

SFM4300-50-O.

SFM4300_50_P 

SFM4300-50-P.

SFM3003_300_CL 

SFM3003-300-CL, -30 to 300 slm, address 0x28.

SFM3003_300_CE 

SFM3003-300-CE, -150 to 300 slm, address 0x2D.

SFM3003_300_CET 

SFM3003-300-CET, with a gas temperature sensor, address 0x2A.

SFM3013_300_CL 

SFM3013-300-CL, address 0x2F.

SFM3013_300_CLM 

SFM3013-300-CLM, adds heliox, address 0x2F.

SFM3019_200_CL 

SFM3019-200-CL, address 0x2E.

SFM3119_240_CL 

SFM3119-240-CL, address 0x29.

SFM3304_250_D 

SFM3304-250-D, -250 to 250 slm, 3.3 V, address 0x2E.

SFM3505_300 

SFM3505-300, air and oxygen channels.

SFM3505_300_X 

SFM3505-300-X.

SFM3000_200_C 

SFM3000-200-C, 5 V, address 0x40, legacy.

SFM3200 

SFM3200, 5 V, legacy.

SFM3200_AW 

SFM3200-AW, with temperature output.

SFM3300_D 

SFM3300-D.

SFM3300_AW 

SFM3300-AW.

SFM3400_D 

SFM3400-D, -33 to 33 slm.

SFM3400_AW 

SFM3400-AW.

SFM4200 

SFM4200, 0 to 160 slm, /RES pin, 100 kHz, legacy.

SFM4100_AIR 

SFM4100-Air, address 1, clock stretching, legacy.

SFM4100_O2 

SFM4100-O2, address 2.

SFM4100_CO2 

SFM4100-CO2, address 3.

SFM4100_N2O 

SFM4100-N2O, address 4.

SFM4100_AR 

SFM4100-Ar, address 5.

SFM6000D_50 

SFM6000D-50, preliminary protocol.

SFM6000D_20 

SFM6000D-20, preliminary protocol.

SFM6000D_5 

SFM6000D-5, preliminary protocol.

Function Documentation

◆ FamilyBit()

constexpr uint32_t sfm::FamilyBit ( Family  f)
constexprnoexcept

A bit in a family mask: SfmFlowMeter<Port, kFamilySf06 | kFamilySf05>.

Parameters
fThe family.
Returns
The mask bit of f.

◆ GetDriverVersion()

constexpr const char * sfm::GetDriverVersion ( )
constexprnoexcept
Returns
The driver version, e.g. "0.1.0", from the generated sfm_flow_meter_version.h. No I/O.

◆ GetDriverVersionMajor()

constexpr uint32_t sfm::GetDriverVersionMajor ( )
constexprnoexcept
Returns
The major version. No I/O.

◆ GetDriverVersionMinor()

constexpr uint32_t sfm::GetDriverVersionMinor ( )
constexprnoexcept
Returns
The minor version. No I/O.

◆ GetDriverVersionPatch()

constexpr uint32_t sfm::GetDriverVersionPatch ( )
constexprnoexcept
Returns
The patch version. No I/O.

◆ ToString()

constexpr const char * sfm::ToString ( Error  error)
constexprnoexcept

The name of an error, for logs.

Parameters
errorThe error.
Returns
A static string such as "Timeout"; "Unknown" for a value that is not an enumerator.

Variable Documentation

◆ kFamilySf06

constexpr uint32_t sfm::kFamilySf06 = 1U << 0
inlineconstexpr

Family mask bits.

Family::Sf06.

◆ kFamilySfx6000

constexpr uint32_t sfm::kFamilySfx6000 = 1U << 5
inlineconstexpr