|
libxr
1.0
Want to be the best embedded framework
|
ESP32 多通道 ADC 驱动 / ESP32 multi-channel ADC driver. More...
#include <esp_adc.hpp>
Data Structures | |
| class | Channel |
| ADC 通道对象 / ADC channel object. More... | |
Public Member Functions | |
| ESP32ADC (adc_unit_t unit, const adc_channel_t *channels, uint8_t num_channels, uint32_t freq=SOC_ADC_SAMPLE_FREQ_THRES_LOW, adc_atten_t attenuation=ADC_ATTEN_DB_12, adc_bitwidth_t bitwidth=static_cast< adc_bitwidth_t >(SOC_ADC_DIGI_MAX_BITWIDTH), float reference_voltage=3.3f, size_t dma_buf_size=256) | |
| 构造 ADC 驱动对象 / Construct ADC driver | |
| ~ESP32ADC () | |
| 析构函数 / Destructor | |
| Channel & | GetChannel (uint8_t idx) |
| 获取通道对象 / Get channel object | |
| float | ReadChannel (uint8_t idx) |
| 读取指定通道电压值 / Read channel voltage | |
Private Member Functions | |
| void | HandleSamples (const void *buf, size_t size_bytes) |
| 解析 DMA 缓冲并计算均值 / Parse DMA buffer and compute averages | |
| float | Normalize (float raw) const |
| 将原始 ADC 值归一化为电压 / Normalize raw ADC to voltage | |
Static Private Member Functions | |
| static bool IRAM_ATTR | OnConvDone (adc_continuous_handle_t handle, const adc_continuous_evt_data_t *edata, void *user_data) |
| DMA 采样完成回调 / DMA conversion done callback. | |
Private Attributes | |
| adc_digi_pattern_config_t * | m_patterns_ |
| ADC采样模式数组 / Pattern config array. | |
| Channel * | m_channels_ |
| 通道对象数组 / Channel objects array | |
| float * | m_latest_values_ |
| 最新均值(每通道)/ Latest average value (per channel) | |
| int * | m_sum_buf_ |
| 求和缓冲 / Accumulation buffer | |
| int * | m_cnt_buf_ |
| 计数缓冲 / Count buffer | |
| adc_unit_t | m_unit_ |
| ADC单元 / ADC unit. | |
| uint8_t | m_num_channels_ |
| 通道数 / Number of channels | |
| adc_atten_t | m_attenuation_ |
| 衰减档位 / Attenuation | |
| adc_bitwidth_t | m_bitwidth_ |
| 位宽 / Bit width | |
| float | m_reference_voltage_ |
| 参考电压 / Reference voltage | |
| uint16_t | m_max_raw_ |
| 最大原始采样值 / Max raw value | |
| adc_continuous_handle_t | m_handle_ = nullptr |
| ESP-IDF采集句柄 / ADC handle. | |
ESP32 多通道 ADC 驱动 / ESP32 multi-channel ADC driver.
封装 ADC 连续采样、DMA 读取和通道均值计算。 Encapsulates continuous ADC sampling, DMA reads, and per-channel averaging.
Definition at line 29 of file esp_adc.hpp.
|
inline |
构造 ADC 驱动对象 / Construct ADC driver
| unit | ADC 单元(ADC_UNIT_1 或 ADC_UNIT_2) / ADC unit |
| channels | ADC 通道号数组 / ADC channel array |
| num_channels | 通道数量 / Number of channels |
| freq | 采样频率(Hz) / Sample frequency in Hz |
| attenuation | 衰减档位 / ADC attenuation |
| bitwidth | 位宽 / ADC bit width |
| reference_voltage | 参考电压(V) / Reference voltage in volts |
| dma_buf_size | DMA 缓冲区大小(字节) / DMA buffer size in bytes |
Definition at line 87 of file esp_adc.hpp.
|
inline |
析构函数 / Destructor
Definition at line 148 of file esp_adc.hpp.
|
inline |
获取通道对象 / Get channel object
| idx | 逻辑通道索引 / Channel logical index |
Definition at line 167 of file esp_adc.hpp.
|
inlineprivate |
解析 DMA 缓冲并计算均值 / Parse DMA buffer and compute averages
| buf | 缓冲区指针 / Buffer pointer |
| size_bytes | 数据字节数 / Buffer size in bytes |
Definition at line 195 of file esp_adc.hpp.
|
inlineprivate |
将原始 ADC 值归一化为电压 / Normalize raw ADC to voltage
| raw | 原始采样值 / Raw ADC value |
Definition at line 238 of file esp_adc.hpp.
|
inlinestaticprivate |
DMA 采样完成回调 / DMA conversion done callback.
Definition at line 180 of file esp_adc.hpp.
|
inline |
读取指定通道电压值 / Read channel voltage
| idx | 逻辑通道索引 / Channel index |
Definition at line 174 of file esp_adc.hpp.
|
private |
衰减档位 / Attenuation
Definition at line 251 of file esp_adc.hpp.
|
private |
位宽 / Bit width
Definition at line 252 of file esp_adc.hpp.
|
private |
通道对象数组 / Channel objects array
Definition at line 244 of file esp_adc.hpp.
|
private |
计数缓冲 / Count buffer
Definition at line 247 of file esp_adc.hpp.
|
private |
ESP-IDF采集句柄 / ADC handle.
Definition at line 255 of file esp_adc.hpp.
|
private |
最新均值(每通道)/ Latest average value (per channel)
Definition at line 245 of file esp_adc.hpp.
|
private |
最大原始采样值 / Max raw value
Definition at line 254 of file esp_adc.hpp.
|
private |
通道数 / Number of channels
Definition at line 250 of file esp_adc.hpp.
|
private |
ADC采样模式数组 / Pattern config array.
Definition at line 243 of file esp_adc.hpp.
|
private |
参考电压 / Reference voltage
Definition at line 253 of file esp_adc.hpp.
|
private |
求和缓冲 / Accumulation buffer
Definition at line 246 of file esp_adc.hpp.
|
private |
ADC单元 / ADC unit.
Definition at line 249 of file esp_adc.hpp.