|
HardFOC Vortex V1 HAL
Unified HAL API for the HardFOC Vortex motor-control platform (ESP32-C6, TMC9660)
|
Singleton manager for all analogue-to-digital channels on Vortex V1. More...
#include <AdcManager.h>
Public Member Functions | |
| AdcManager (const AdcManager &)=delete | |
| AdcManager & | operator= (const AdcManager &)=delete |
| AdcManager (AdcManager &&)=delete | |
| AdcManager & | operator= (AdcManager &&)=delete |
| bool | EnsureInitialized () noexcept |
| Initialise the ADC subsystem if not already initialised. | |
| bool | Deinitialize () noexcept |
| Release all ADC resources and reset to uninitialised state. | |
| bool | IsInitialized () const noexcept |
| Check whether the ADC subsystem has been initialised. | |
| BaseAdc * | Get (std::string_view name) noexcept |
| Get the BaseAdc driver for a named channel. | |
| BaseAdc * | Get (HfFunctionalAdcChannel channel) noexcept |
| Get the BaseAdc driver by functional enum — O(1) lookup. | |
| bool | Contains (std::string_view name) const noexcept |
| Check whether a named ADC channel is registered. | |
| size_t | Size () const noexcept |
| Get the number of registered ADC channels. | |
| hf_adc_err_t | ReadVoltage (std::string_view name, float &voltage, hf_u8_t samples=1, hf_time_t timeBetweenSamples=0) noexcept |
| Read voltage from a channel by name (already divided if divider > 1). | |
| hf_adc_err_t | ReadVoltage (HfFunctionalAdcChannel channel, float &voltage, hf_u8_t samples=1, hf_time_t timeBetweenSamples=0) noexcept |
| Read voltage from a channel by enum — O(1) lookup, preferred for real-time paths. | |
| hf_adc_err_t | ReadRaw (std::string_view name, uint32_t &raw_value, hf_u8_t numOfSamplesToAvg=1, hf_time_t timeBetweenSamples=0) noexcept |
| Read raw ADC value from a channel by name. | |
| hf_adc_err_t | ReadRaw (HfFunctionalAdcChannel channel, uint32_t &raw_value, hf_u8_t numOfSamplesToAvg=1, hf_time_t timeBetweenSamples=0) noexcept |
| Read raw ADC value from a channel by functional enum. | |
| hf_adc_err_t | GetSystemDiagnostics (AdcSystemDiagnostics &diagnostics) const noexcept |
| Populate an AdcSystemDiagnostics snapshot. | |
| hf_adc_err_t | GetLastError () const noexcept |
| Get the most recent error code from any ADC operation. | |
| void | DumpStatistics () const noexcept |
| Log ADC channel statistics and health info to the console. | |
Static Public Member Functions | |
| static AdcManager & | GetInstance () noexcept |
| Return the singleton AdcManager instance. | |
Private Member Functions | |
| AdcManager () noexcept=default | |
| ~AdcManager () | |
| bool | Initialize () noexcept |
| size_t | FindByName (std::string_view name) const noexcept |
| Find entry index by string name. Returns kInvalidIndex if not found. | |
| size_t | FindByEnum (HfFunctionalAdcChannel channel) const noexcept |
| Find entry index by functional enum. Returns kInvalidIndex if not found. | |
Private Attributes | |
| std::array< AdcEntry, kMaxChannels > | entries_ {} |
| size_t | registered_count_ {0} |
| std::optional< Tmc9660AdcWrapper > | tmc9660_adc_ |
| Single TMC9660 ADC wrapper — all channels route through this. | |
| MotorController * | motor_controller_ {nullptr} |
| MotorController dependency (non-owning pointer, set at init). | |
| std::atomic< bool > | initialized_ {false} |
| std::atomic< hf_adc_err_t > | last_error_ {hf_adc_err_t::ADC_SUCCESS} |
| std::atomic< bool > | warned_motor_controller_not_ready_ {false} |
| std::atomic< bool > | warned_tmc_handler_missing_ {false} |
| RtosMutex | mutex_ |
Static Private Attributes | |
| static constexpr size_t | kMaxChannels |
| static constexpr size_t | kInvalidIndex = SIZE_MAX |
Singleton manager for all analogue-to-digital channels on Vortex V1.
Provides a uniform API over the ESP32 internal ADC and the TMC9660 motor-controller ADC. Channels are registered from the pincfg X-MACRO table at initialisation and looked up by name or by functional enum.
|
delete |
|
delete |
|
privatedefaultnoexcept |
|
privatedefault |
|
noexcept |
Check whether a named ADC channel is registered.
| name | Channel name to look up. |
|
noexcept |
Release all ADC resources and reset to uninitialised state.
|
noexcept |
Log ADC channel statistics and health info to the console.
|
noexcept |
Initialise the ADC subsystem if not already initialised.
|
privatenoexcept |
Find entry index by functional enum. Returns kInvalidIndex if not found.
|
privatenoexcept |
Find entry index by string name. Returns kInvalidIndex if not found.
|
noexcept |
Get the BaseAdc driver by functional enum — O(1) lookup.
| channel | Functional ADC channel enum. |
|
noexcept |
Get the BaseAdc driver for a named channel.
| name | Channel name from the pincfg table (linear scan). |
|
staticnoexcept |
|
inlinenoexcept |
Get the most recent error code from any ADC operation.
|
noexcept |
Populate an AdcSystemDiagnostics snapshot.
| [out] | diagnostics | Diagnostics structure to fill. |
|
privatenoexcept |
|
inlinenoexcept |
Check whether the ADC subsystem has been initialised.
|
delete |
|
delete |
|
noexcept |
Read raw ADC value from a channel by functional enum.
| channel | Functional ADC channel enum. |
| raw_value | Output: raw ADC count. |
| numOfSamplesToAvg | Number of samples to average (default 1). |
| timeBetweenSamples | Delay in ms between consecutive samples (default 0). |
|
noexcept |
Read raw ADC value from a channel by name.
| name | Channel name (linear scan). |
| raw_value | Output: raw ADC count. |
| numOfSamplesToAvg | Number of samples to average (default 1). |
| timeBetweenSamples | Delay in ms between consecutive samples (default 0). |
|
noexcept |
Read voltage from a channel by enum — O(1) lookup, preferred for real-time paths.
| channel | Functional ADC channel enum |
| voltage | Output: voltage at the input, if divider == 1, or bus voltage |
| samples | Number of samples to average (default 1) |
| timeBetweenSamples | Delay in ms between consecutive samples (default 0) |
|
noexcept |
Read voltage from a channel by name (already divided if divider > 1).
| name | Channel name (linear string search — use enum overload in tight loops) |
| voltage | Output: voltage at the input, if divider == 1, or bus voltage |
| samples | Number of samples to average (default 1) |
| timeBetweenSamples | Delay in ms between consecutive samples (default 0) |
|
noexcept |
Get the number of registered ADC channels.
|
private |
|
private |
|
staticconstexprprivate |
|
staticconstexprprivate |
|
private |
|
private |
MotorController dependency (non-owning pointer, set at init).
|
mutableprivate |
|
private |
|
private |
Single TMC9660 ADC wrapper — all channels route through this.
In place; emplaced at init
|
private |
Avoid repeating the same dependency warning when EnsureInitialized() is called from multiple subsystems (e.g. Vortex API then TemperatureManager) after a failed boot.
|
private |