ADS7952 Driver
API reference
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | List of all members
ads7952::ADS7952< SpiType > Class Template Reference

Main driver class for the ADS7952 ADC. More...

#include <ads7952.hpp>

Public Member Functions

 ADS7952 (SpiType &spi, float vref=ADS7952_CFG::DEFAULT_VREF, float va=ADS7952_CFG::DEFAULT_VA, Range initial_range=ADS7952_CFG::DEFAULT_RANGE) noexcept
 Construct a new ADS7952 driver instance.
 
 ADS7952 (const ADS7952 &)=delete
 
ADS7952 & operator= (const ADS7952 &)=delete
 
bool EnsureInitialized (bool force=false) noexcept
 Ensure the driver is initialized — idempotent, safe to call repeatedly.
 
bool IsInitialized () const noexcept
 Check if the driver has been initialized.
 
ReadResult ReadChannel (uint8_t channel) noexcept
 Read a single ADC channel (switches to Manual mode).
 
ChannelReadings ReadAllChannels () noexcept
 Read all channels in the current Auto-1 sequence.
 
float CountToVoltage (uint16_t count) const noexcept
 Convert raw count to voltage using the currently active reference.
 
uint16_t VoltageToCount (float voltage) const noexcept
 Convert a voltage to a 12-bit ADC count using the active reference.
 
bool EnterManualMode (uint8_t channel=0) noexcept
 Enter Manual mode, selecting the given channel for conversion.
 
bool EnterAuto1Mode (bool reset_counter=true) noexcept
 Enter Auto-1 mode (sequences through programmed channel mask).
 
bool EnterAuto2Mode (bool reset_counter=true) noexcept
 Enter Auto-2 mode (sequences channels 0 through last_channel).
 
Mode GetMode () const noexcept
 Get the current operating mode.
 
bool ProgramAuto1Channels (uint16_t channel_mask) noexcept
 Program the Auto-1 channel sequence.
 
bool ProgramAuto2LastChannel (uint8_t last_channel) noexcept
 Program the Auto-2 last channel.
 
bool ProgramGPIO (const GPIOConfig &config) noexcept
 Program GPIO pin functions, direction, and alarm routing.
 
bool ProgramAlarm (uint8_t channel, AlarmBound bound, uint16_t threshold_12bit) noexcept
 Program an alarm threshold for a single channel (count-based).
 
bool ProgramAlarmVoltage (uint8_t channel, AlarmBound bound, float voltage) noexcept
 Program an alarm threshold for a single channel (voltage-based).
 
bool SetRange (Range range) noexcept
 Set the input voltage range; in effect on the chip when this returns.
 
Range GetRange () const noexcept
 Get the current input range setting.
 
bool SetPowerDown (PowerDown pd) noexcept
 Set the power-down mode; in effect on the chip when this returns.
 
PowerDown GetPowerDown () const noexcept
 Get the current power-down setting.
 
bool SetGPIOOutputs (uint8_t gpio_state) noexcept
 Set GPIO output pin levels (for pins configured as outputs).
 
uint8_t GetGPIOOutputs () const noexcept
 Get the GPIO output levels last written (bits [3:0]).
 
float GetActiveVref () const noexcept
 Get the active voltage reference (affected by range setting).
 
float GetVref () const noexcept
 Get the configured Vref (REFP pin voltage).
 
float GetVA () const noexcept
 Get the configured VA supply voltage.
 
void SetVref (float vref) noexcept
 Update the Vref value for voltage calculations.
 
void SetVA (float va) noexcept
 Update the VA supply voltage value.
 
uint16_t GetAuto1ChannelMask () const noexcept
 Get the Auto-1 programmed channel mask. Bit ordering: bit N = channel N (bit 0 = CH0, bit 11 = CH11).
 
uint8_t GetAuto2LastChannel () const noexcept
 Get the Auto-2 programmed last channel.
 
uint8_t RawManualFrames (uint8_t channel, uint16_t *out, uint8_t n) noexcept
 Clock raw 16-bit frames and return every response word unparsed.
 

Static Public Member Functions

static constexpr float CountToVoltage (uint16_t count, float vref) noexcept
 Convert raw count to voltage with explicit reference.
 
static constexpr uint8_t GetDriverVersionMajor () noexcept
 Driver semantic major version.
 
static constexpr uint8_t GetDriverVersionMinor () noexcept
 Driver semantic minor version.
 
static constexpr uint8_t GetDriverVersionPatch () noexcept
 Driver semantic patch version.
 

Detailed Description

template<typename SpiType>
class ads7952::ADS7952< SpiType >

Main driver class for the ADS7952 ADC.

Provides a synchronous, command-oriented API over the ADS7952 SPI protocol. The class is transport-agnostic and relies on a CRTP SPI implementation.

Bus errors: when the port's transfer() returns false, the call that sent the frame stops there; bool functions return false and the reads return Error::SpiError. Driver state (mode, masks) is only updated after the frames that change it were transferred.

Template Parameters
SpiTypePlatform-specific SPI class derived from SpiInterface<SpiType>

Definition at line 81 of file ads7952.hpp.

Constructor & Destructor Documentation

◆ ADS7952()

template<typename SpiType >
ads7952::ADS7952< SpiType >::ADS7952 ( const ADS7952< SpiType > &  )
delete

Member Function Documentation

◆ CountToVoltage()

template<typename SpiType >
static constexpr float ads7952::ADS7952< SpiType >::CountToVoltage ( uint16_t  count,
float  vref 
)
inlinestaticconstexprnoexcept

Convert raw count to voltage with explicit reference.

Parameters
countRaw 12-bit ADC count (0-4095)
vrefReference voltage in volts
Returns
Voltage in volts

Definition at line 164 of file ads7952.hpp.

References ads7952::reg::MAX_COUNT.

◆ GetActiveVref()

template<typename SpiType >
float ads7952::ADS7952< SpiType >::GetActiveVref ( ) const
inlinenoexcept

Get the active voltage reference (affected by range setting).

Definition at line 388 of file ads7952.hpp.

◆ GetAuto1ChannelMask()

template<typename SpiType >
uint16_t ads7952::ADS7952< SpiType >::GetAuto1ChannelMask ( ) const
inlinenoexcept

Get the Auto-1 programmed channel mask. Bit ordering: bit N = channel N (bit 0 = CH0, bit 11 = CH11).

Definition at line 421 of file ads7952.hpp.

◆ GetAuto2LastChannel()

template<typename SpiType >
uint8_t ads7952::ADS7952< SpiType >::GetAuto2LastChannel ( ) const
inlinenoexcept

Get the Auto-2 programmed last channel.

Definition at line 424 of file ads7952.hpp.

◆ GetDriverVersionMajor()

template<typename SpiType >
static constexpr uint8_t ads7952::ADS7952< SpiType >::GetDriverVersionMajor ( )
inlinestaticconstexprnoexcept

Driver semantic major version.

Definition at line 451 of file ads7952.hpp.

◆ GetDriverVersionMinor()

template<typename SpiType >
static constexpr uint8_t ads7952::ADS7952< SpiType >::GetDriverVersionMinor ( )
inlinestaticconstexprnoexcept

Driver semantic minor version.

Definition at line 453 of file ads7952.hpp.

◆ GetDriverVersionPatch()

template<typename SpiType >
static constexpr uint8_t ads7952::ADS7952< SpiType >::GetDriverVersionPatch ( )
inlinestaticconstexprnoexcept

Driver semantic patch version.

Definition at line 455 of file ads7952.hpp.

◆ GetGPIOOutputs()

template<typename SpiType >
uint8_t ads7952::ADS7952< SpiType >::GetGPIOOutputs ( ) const
inlinenoexcept

Get the GPIO output levels last written (bits [3:0]).

Definition at line 379 of file ads7952.hpp.

◆ GetMode()

template<typename SpiType >
Mode ads7952::ADS7952< SpiType >::GetMode ( ) const
inlinenoexcept

Get the current operating mode.

Definition at line 205 of file ads7952.hpp.

◆ GetPowerDown()

template<typename SpiType >
PowerDown ads7952::ADS7952< SpiType >::GetPowerDown ( ) const
inlinenoexcept

Get the current power-down setting.

Definition at line 349 of file ads7952.hpp.

◆ GetRange()

template<typename SpiType >
Range ads7952::ADS7952< SpiType >::GetRange ( ) const
inlinenoexcept

Get the current input range setting.

Definition at line 332 of file ads7952.hpp.

◆ GetVA()

template<typename SpiType >
float ads7952::ADS7952< SpiType >::GetVA ( ) const
inlinenoexcept

Get the configured VA supply voltage.

Definition at line 394 of file ads7952.hpp.

◆ GetVref()

template<typename SpiType >
float ads7952::ADS7952< SpiType >::GetVref ( ) const
inlinenoexcept

Get the configured Vref (REFP pin voltage).

Definition at line 391 of file ads7952.hpp.

◆ IsInitialized()

template<typename SpiType >
bool ads7952::ADS7952< SpiType >::IsInitialized ( ) const
inlinenoexcept

Check if the driver has been initialized.

Definition at line 122 of file ads7952.hpp.

◆ operator=()

template<typename SpiType >
ADS7952 & ads7952::ADS7952< SpiType >::operator= ( const ADS7952< SpiType > &  )
delete

The documentation for this class was generated from the following files: