5#if (defined(ESP32) && defined(USE_ANALOG) && !USE_LEGACY_I2S) || defined(DOXYGEN)
8 #ifndef perimanClearPinBus
9 #define perimanClearPinBus(p) perimanSetPinBus(p, ESP32_BUS_TYPE_INIT, NULL)
98 return io.readBytes(
dest, size_bytes);
118 FIFO() : size_(0), buffer_(
nullptr), head_(0), tail_(0), count_(0) {}
128 if (count_ < size_) {
129 buffer_[tail_] = value;
131 tail_ = (tail_ + 1) % size_;
142 value = buffer_[head_];
144 head_ = (head_ + 1) % size_;
162 return count_ == size_;
264 LOGE(
"Invalid TYPE2 ADC channel: %u", (
unsigned)
chan_num);
268#ifdef ADC_CONV_SINGLE_UNIT_1
270 sample.type2.unit != 0) {
271 LOGE(
"Invalid TYPE2 ADC unit for ADC1 mode: %u",
272 (
unsigned)sample.type2.unit);
276#ifdef ADC_CONV_SINGLE_UNIT_2
278 sample.type2.unit != 1) {
279 LOGE(
"Invalid TYPE2 ADC unit for ADC2 mode: %u",
280 (
unsigned)sample.type2.unit);
289 return static_cast<int16_t>(data);
296 LOGE(
"adc_cali_raw_to_voltage error: %d", err);
304 if (data ==
nullptr)
return false;
309 LOGE(
"ADC reorder resync on invalid TYPE2 record at sample %d", i);
317 LOGE(
"ADC reorder resync on invalid channel %u at sample %d",
325 LOGE(
"ADC reorder FIFO overflow on channel index %d (channel %u)",
346 LOGE(
"ADC reorder pop failed on channel index %d",
ch);
373#if ADC_CALI_SCHEME_CURVE_FITTING_SUPPORTED
375#elif !defined(CONFIG_IDF_TARGET_ESP32H2) && !defined(CONFIG_IDF_TARGET_ESP32P4)
391 LOGE(
"perimanClearPinBus failed!");
414 int samples = size_bytes / 2;
417 for (
int j = 0;
j < samples;
j++) {
455 LOGE(
"ADC RX scratch buffer is not initialized");
479 LOGE(
"adc_continuous_read unsuccessful: %d", err);
528 LOGE(
"new_channels");
539 LOGE(
"DAC not supported");
558 LOGE(
"adc unit %u continuous is already initialized. Please call end() first!",
cfg.
adc_unit);
571 LOGE(
"perimanClearPinBus failed!");
578 #if CONFIG_IDF_TARGET_ESP32 || CONFIG_IDF_TARGET_ESP32S2
586 "buffer_size is too big for one ADC DMA frame: %u samples = %u "
587 "bytes, max %u samples / %u bytes",
594 "RX DMA frame: %u conversion results, %u bytes (max %u results / "
606#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 2, 0)
607 adc_config.flags.flush_pool =
true;
610 (
unsigned)adc_config.max_store_buf_size);
613 LOGE(
"adc_continuous_new_handle failed with error: %d", err);
616 LOGI(
"adc_continuous_new_handle successful");
639 LOGI(
"dig_cfg.sample_freq_hz: %u", (
unsigned)
dig_cfg.sample_freq_hz);
640 LOGI(
"dig_cfg.conv_mode: %u (1: unit 1, 2: unit 2, 3: both)",
dig_cfg.conv_mode);
641 LOGI(
"dig_cfg.format: %u (0 is type1: [12bit data, 4bit channel])",
dig_cfg.format);
643 LOGI(
"dig_cfg.adc_pattern[%d].atten: %u", i,
dig_cfg.adc_pattern[i].atten);
644 LOGI(
"dig_cfg.adc_pattern[%d].channel: %u", i,
dig_cfg.adc_pattern[i].channel);
645 LOGI(
"dig_cfg.adc_pattern[%d].unit: %u", i,
dig_cfg.adc_pattern[i].unit);
646 LOGI(
"dig_cfg.adc_pattern[%d].bit_width: %u", i,
dig_cfg.adc_pattern[i].bit_width);
652 LOGE(
"adc_continuous_config unsuccessful with error: %d", err);
656 LOGI(
"adc_continuous_config successful");
671 LOGE(
"perimanSetPinBus to Continuous an ADC Unit %u failed!",
cfg.
adc_unit);
682 LOGE(
"adc_continuous_start unsuccessful with error: %d", err);
697 LOGE(
"Failed to allocate ADC RX scratch buffer");
701 LOGI(
"ADC RX scratch buffer allocated for %u bytes / %u samples",
712 LOGI(
"%d FIFO buffers allocated of size %u from DMA frame %u bytes",
715 LOGI(
"Setup ADC successful");
727 LOGE(
"dac_continuous_disable failed");
731 LOGE(
"dac_continuous_del_channels failed");
741 LOGD(
"===> adcDetachBus: %d", (
int)
bus);
751 LOGE(
"adc_continuous_stop failed");
758 LOGE(
"adc_continuous_deinit failed");
804 LOGE(
"ADC channel %u is not available on ADC unit %u", adc_channel,
cfg.
adc_unit);
807 LOGI(
"ADC channel %u is on pin %u", adc_channel,
io_pin);
818 LOGE(
"sample rate eff: %u can not be set, range: %u to %u", sample_rate,
822 LOGI(
"sample rate eff: %u, range: %u to %u", sample_rate,
840 LOGE(
"bits per sample: error. It should be: %d but is %d",
864 #if ADC_CALI_SCHEME_CURVE_FITTING_SUPPORTED
871 #elif !defined(CONFIG_IDF_TARGET_ESP32H2) && !defined(CONFIG_IDF_TARGET_ESP32P4)
882 LOGE(
"creating calibration handle failed for ADC%d with atten %d and bitwidth %d",
887 LOGI(
"enabled calibration for ADC%d with atten %d and bitwidth %d",
#define TRACEI()
Definition AudioLoggerIDF.h:32
#define LOGI(...)
Definition AudioLoggerIDF.h:28
#define LOGD(...)
Definition AudioLoggerIDF.h:27
#define LOGE(...)
Definition AudioLoggerIDF.h:30
@ TX_MODE
Definition AudioTypes.h:30
@ RX_MODE
Definition AudioTypes.h:30