SFM_FLOW_METER Driver 0.1.0
API reference
Loading...
Searching...
No Matches
Classes | Namespaces | Functions | Variables
sfm_flow_meter_parts.hpp File Reference

The table of supported parts: one row of data per variant, the lookups, Validate() and the unit conversions. More...

#include <algorithm>
#include <array>
#include <cstddef>
#include <cstdint>
#include "sfm_flow_meter_detail.hpp"
#include "sfm_flow_meter_registers.hpp"
#include "sfm_flow_meter_types.hpp"

Go to the source code of this file.

Classes

struct  sfm::Scaling
 Counts per slm as the rational num / den, the offset and the unit word of one gas. More...
 
struct  sfm::GasRow
 One calibrated gas of a part: its start code, its status index and its scaling. More...
 
struct  sfm::TempRow
 The temperature scaling of a part. More...
 
struct  sfm::Timing
 Timings of a part in microseconds: the datasheet maxima. More...
 
struct  sfm::AddressSet
 The addresses a part may use; list[0] is the default. More...
 
struct  sfm::GasList
 The gases of a part. More...
 
struct  sfm::PartInfo
 One row of the part table. More...
 
class  sfm::CheckedConfig
 A configuration proven valid at build time. More...
 

Namespaces

namespace  sfm
 The SFM flow meter driver: everything it declares lives here; internals in detail.
 
namespace  sfm::feature
 Feature bits of a part (PartInfo::features); a clear bit makes the call Unsupported.
 
namespace  sfm::parts
 The part table: what the code, the docs generators and the tests read.
 

Functions

constexpr const PartInfo * sfm::FindPart (Variant variant) noexcept
 The table row of a variant.
 
constexpr const PartInfo * sfm::FindById (Family family, uint32_t id, uint8_t address) noexcept
 The table row that a product identifier and address select inside one family.
 
constexpr const PartInfo * sfm::FamilyRow (Family family) noexcept
 The first row of a family: what Variant::Auto uses for waits before the part is known.
 
constexpr const GasRow * sfm::FindGas (const PartInfo &part, Gas gas) noexcept
 The gas row of a part.
 
constexpr bool sfm::Has (const PartInfo &part, uint32_t bits) noexcept
 
constexpr Capabilities sfm::CapabilitiesOf (const PartInfo &part) noexcept
 
constexpr int64_t sfm::DivideRounded (int64_t value, int64_t divisor) noexcept
 Divide value by divisor rounding to nearest, ties away from zero.
 
constexpr int32_t sfm::FlowMlPerMin (int32_t raw, const Scaling &scaling) noexcept
 A raw flow in millilitres per minute: (raw - offset) * 1000 * den / num, rounded.
 
constexpr int32_t sfm::TemperatureMdegC (int32_t raw, const TempRow &row) noexcept
 A raw temperature in milli-degrees Celsius: (raw - offset) * 1000 / scale, rounded.
 
constexpr Error sfm::Validate (const Config &config) noexcept
 Check a configuration against the part it names, without touching the chip.
 
constexpr Config sfm::PresetFor (Variant variant) noexcept
 A part's datasheet defaults as a configuration.
 
void sfm::ConfigIsInvalid () noexcept
 Reached only when a CheckedConfig is built from an invalid configuration: it is never defined, so the build fails and names it (KB-CPP20-013).
 

Variables

constexpr uint32_t sfm::feature::kScaleRead = 1U << 0
 ReadScaling().
 
constexpr uint32_t sfm::feature::kAveraging = 1U << 1
 SetAveraging().
 
constexpr uint32_t sfm::feature::kAveragingZero = 1U << 2
 N = 0 (average until read) is legal.
 
constexpr uint32_t sfm::feature::kConcentration = 1U << 3
 UpdateConcentration().
 
constexpr uint32_t sfm::feature::kSleep = 1U << 4
 Sleep() and WakeUp().
 
constexpr uint32_t sfm::feature::kStatusWord = 1U << 5
 The frame carries a status word.
 
constexpr uint32_t sfm::feature::kTemperatureFrame = 1U << 6
 The frame carries the temperature.
 
constexpr uint32_t sfm::feature::kTemperatureRead
 ReadTemperature() by a pointer sequence.
 
constexpr uint32_t sfm::feature::kGeneralCallReset = 1U << 8
 SoftReset() is the general call.
 
constexpr uint32_t sfm::feature::kSoftResetCommand
 SoftReset() is a command to the device.
 
constexpr uint32_t sfm::feature::kResetPin = 1U << 10
 HardReset() pulses /RES (SFM4200).
 
constexpr uint32_t sfm::feature::kClockStretch = 1U << 11
 Reads need ReadStretch() (SFM4100).
 
constexpr uint32_t sfm::feature::kFilterArg = 1U << 12
 The start command takes a filter argument.
 
constexpr uint32_t sfm::feature::kFirstByteAck = 1U << 13
 SF05: the first data byte must be ACKed.
 
constexpr uint32_t sfm::feature::kTwoFlows = 1U << 14
 The frame carries two flows (SFM3505).
 
constexpr uint32_t sfm::feature::kRestartBeforeRead = 1U << 15
 SF05: start again around each read.
 
constexpr uint32_t sfm::feature::kPowerCycle
 HardReset() is a supply cycle (needs a hook).
 
constexpr uint32_t sfm::feature::kWakeByte = 1U << 17
 Wake is address plus one dummy byte.
 
constexpr uint32_t sfm::feature::kIrqPin = 1U << 18
 The module has an IRQn or DRDY output.
 
constexpr std::size_t sfm::parts::kCount = 32
 Rows in the table: one per variant but Auto.
 
constexpr std::array< PartInfo, kCount > sfm::parts::kTable
 The table, in Variant order after Auto.
 

Detailed Description

The table of supported parts: one row of data per variant, the lookups, Validate() and the unit conversions.

A part is a row of data (PartInfo): family, addresses, scale and offset per gas, temperature scale, timings, feature flags, connector. The driver's code never names a part: it dispatches on PartInfo::family and on the feature flags of the row. static_asserts walk the table at build time, and pin one row per family against hand-typed datasheet values, so a mistyped digit fails the build and not a bench.

Rows of the Sfx6000 family come from an interface reference the vendor marks "preliminary": PartInfo::preliminary is true and every fact of those rows is tagged [P] in the docs.