|
| | NtcThermistor (Port &port, const Config &config) noexcept |
| | Bind the driver to a port and store the configuration. No I/O, cannot fail.
|
| |
|
| NtcThermistor (const NtcThermistor &)=delete |
| | One driver object per thermistor.
|
| |
|
NtcThermistor & | operator= (const NtcThermistor &)=delete |
| | One driver object per thermistor.
|
| |
| Result< void > | EnsureInitialized () noexcept |
| | Start the driver, once: the only way to initialise it.
|
| |
| bool | IsInitialized () const noexcept |
| |
| Result< Reading > | Read () noexcept |
| | Read the temperature: bias on, settle, sample_count conversions, bias off, convert.
|
| |
| Result< uint32_t > | ReadResistance () noexcept |
| | Read the thermistor's resistance in ohms: the divider arithmetic only, no curve and no window.
|
| |
| Result< uint32_t > | ReadRawCode () noexcept |
| | One raw conversion, with no averaging and no conversion: bias on, settle, one sample, bias off. A diagnostic: it is the code the port returned, and it has no retry.
|
| |
| Result< void > | SetConfig (const Config &config) noexcept |
| | Replace the configuration. It is validated first; on failure the old one stays.
|
| |
| const Config & | GetConfig () const &noexcept |
| |
|
void | GetConfig () const &&=delete |
| | Not on a temporary driver: the reference would dangle (handbook KB-CPP20-044).
|
| |
| uint32_t | GetLastCode () const noexcept |
| |
template<AdcPort Port>
class ntc_thermistor::NtcThermistor< Port >
Driver for one NTC thermistor in a resistor divider on an ADC port.
Lifecycle: construct with the configuration (no I/O), then EnsureInitialized(), the one way to start; use; replace the configuration with SetConfig(). Every call that touches the port returns Error::NotInitialized until EnsureInitialized() has succeeded; no call starts it as a side effect.
Optional hooks: void DelayUs(uint32_t) (the wait between samples, sample_delay_us, and the settling time, settle_us; a Config that needs a wait the port cannot make is InvalidArgument) and bool SetBias(bool) (powers the divider only while sampling).
- Template Parameters
-
Start the driver, once: the only way to initialise it.
Checks the configuration (and that the port has the hooks it needs), brings the ADC up and, when the port has SetBias(), switches the divider off so that the first reading starts from a known state. After it succeeds, later calls return Ok at once with no I/O. After it fails, the driver stays uninitialised and the next call starts again.
- Returns
Ok, InvalidArgument (the configuration fails Validate() or needs a hook the port lacks; no port call) or Bus.