51#ifndef SBL_HW_HAL_ADC_DRIVER_HPP_
52#define SBL_HW_HAL_ADC_DRIVER_HPP_
82template<
typename Driver>
84 Driver::configure_channel(handle, sample_time);
85 Driver::start_conversion(handle);
86 while (!Driver::is_conversion_complete()) {
89 return Driver::read_raw();
102template<
typename Driver>
104 constexpr uint32_t MAX_VALUE = (1u << Driver::resolution_bits()) - 1;
105 return (
static_cast<uint32_t
>(raw_value) * vref_mv) / MAX_VALUE;
uint32_t to_millivolts(uint16_t raw_value, uint32_t vref_mv=3300)
Convert raw ADC value to voltage (millivolts)
uint16_t read(const AdcHandle &handle, SampleTime sample_time=SampleTime::Medium)
Blocking single-channel ADC read.
SampleTime
ADC sample time configuration.
Resolution
ADC resolution configuration.
Root namespace for all Sound Byte Libs code.
UART handle type for hardware abstraction.