|
| | MCP9700 (Port &port, const Config &config={}) noexcept |
| | Bind the driver to a port and store the configuration. No I/O, cannot fail.
|
| |
|
| MCP9700 (const MCP9700 &)=delete |
| | One driver object per sensor.
|
| |
|
MCP9700 & | operator= (const MCP9700 &)=delete |
| | One driver object per sensor.
|
| |
| Result< void > | EnsureInitialized () noexcept |
| | Start the sensor, once: the only way to initialise the driver.
|
| |
| bool | IsInitialized () const noexcept |
| |
| Result< void > | Deinitialize () noexcept |
| | Mark the driver uninitialised and switch the sensor off when the port has GpioSet(); the next EnsureInitialized() starts it again (the recovery after a fault). Ok with no I/O when it was not initialised.
|
| |
| Result< void > | Sleep () noexcept |
| | Switch the sensor off; EnsureInitialized() powers it again.
|
| |
| Result< Measurement > | ReadMeasurement () noexcept |
| | The validated reading: discard_conversions dummy conversions, then samples averaged.
|
| |
| Result< int32_t > | ReadTemperatureMilliC () noexcept |
| | The temperature of ReadMeasurement(), milli-degrees Celsius, after offset_cal_mc.
|
| |
| Result< uint32_t > | ReadOutputMv () noexcept |
| | The mean output voltage at VOUT (scaled by the divider), validated like a reading.
|
| |
| Result< uint32_t > | ReadRawPortMv () noexcept |
| | One conversion, once: no scaling, no check, no retry (handbook KB-CPP-129). For bring-up.
|
| |
| uint32_t | GetLastRawPortMv () const noexcept |
| |
| uint32_t | ResolutionMilliC () const noexcept |
| | One ADC step expressed in milli-degrees at the current slope, rounded up. No I/O.
|
| |
| const Config & | GetConfig () const &noexcept |
| |
|
void | GetConfig () const &&=delete |
| | Not on a temporary driver: the reference would dangle (handbook KB-CPP20-044).
|
| |
| Result< VariantSpec > | GetSpec () const noexcept |
| | The effective variant row (a table row, or the one built from the Custom declaration). No I/O.
|
| |
template<AdcPort Port>
class mcp9700::MCP9700< Port >
Driver for one MCP970x analog temperature sensor (or a declared Custom part) on an ADC port.
Lifecycle: construct with the configuration (no I/O), then EnsureInitialized(), the one way to start, use, optionally Deinitialize() or Sleep(). Every call that touches the sensor returns Error::NotInitialized until EnsureInitialized() has succeeded; no call starts it as a side effect.
Hooks beyond the two required ADC ones: void DelayUs(uint32_t) (required by every wait: a missing one is a compile error), bool GpioSet(CtrlPin,
GpioSignal) (the sensor's supply from an MCU pin; without it Sleep() returns Unsupported), void Log(LogLevel, const char*).
A reading never retries and never clamps: a failed read is reported once, and a failed read does not uninitialise the driver.
- Template Parameters
-
Start the sensor, once: the only way to initialise the driver.
Checks the configuration, brings the ADC up, powers the sensor (GpioSet, when the port has it), waits power_on_settle_us (the datasheet gives t_ON typical only, 800 us), then takes one validated reading: the analog equivalent of a chip-ID check. After it succeeds, later calls return Ok at once with no I/O. After it fails the sensor is switched off again (best effort), the driver stays uninitialised and the next call starts again.
- Returns
Ok, InvalidArgument (the configuration fails Validate(); no I/O), Bus, or DeviceIdMismatch (no plausible, stable output on the channel).
The validated reading: discard_conversions dummy conversions, then samples averaged.
Sends exactly discard_conversions + samples conversions, never retries. Checks, in this order of precedence: Bus (stops at the first failed conversion), Saturated, Unstable, then OutputLow / OutputHigh against the specified range plus range_margin_mc.
- Returns
- The measurement, or
NotInitialized, Bus, Saturated, Unstable, OutputLow or OutputHigh.