49 explicit StmAdc(ADC_HandleTypeDef* hal_handle,
hf_u8_t num_channels = 1)
noexcept;
62 hf_time_t timeBetweenSamples = 0)
noexcept override;
66 hf_time_t timeBetweenSamples = 0)
noexcept override;
69 float& channel_reading_v,
hf_u8_t numOfSamplesToAvg = 1,
70 hf_time_t timeBetweenSamples = 0)
noexcept override;
Abstract base class for ADC implementations in the HardFOC system.
hf_adc_err_t
Definition BaseAdc.h:115
uint32_t hf_u32_t
Platform-agnostic 32-bit unsigned integer type.
Definition HardwareTypes.h:52
hf_u32_t hf_time_t
Platform-agnostic time type in milliseconds.
Definition HardwareTypes.h:173
uint8_t hf_u8_t
Platform-agnostic 8-bit unsigned integer type.
Definition HardwareTypes.h:40
hf_u32_t hf_channel_id_t
Platform-agnostic channel identifier type.
Definition HardwareTypes.h:163
STM32 platform-specific type definitions for hardware abstraction.
Base class for ADCs.
Definition BaseAdc.h:196
STM32 ADC wrapper — wraps STM32 HAL ADC with full channel management.
Definition StmAdc.h:40
hf_u8_t GetMaxChannels() const noexcept override
Get the maximum number of channels supported by this ADC.
Definition StmAdc.cpp:71
bool Initialize() noexcept override
Initializes the ADC peripheral (must be implemented by derived classes).
Definition StmAdc.cpp:50
bool Deinitialize() noexcept override
Deinitializes the ADC peripheral (must be implemented by derived classes)..
Definition StmAdc.cpp:60
hf_adc_err_t ReadChannelV(hf_channel_id_t channel_id, float &channel_reading_v, hf_u8_t numOfSamplesToAvg=1, hf_time_t timeBetweenSamples=0) noexcept override
Read channel voltage.
Definition StmAdc.cpp:83
~StmAdc() noexcept override
Definition StmAdc.cpp:40
ADC_HandleTypeDef * GetHalHandle() const noexcept
Get the underlying HAL ADC handle.
Definition StmAdc.h:75
StmAdc(const hf_stm32_adc_config_t &config) noexcept
Construct with full configuration.
Definition StmAdc.cpp:34
hf_adc_err_t ReadChannelCount(hf_channel_id_t channel_id, hf_u32_t &channel_reading_count, hf_u8_t numOfSamplesToAvg=1, hf_time_t timeBetweenSamples=0) noexcept override
Read channel count (raw ADC value).
Definition StmAdc.cpp:111
bool IsChannelAvailable(hf_channel_id_t channel_id) const noexcept override
Check if a specific channel is available.
Definition StmAdc.cpp:75
float GetVref() const noexcept
Get the configured reference voltage.
Definition StmAdc.h:78
float CountToVoltage(hf_u32_t count) const noexcept
Convert raw ADC count to voltage.
Definition StmAdc.cpp:163
hf_u32_t GetMaxCount() const noexcept
Get the maximum ADC count for current resolution.
Definition StmAdc.cpp:159
static hf_adc_err_t ConvertHalStatus(hf_u32_t hal_status) noexcept
Convert HAL status to ADC error code.
Definition StmAdc.cpp:196
hf_adc_err_t ReadRawCount(hf_u32_t &count) noexcept
Perform a single ADC conversion and return the raw count.
Definition StmAdc.cpp:173
hf_u8_t GetResolutionBits() const noexcept
Get the current ADC resolution in bits.
Definition StmAdc.cpp:155
hf_stm32_adc_config_t config_
ADC configuration.
Definition StmAdc.h:96
hf_adc_err_t ReadChannel(hf_channel_id_t channel_id, hf_u32_t &channel_reading_count, float &channel_reading_v, hf_u8_t numOfSamplesToAvg=1, hf_time_t timeBetweenSamples=0) noexcept override
Read both channel count and voltage.
Definition StmAdc.cpp:138
ADC configuration for STM32.
Definition StmTypes.h:431
ADC_HandleTypeDef * hal_handle
Pointer to CubeMX-generated ADC handle.
Definition StmTypes.h:432
float vref_v
Reference voltage (V)
Definition StmTypes.h:434