|
NTC Thermistor Driver
API reference
|
CRTP-based template interface for ADC operations. More...
#include <ntc_adc_interface.hpp>
Public Member Functions | |
| bool | IsInitialized () const |
| Check if ADC is initialized. | |
| bool | EnsureInitialized () |
| Ensure ADC is initialized, initializing if necessary. | |
| bool | IsChannelAvailable (uint8_t channel) const |
| Check if a specific ADC channel is available. | |
| AdcError | ReadChannelCount (uint8_t channel, uint32_t *count) |
| Read raw ADC count value from specified channel. | |
| AdcError | ReadChannelV (uint8_t channel, float *voltage_v) |
| Read voltage value from specified channel. | |
| float | GetReferenceVoltage () const |
| Get the reference voltage of the ADC. | |
| uint8_t | GetResolutionBits () const |
| Get the ADC resolution in bits. | |
| AdcInterface (const AdcInterface &)=delete | |
| AdcInterface & | operator= (const AdcInterface &)=delete |
| AdcInterface (AdcInterface &&)=default | |
| AdcInterface & | operator= (AdcInterface &&)=default |
Protected Member Functions | |
| AdcInterface ()=default | |
| Protected constructor to prevent direct instantiation. | |
| ~AdcInterface ()=default | |
| Protected destructor. | |
CRTP-based template interface for ADC operations.
This template class provides a hardware-agnostic interface for ADC operations using the CRTP pattern. Platform-specific implementations should inherit from this template with themselves as the template parameter.
Benefits of CRTP:
Example usage:
Optional hook: void DelayMs(uint32_t ms) in the derived class. When the port provides it, the driver waits sample_delay_ms between averaged samples through it (an RTOS sleep or a timed busy-wait). A port without it takes the samples back to back and sample_delay_ms has no effect. The hook is detected at compile time; it is deliberately not declared in this base class.
| Derived | The derived class type (CRTP pattern) |
|
delete |
|
default |
|
protecteddefault |
Protected constructor to prevent direct instantiation.
|
protecteddefault |
Protected destructor.
|
inline |
Ensure ADC is initialized, initializing if necessary.
|
inline |
Get the reference voltage of the ADC.
|
inline |
Get the ADC resolution in bits.
|
inline |
Check if a specific ADC channel is available.
| channel | ADC channel number to check |
|
inline |
Check if ADC is initialized.
|
default |
|
delete |
|
inline |
Read raw ADC count value from specified channel.
| channel | ADC channel to read from |
| count | Pointer to store the raw count value |
|
inline |
Read voltage value from specified channel.
| channel | ADC channel to read from |
| voltage_v | Pointer to store the voltage value in volts |