HF-ADS7952 Driver 0.1.0-dev
HF-ADS7952 C++ Driver
Loading...
Searching...
No Matches
Conversion Helpers

Lightweight utility functions for engineering-unit conversion. More...

Functions

constexpr uint16_t ads7952::VoltageToCount (float voltage, float vref) noexcept
 Convert a voltage to a 12-bit ADC count.
 

Detailed Description

Lightweight utility functions for engineering-unit conversion.

Function Documentation

◆ VoltageToCount()

constexpr uint16_t ads7952::VoltageToCount ( float voltage,
float vref )
constexprnoexcept

Convert a voltage to a 12-bit ADC count.

Useful for computing alarm thresholds from engineering units. The result is clamped to 0–4095.

Parameters
voltageTarget voltage in volts
vrefReference voltage in volts
Returns
uint16_t 12-bit ADC count
uint16_t low = ads7952::VoltageToCount(0.5f, 2.5f); // → 819
uint16_t high = ads7952::VoltageToCount(2.0f, 2.5f); // → 3276
adc.ProgramAlarm(0, ads7952::AlarmBound::Low, low);
constexpr uint16_t VoltageToCount(float voltage, float vref) noexcept
Convert a voltage to a 12-bit ADC count.
@ Low
Low alarm threshold register.

Definition at line 276 of file ads7952_types.hpp.

Referenced by ads7952::ADS7952< SpiType >::ProgramAlarmVoltage().