|
Sound Byte Libs 1ee2ca6
C++ firmware library for audio applications on 32-bit ARM Cortex-M processors
|
ADC driver interface - canonical types for MCU driver implementations. More...
Go to the source code of this file.
Namespaces | |
| namespace | sbl |
| Root namespace for all Sound Byte Libs functionality. | |
| namespace | sbl::adc |
Typedefs | |
| using | sbl::adc::SampleTime = sbl::core::hal::adc::SampleTime |
| using | sbl::adc::Resolution = sbl::core::hal::adc::Resolution |
Functions | |
| template<typename Driver > | |
| uint16_t | sbl::adc::read (const AdcHandle &handle, SampleTime sample_time=SampleTime::Medium) |
| Blocking single-channel ADC read. | |
| template<typename Driver > | |
| uint32_t | sbl::adc::to_millivolts (uint16_t raw_value, uint32_t vref_mv=3300) |
| Convert raw ADC value to voltage (millivolts) | |
ADC driver interface - canonical types for MCU driver implementations.
This header provides everything an ADC driver needs:
Drivers implement the following static interface:
// Initialize the ADC peripheral static void init();
// Configure channel for conversion static void configure_channel(const sbl::AdcHandle& handle, sbl::adc::SampleTime sample_time);
// Start single conversion static void start_conversion(const sbl::AdcHandle& handle);
// Check if conversion is complete static bool is_conversion_complete();
// Read raw conversion result static uint16_t read_raw();
// Get ADC resolution (compile-time constant) static constexpr uint8_t resolution_bits();
The core library provides convenience functions that compose the low-level primitives:
// Single blocking read uint16_t value = sbl::adc::read<sbl::driver::Adc>(handle);
Usage in driver: #include <sbl/hal/adc/driver.hpp> using sbl::adc::SampleTime;
Definition in file driver.hpp.