|
HardFOC Core
API reference
|
Unified handler for ADS7952 12-channel SAR ADC with BaseAdc integration. More...
#include <Ads7952Handler.h>
Public Member Functions | |
| Ads7952Handler (BaseSpi &spi_interface, const Ads7952HandlerConfig &config=GetDefaultAds7952Config()) noexcept | |
| Construct ADS7952 handler with SPI interface. | |
| ~Ads7952Handler () noexcept override=default | |
| Destructor — automatically cleans up driver resources. | |
| Ads7952Handler (const Ads7952Handler &)=delete | |
| Ads7952Handler & | operator= (const Ads7952Handler &)=delete |
| Ads7952Handler (Ads7952Handler &&)=delete | |
| Ads7952Handler & | operator= (Ads7952Handler &&)=delete |
| bool | Initialize () noexcept override |
| Initialize the ADS7952 ADC (lazy initialization). | |
| bool | Deinitialize () noexcept override |
| Deinitialize the ADC and release driver resources. | |
| hf_u8_t | GetMaxChannels () const noexcept override |
| Get maximum number of ADC channels (always 12 for ADS7952). | |
| bool | IsChannelAvailable (hf_channel_id_t channel) const noexcept override |
| Check if a channel is available (0–11). | |
| hf_adc_err_t | ReadChannelV (hf_channel_id_t channel, float &voltage, hf_u8_t samples=1, hf_time_t timeout_ms=0) noexcept override |
| Read a channel and return voltage. | |
| hf_adc_err_t | ReadChannelCount (hf_channel_id_t channel, hf_u32_t &count, hf_u8_t samples=1, hf_time_t timeout_ms=0) noexcept override |
| Read a channel and return raw count. | |
| hf_adc_err_t | ReadChannel (hf_channel_id_t channel, hf_u32_t &count, float &voltage, hf_u8_t samples=1, hf_time_t timeout_ms=0) noexcept override |
| Read a channel and return both raw count and voltage. | |
| hf_adc_err_t | ReadMultipleChannels (const hf_channel_id_t *channels, hf_u8_t num_channels, hf_u32_t *counts, float *voltages) noexcept override |
| Read multiple channels in a single batch using Auto-1 mode. | |
| bool | ReadAllChannels (ads7952::ChannelReadings &readings) noexcept |
| Read all 12 channels using Auto-1 mode. | |
| bool | ReadAuto1Channels (uint16_t mask, ads7952::ChannelReadings &readings) noexcept |
| Auto-1 burst for a channel mask; stay in Auto-1 (no Manual hop). | |
| uint8_t | RawManualFrames (uint8_t channel, uint16_t *out, uint8_t n) noexcept |
| Bring-up trace: raw 16-bit response words for a manual select. | |
| bool | ProgramAlarm (uint8_t channel, ads7952::AlarmBound bound, uint16_t threshold_12bit) noexcept |
| Program alarm threshold for a channel (in 12-bit counts). | |
| bool | ProgramAlarmVoltage (uint8_t channel, ads7952::AlarmBound bound, float voltage) noexcept |
| Program alarm threshold for a channel (in voltage). | |
| bool | SetRange (ads7952::Range range) noexcept |
| Set the ADC input range. | |
| float | GetActiveVref () const noexcept |
| Get the current effective reference voltage. | |
| ads7952::ADS7952< Ads7952SpiAdapter > * | GetDriver () noexcept |
| Get raw pointer to the ADS7952 driver for advanced operations. | |
| const ads7952::ADS7952< Ads7952SpiAdapter > * | GetDriver () const noexcept |
| template<typename Fn > | |
| auto | visitDriver (Fn &&fn) noexcept -> decltype(fn(std::declval< ads7952::ADS7952< Ads7952SpiAdapter > & >())) |
| Visit the underlying ADS7952 driver under handler mutex protection. | |
| const char * | GetDescription () const noexcept |
| Get handler description string. | |
| bool | GetHandlerDiagnostics (Ads7952Diagnostics &diag) const noexcept |
| Get current diagnostics snapshot. | |
| void | DumpDiagnostics () const noexcept |
| Dump comprehensive diagnostics to log. | |
| uint8_t | GetDeviceIndex () const noexcept |
| Get the logical device index. | |
Private Member Functions | |
| bool | EnsureInitializedLocked () noexcept |
| Ensure initialized while mutex is already held. | |
| bool | ApplyConfiguration () noexcept |
| Apply configuration to the driver after init. | |
| ads7952::ReadResult | ReadChannelLocked (uint8_t channel) noexcept |
| Perform a single-channel read under lock (no mutex acquire). | |
Private Attributes | |
| BaseSpi & | spi_ref_ |
| Reference to SPI interface. | |
| std::unique_ptr< Ads7952SpiAdapter > | spi_adapter_ |
| CRTP SPI adapter. | |
| std::unique_ptr< ads7952::ADS7952< Ads7952SpiAdapter > > | adc_driver_ |
| ADS7952 driver. | |
| Ads7952HandlerConfig | config_ |
| Handler configuration. | |
| RtosMutex | handler_mutex_ |
| Thread safety mutex. | |
| char | description_ [64] |
| Description string. | |
| uint32_t | total_reads_ {0} |
| Successful read count. | |
| uint32_t | error_count_ {0} |
| Failed read count. | |
Unified handler for ADS7952 12-channel SAR ADC with BaseAdc integration.
Provides a comprehensive interface for the ADS7952 ADC with:
Architecture follows the same patterns as As5047uHandler:
|
explicitnoexcept |
Construct ADS7952 handler with SPI interface.
| spi_interface | Reference to BaseSpi implementation (e.g., EspSpiDevice) |
| config | Handler configuration (Vref, VA, range, mode, etc.) |
|
overridedefaultnoexcept |
Destructor — automatically cleans up driver resources.
|
delete |
|
delete |
|
privatenoexcept |
Apply configuration to the driver after init.
|
overridenoexcept |
Deinitialize the ADC and release driver resources.
|
noexcept |
Dump comprehensive diagnostics to log.
|
privatenoexcept |
Ensure initialized while mutex is already held.
|
noexcept |
Get the current effective reference voltage.
|
noexcept |
Get handler description string.
|
inlinenoexcept |
Get the logical device index.
|
noexcept |
|
noexcept |
Get raw pointer to the ADS7952 driver for advanced operations.
|
noexcept |
Get current diagnostics snapshot.
|
overridenoexcept |
Get maximum number of ADC channels (always 12 for ADS7952).
|
overridenoexcept |
Initialize the ADS7952 ADC (lazy initialization).
Creates the CRTP SPI adapter and ADS7952 driver instance, applies configuration (range, mode, channel mask), and verifies communication.
|
overridenoexcept |
Check if a channel is available (0–11).
| channel | Channel ID (0-based) |
|
delete |
|
delete |
|
noexcept |
Program alarm threshold for a channel (in 12-bit counts).
| channel | Channel number (0–11) |
| bound | High or Low alarm |
| threshold_12bit | 12-bit threshold value (0–4095) |
|
noexcept |
Program alarm threshold for a channel (in voltage).
| channel | Channel number (0–11) |
| bound | High or Low alarm |
| voltage | Threshold voltage |
|
noexcept |
Bring-up trace: raw 16-bit response words for a manual select.
| channel | Channel selected in frame 0. |
| out | Destination for n words (DO15:12 address, DO11:0 data). |
| n | Frames to clock (select + CONTINUEs). |
|
noexcept |
Read all 12 channels using Auto-1 mode.
| readings | Output: populated ChannelReadings structure |
|
noexcept |
Auto-1 burst for a channel mask; stay in Auto-1 (no Manual hop).
| mask | Bits 0–11; 0 uses ads7952::kAllChannels. | |
| [out] | readings | Per-channel counts for bits set in mask. |
|
overridenoexcept |
Read a channel and return both raw count and voltage.
| channel | Channel ID (0–11) |
| count | Output: raw 12-bit count |
| voltage | Output: converted voltage |
| samples | Number of samples to average (default 1) |
| timeout_ms | Timeout in ms (0 = default) |
|
overridenoexcept |
Read a channel and return raw count.
| channel | Channel ID (0–11) |
| count | Output: raw 12-bit ADC count (0–4095) |
| samples | Number of samples to average (default 1) |
| timeout_ms | Timeout in ms (0 = default) |
|
privatenoexcept |
Perform a single-channel read under lock (no mutex acquire).
|
overridenoexcept |
Read a channel and return voltage.
| channel | Channel ID (0–11) |
| voltage | Output: converted voltage |
| samples | Number of samples to average (default 1) |
| timeout_ms | Timeout in ms (0 = default) |
|
overridenoexcept |
Read multiple channels in a single batch using Auto-1 mode.
| channels | Array of channel IDs to read |
| num_channels | Number of channels to read |
| counts | Output array: raw 12-bit counts (may be nullptr) |
| voltages | Output array: converted voltages (may be nullptr) |
|
noexcept |
Set the ADC input range.
| range | Vref or 2*Vref (clamped to VA) |
|
inlinenoexcept |
Visit the underlying ADS7952 driver under handler mutex protection.
| Fn | Callable accepting ADS7952<Ads7952SpiAdapter>& |
|
private |
ADS7952 driver.
|
private |
Handler configuration.
|
private |
Description string.
|
mutableprivate |
Failed read count.
|
mutableprivate |
Thread safety mutex.
|
private |
CRTP SPI adapter.
|
private |
Reference to SPI interface.
|
mutableprivate |
Successful read count.