NTC_THERMISTOR Driver 0.1.0
API reference
Loading...
Searching...
No Matches
Classes | Namespaces | Concepts
ntc_thermistor_adc_interface.hpp File Reference

The ADC port of the NTC thermistor driver: the CRTP base and the AdcPort concept. More...

#include <concepts>
#include <cstdint>
#include "ntc_thermistor_detail.hpp"

Go to the source code of this file.

Classes

class  ntc_thermistor::AdcInterface< Derived >
 CRTP base of the platform ADC port. More...
 

Namespaces

namespace  ntc_thermistor
 The NTC thermistor driver: everything it declares lives here; internals in detail.
 

Concepts

concept  ntc_thermistor::AdcPort
 Satisfied by a class that derives from AdcInterface<Port> and implements the required hooks with exactly the types above, noexcept and returning bool (handbook KB-CPP20-006).
 

Detailed Description

The ADC port of the NTC thermistor driver: the CRTP base and the AdcPort concept.

A thermistor sits in a resistor divider whose node goes to an ADC channel of your MCU. The driver calls hooks on a class you derive from ntc_thermistor::AdcInterface<Self>:

Hook Contract
bool EnsureInitialized() noexcept Bring the ADC up on the first call; true at once afterwards
bool ReadRaw(uint8_t channel, uint32_t& code) noexcept One conversion of channel: the raw count, 0 to 2^bits - 1, bits = Config::adc_bits; no averaging, no volts; false on any ADC failure
void DelayUs(uint32_t us) noexcept Optional: wait at least us microseconds; needed by sample_delay_us and settle_us
bool SetBias(bool on) noexcept Optional: power the divider (from a GPIO) only while sampling; false when the pin could not be driven

The port returns the converter's raw count; the driver never configures the ADC (attenuation, width, sampling time). A port that only has calibrated millivolts maps them back to a code of adc_bits bits.