Convenience layer: read a channel, start and stop a scan.
|
| template<typename Driver > |
| uint16_t | read (const AdcHandle &handle, SampleTime sample_time=SampleTime::Medium) |
| | Blocking single-channel ADC read.
|
| |
| template<typename Driver > |
| uint32_t | to_millivolts (uint16_t raw_value, uint32_t vref_mv=3300) |
| | Convert raw ADC value to voltage (millivolts)
|
| |
| template<typename Driver > |
| void | start_scan (const AdcHandle *channels, uint8_t num_channels, uint16_t *buffer, SampleTime sample_time=SampleTime::Slow) |
| | Start continuous DMA scan of multiple ADC channels.
|
| |
| template<typename Driver > |
| void | start_scan (const AdcHandle *channels, uint8_t num_channels, uint16_t *buffer, const SampleTime *sample_times) |
| | Start continuous DMA scan with per-channel sample times.
|
| |
| template<typename Driver > |
| void | stop_scan () |
| | Stop DMA scan mode.
|
| |
template<typename Driver >
| uint16_t sbl::adc::read |
( |
const AdcHandle & |
handle, |
|
|
SampleTime |
sample_time = SampleTime::Medium |
|
) |
| |
|
inline |
Blocking single-channel ADC read.
Convenience function that composes low-level driver primitives. Configures the channel, starts conversion, waits for completion, and returns the raw value.
- Template Parameters
-
| Driver | ADC driver type (e.g., sbl::driver::Adc) |
- Parameters
-
| handle | ADC channel handle from hardware config |
| sample_time | Sampling duration (default: Medium) |
- Returns
- Raw ADC value (resolution depends on driver)
- Note
- Not ISR-safe — polls for conversion complete (busy-wait loop)
Example: auto value = sbl::adc::read<sbl::driver::Adc>(sbl::hw::adc::knob1);
Definition at line 76 of file driver.hpp.
template<typename Driver >
| void sbl::adc::start_scan |
( |
const AdcHandle * |
channels, |
|
|
uint8_t |
num_channels, |
|
|
uint16_t * |
buffer, |
|
|
SampleTime |
sample_time = SampleTime::Slow |
|
) |
| |
|
inline |
Start continuous DMA scan of multiple ADC channels.
The ADC scans all channels in sequence with circular DMA, depositing results into buffer[0..num_channels-1]. The CPU reads the buffer at any time for the latest value — no synchronization needed (16-bit aligned reads are atomic on Cortex-M).
- Template Parameters
-
| Driver | ADC driver type (e.g., sbl::driver::Adc) |
- Parameters
-
| channels | Array of AdcHandle defining the scan sequence |
| num_channels | Number of channels to scan (1–16) |
| buffer | DMA-accessible buffer with num_channels elements |
| sample_time | Sampling duration for all channels (default: Slow) |
- Note
- Not ISR-safe — init-time only (configures ADC + DMA hardware)
Definition at line 47 of file scan.hpp.