diff --git a/_analog_driver_e_s_p32_v1_8h_source.html b/_analog_driver_e_s_p32_v1_8h_source.html
index 8a3444a30..902e44cc3 100644
--- a/_analog_driver_e_s_p32_v1_8h_source.html
+++ b/_analog_driver_e_s_p32_v1_8h_source.html
@@ -98,7 +98,7 @@
-
+
@@ -126,714 +126,727 @@
-
-
-
- 74 dac_continuous_del_channels(dac_handle);
-
-
-
-
-
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
- 90 size_t write(
const uint8_t *src,
size_t size_bytes)
override {
-
-
- 93 return converter.write(src, size_bytes);
-
-
-
-
- 98 size_t readBytes(uint8_t *dest,
size_t size_bytes)
override {
-
-
- 101 return io.readBytes(dest, size_bytes);
-
-
-
-
- 106 int available()
override {
- 107 return active_rx ? (uint32_t)(cfg.buffer_size *
sizeof(int16_t)) : 0;
-
+
+
+
+
+
+
+
+ 88 size_t write(
const uint8_t *src,
size_t size_bytes)
override {
+
+
+ 91 return converter.write(src, size_bytes);
+
+
+
+
+ 96 size_t readBytes(uint8_t *dest,
size_t size_bytes)
override {
+
+
+ 99 return io.readBytes(dest, size_bytes);
+
+
+
+
+ 104 int available()
override {
+ 105 return active_rx ? (uint32_t)(cfg.buffer_size *
sizeof(int16_t)) : 0;
+
+
+
-
-
-
-
-
-
- 119 FIFO() : size_(0), buffer_(
nullptr), head_(0), tail_(0), count_(0) {}
+
+
+
+
+ 117 FIFO() : size_(0), buffer_(
nullptr), head_(0), tail_(0), count_(0) {}
+
+ 119 FIFO(
size_t size) : size_(size), buffer_(
new T[size]), head_(0), tail_(0), count_(0) {}
- 121 FIFO(
size_t size) : size_(size), buffer_(
new T[size]), head_(0), tail_(0), count_(0) {}
-
-
-
-
-
-
- 128 bool push(
const T& value) {
- 129 if (count_ < size_) {
- 130 buffer_[tail_] = value;
-
- 132 tail_ = (tail_ + 1) % size_;
-
-
-
-
-
-
-
-
-
-
- 143 value = buffer_[head_];
-
- 145 head_ = (head_ + 1) % size_;
-
-
-
-
-
-
-
-
- 154 size_t size()
const {
-
-
-
-
-
-
-
-
- 163 return count_ == size_;
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 180 adc_continuous_handle_t adc_handle =
nullptr;
- 181 adc_cali_handle_t adc_cali_handle =
nullptr;
-
-
- 184 bool active_tx =
false;
- 185 bool active_rx =
false;
-
-
- 188 dac_continuous_handle_t dac_handle;
-
-
-
-
-
-
-
-
-
-
-
-
-
- 202 size_t write(
const uint8_t *src,
size_t size_bytes)
override {
-
-
-
-
- 207 int16_t *data16 = (int16_t *)src;
- 208 uint8_t *data8 = (uint8_t *)src;
- 209 int samples = size_bytes / 2;
-
-
- 212 for (
int j = 0; j < samples; j++) {
- 213 data8[j] = (32768u + data16[j]) >> 8;
-
-
- 216 if (dac_continuous_write(self->dac_handle, data8, samples, &result, self->cfg.timeout) != ESP_OK) {
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 245 size_t readBytes(uint8_t *dest,
size_t size_bytes) {
-
-
- 248 size_t total_bytes = 0;
- 249 size_t bytes_provided = 0;
- 250 int min_samples_in_fifo_per_channel = 0;
- 251 int max_samples_in_fifo_per_channel = 0;
-
-
-
- 255 int samples_provided_per_channel = 0;
- 256 int data_milliVolts = 0;
-
- 258 int samples_requested = size_bytes /
sizeof(int16_t);
- 259 int samples_requested_per_channel = samples_requested/
self->cfg.
channels;
-
- 261 adc_digi_output_data_t* result_data = (adc_digi_output_data_t*)malloc(samples_requested *
sizeof(adc_digi_output_data_t));
- 262 if (result_data == NULL) {
- 263 LOGE(
"Failed to allocate memory for result_data");
-
-
- 266 memset(result_data, 0, samples_requested *
sizeof(adc_digi_output_data_t));
-
-
-
- 270 uint16_t *result16 = (uint16_t *)dest;
- 271 uint16_t *end = (uint16_t *)(dest + size_bytes);
+
+
+
+
+
+ 126 bool push(
const T& value) {
+ 127 if (count_ < size_) {
+ 128 buffer_[tail_] = value;
+
+ 130 tail_ = (tail_ + 1) % size_;
+
+
+
+
+
+
+
+
+
+
+ 141 value = buffer_[head_];
+
+ 143 head_ = (head_ + 1) % size_;
+
+
+
+
+
+
+
+
+ 152 size_t size()
const {
+
+
+
+
+
+
+
+
+ 161 return count_ == size_;
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 178 adc_continuous_handle_t adc_handle =
nullptr;
+ 179 adc_cali_handle_t adc_cali_handle =
nullptr;
+
+
+ 182 bool active_tx =
false;
+ 183 bool active_rx =
false;
+
+
+ 186 dac_continuous_handle_t dac_handle;
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 200 size_t write(
const uint8_t *src,
size_t size_bytes)
override {
+
+
+
+
+ 205 int16_t *data16 = (int16_t *)src;
+ 206 uint8_t *data8 = (uint8_t *)src;
+ 207 int samples = size_bytes / 2;
+
+
+ 210 for (
int j = 0; j < samples; j++) {
+ 211 data8[j] = (32768u + data16[j]) >> 8;
+
+
+ 214 if (dac_continuous_write(self->dac_handle, data8, samples, &result, self->cfg.timeout) != ESP_OK) {
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 243 size_t readBytes(uint8_t *dest,
size_t size_bytes) {
+
+
+ 246 size_t total_bytes = 0;
+ 247 size_t bytes_provided = 0;
+ 248 int min_samples_in_fifo_per_channel = 0;
+ 249 int max_samples_in_fifo_per_channel = 0;
+
+
+
+ 253 int samples_provided_per_channel = 0;
+ 254 int data_milliVolts = 0;
+
+ 256 int samples_requested = size_bytes /
sizeof(int16_t);
+ 257 int samples_requested_per_channel = samples_requested/
self->cfg.
channels;
+
+ 259 adc_digi_output_data_t* result_data = (adc_digi_output_data_t*)malloc(samples_requested *
sizeof(adc_digi_output_data_t));
+ 260 if (result_data == NULL) {
+ 261 LOGE(
"Failed to allocate memory for result_data");
+
+
+ 264 memset(result_data, 0, samples_requested *
sizeof(adc_digi_output_data_t));
+
+
+
+ 268 uint16_t *result16 = (uint16_t *)dest;
+ 269 uint16_t *end = (uint16_t *)(dest + size_bytes);
+
+
-
-
-
-
- 277 if (adc_continuous_read(self->adc_handle, (uint8_t *)result_data, (uint32_t)(samples_requested *
sizeof(adc_digi_output_data_t)), &bytes_read, (uint32_t)
self->cfg.timeout) == ESP_OK) {
- 278 samples_read = bytes_read /
sizeof(adc_digi_output_data_t);
- 279 LOGD(
"adc_continuous_read -> %u bytes / %d samples of %d bytes requested", (
unsigned)bytes_read, samples_read, (
int)(samples_requested *
sizeof(adc_digi_output_data_t)));
-
-
- 282 for (
int i = 0; i < samples_read; i++) {
- 283 adc_digi_output_data_t *p = &result_data[i];
- 284 ADC_CHANNEL_TYPE chan_num = AUDIO_ADC_GET_CHANNEL(p);
- 285 ADC_DATA_TYPE data = AUDIO_ADC_GET_DATA(p);
-
-
-
- 289 for (
int j = 0; j <
self->cfg.channels; ++j) {
- 290 if (self->cfg.adc_channels[j] == chan_num) {
-
-
-
-
-
-
- 297 if (self->fifo_buffers[idx]->push(data)) {
- 298 LOGD(
"Sample %d, FIFO %d, ch %u, d %u", i, idx, chan_num, data);
-
- 300 LOGE(
"Sample %d, FIFO buffer is full, ch %u, d %u", i, (
unsigned)chan_num, data);
-
-
- 303 LOGE(
"Sample %d, ch %u not found in configuration, d: %u", i, (
unsigned)chan_num, data);
- 304 for (
int k = 0; k <
self->cfg.channels; ++k) {
- 305 LOGE(
"Available config ch: %u", self->cfg.adc_channels[k]);
-
-
+
+
+ 275 if (adc_continuous_read(self->adc_handle, (uint8_t *)result_data, (uint32_t)(samples_requested *
sizeof(adc_digi_output_data_t)), &bytes_read, (uint32_t)
self->cfg.timeout) == ESP_OK) {
+ 276 samples_read = bytes_read /
sizeof(adc_digi_output_data_t);
+ 277 LOGD(
"adc_continuous_read -> %u bytes / %d samples of %d bytes requested", (
unsigned)bytes_read, samples_read, (
int)(samples_requested *
sizeof(adc_digi_output_data_t)));
+
+
+ 280 for (
int i = 0; i < samples_read; i++) {
+ 281 adc_digi_output_data_t *p = &result_data[i];
+ 282 ADC_CHANNEL_TYPE chan_num = AUDIO_ADC_GET_CHANNEL(p);
+ 283 ADC_DATA_TYPE data = AUDIO_ADC_GET_DATA(p);
+
+
+
+ 287 for (
int j = 0; j <
self->cfg.channels; ++j) {
+ 288 if (self->cfg.adc_channels[j] == chan_num) {
+
+
+
+
+
+
+ 295 if (self->fifo_buffers[idx]->push(data)) {
+ 296 LOGD(
"Sample %d, FIFO %d, ch %u, d %u", i, idx, chan_num, data);
+
+ 298 LOGE(
"Sample %d, FIFO buffer is full, ch %u, d %u", i, (
unsigned)chan_num, data);
+
+
+ 301 LOGE(
"Sample %d, ch %u not found in configuration, d: %u", i, (
unsigned)chan_num, data);
+ 302 for (
int k = 0; k <
self->cfg.channels; ++k) {
+ 303 LOGE(
"Available config ch: %u", self->cfg.adc_channels[k]);
+
+
+
+
-
-
-
- 312 min_samples_in_fifo_per_channel =
self->fifo_buffers[0]->size();
- 313 for (
int i = 1; i <
self->cfg.channels; i++) {
- 314 fifo_size =
self->fifo_buffers[i]->size();
- 315 if (fifo_size < min_samples_in_fifo_per_channel) {
- 316 min_samples_in_fifo_per_channel = fifo_size;
-
-
-
-
- 321 while (samples_requested_per_channel > min_samples_in_fifo_per_channel) {
-
-
-
- 325 if (adc_continuous_read(self->adc_handle, (uint8_t *)result_data, (uint32_t)(2*self->cfg.
channels *
sizeof(adc_digi_output_data_t)), &bytes_read, (uint32_t)self->cfg.timeout) != ESP_OK) {
- 326 LOGE(
"Top off, adc_continuous_read unsuccessful");
-
-
-
-
- 331 samples_read = bytes_read /
sizeof(adc_digi_output_data_t);
- 332 LOGD(
"Top Off: Requested %d samples per Channel, Min samples in FIFO: %d, Read additional %d bytes / %d samples", samples_requested_per_channel, min_samples_in_fifo_per_channel, (
unsigned)bytes_read, samples_read);
-
- 334 for (
int i = 0; i < samples_read; i++) {
- 335 adc_digi_output_data_t *p = &result_data[i];
- 336 ADC_CHANNEL_TYPE chan_num = AUDIO_ADC_GET_CHANNEL(p);
- 337 ADC_DATA_TYPE data = AUDIO_ADC_GET_DATA(p);
-
-
-
- 341 for (
int j = 0; j <
self->cfg.channels; ++j) {
- 342 if (self->cfg.adc_channels[j] == chan_num) {
-
-
-
-
-
-
- 349 if (self->fifo_buffers[idx]->push(data)) {
- 350 LOGD(
"Top Off Sample %d, FIFO %d, ch %u, d %u", i, idx, chan_num, data);
-
- 352 LOGE(
"Top Off Sample %d, FIFO buffer is full, ch %u, d %u", i, chan_num, data);
-
-
- 355 LOGE(
"Top Off Sample %d, ch %u not found in configuration, d %u", i, chan_num, data);
- 356 for (
int k = 0; k <
self->cfg.channels; ++k) {
- 357 LOGE(
"Available config ch: %u", self->cfg.adc_channels[k]);
-
-
-
-
-
- 363 min_samples_in_fifo_per_channel =
self->fifo_buffers[0]->size();
- 364 max_samples_in_fifo_per_channel =
self->fifo_buffers[0]->size();
- 365 for (
int i = 1; i <
self->cfg.channels; i++) {
- 366 fifo_size =
self->fifo_buffers[i]->size();
- 367 if (fifo_size < min_samples_in_fifo_per_channel) {
- 368 min_samples_in_fifo_per_channel = fifo_size;
-
- 370 if (fifo_size > max_samples_in_fifo_per_channel) {
- 371 max_samples_in_fifo_per_channel = fifo_size;
-
-
- 374 LOGD(
"Min # of samples in FIFO: %d, Max # of samples in FIFO: %d", min_samples_in_fifo_per_channel, max_samples_in_fifo_per_channel);
-
-
-
- 378 if (samples_requested_per_channel <= min_samples_in_fifo_per_channel) {
- 379 LOGD(
"Going to copying %d samples of %d samples/channel to output buffer", samples_requested, samples_requested_per_channel);
- 380 samples_provided_per_channel = samples_requested_per_channel;
-
-
- 383 LOGE(
"Only %d samples per channel available for output buffer", min_samples_in_fifo_per_channel);
- 384 samples_provided_per_channel = min_samples_in_fifo_per_channel;
-
-
- 387 for (
int i = 0; i < samples_provided_per_channel; i++) {
- 388 for (
int j = 0; j <
self->cfg.channels; j++) {
-
- 390 self->fifo_buffers[j]->pop(data);
- 391 if (result16 < end) {
- 392 if (self->cfg.adc_calibration_active) {
-
- 394 auto err = adc_cali_raw_to_voltage(self->adc_cali_handle, (
int)data, &data_milliVolts);
-
- 396 *result16 =
static_cast<int16_t
>(data_milliVolts);
-
- 398 LOGE(
"adc_cali_raw_to_voltage error: %d", err);
-
-
-
-
-
-
-
- 406 LOGE(
"Buffer write overflow, skipping data");
-
-
-
+
+ 310 min_samples_in_fifo_per_channel =
self->fifo_buffers[0]->size();
+ 311 for (
int i = 1; i <
self->cfg.channels; i++) {
+ 312 fifo_size =
self->fifo_buffers[i]->size();
+ 313 if (fifo_size < min_samples_in_fifo_per_channel) {
+ 314 min_samples_in_fifo_per_channel = fifo_size;
+
+
+
+
+ 319 while (samples_requested_per_channel > min_samples_in_fifo_per_channel) {
+
+
+
+ 323 if (adc_continuous_read(self->adc_handle, (uint8_t *)result_data, (uint32_t)(2*self->cfg.
channels *
sizeof(adc_digi_output_data_t)), &bytes_read, (uint32_t)self->cfg.timeout) != ESP_OK) {
+ 324 LOGE(
"Top off, adc_continuous_read unsuccessful");
+
+
+
+
+ 329 samples_read = bytes_read /
sizeof(adc_digi_output_data_t);
+ 330 LOGD(
"Top Off: Requested %d samples per Channel, Min samples in FIFO: %d, Read additional %d bytes / %d samples", samples_requested_per_channel, min_samples_in_fifo_per_channel, (
unsigned)bytes_read, samples_read);
+
+ 332 for (
int i = 0; i < samples_read; i++) {
+ 333 adc_digi_output_data_t *p = &result_data[i];
+ 334 ADC_CHANNEL_TYPE chan_num = AUDIO_ADC_GET_CHANNEL(p);
+ 335 ADC_DATA_TYPE data = AUDIO_ADC_GET_DATA(p);
+
+
+
+ 339 for (
int j = 0; j <
self->cfg.channels; ++j) {
+ 340 if (self->cfg.adc_channels[j] == chan_num) {
+
+
+
+
+
+
+ 347 if (self->fifo_buffers[idx]->push(data)) {
+ 348 LOGD(
"Top Off Sample %d, FIFO %d, ch %u, d %u", i, idx, chan_num, data);
+
+ 350 LOGE(
"Top Off Sample %d, FIFO buffer is full, ch %u, d %u", i, chan_num, data);
+
+
+ 353 LOGE(
"Top Off Sample %d, ch %u not found in configuration, d %u", i, chan_num, data);
+ 354 for (
int k = 0; k <
self->cfg.channels; ++k) {
+ 355 LOGE(
"Available config ch: %u", self->cfg.adc_channels[k]);
+
+
+
+
+
+ 361 min_samples_in_fifo_per_channel =
self->fifo_buffers[0]->size();
+ 362 max_samples_in_fifo_per_channel =
self->fifo_buffers[0]->size();
+ 363 for (
int i = 1; i <
self->cfg.channels; i++) {
+ 364 fifo_size =
self->fifo_buffers[i]->size();
+ 365 if (fifo_size < min_samples_in_fifo_per_channel) {
+ 366 min_samples_in_fifo_per_channel = fifo_size;
+
+ 368 if (fifo_size > max_samples_in_fifo_per_channel) {
+ 369 max_samples_in_fifo_per_channel = fifo_size;
+
+
+ 372 LOGD(
"Min # of samples in FIFO: %d, Max # of samples in FIFO: %d", min_samples_in_fifo_per_channel, max_samples_in_fifo_per_channel);
+
+
+
+ 376 if (samples_requested_per_channel <= min_samples_in_fifo_per_channel) {
+ 377 LOGD(
"Going to copying %d samples of %d samples/channel to output buffer", samples_requested, samples_requested_per_channel);
+ 378 samples_provided_per_channel = samples_requested_per_channel;
+
+
+ 381 LOGE(
"Only %d samples per channel available for output buffer", min_samples_in_fifo_per_channel);
+ 382 samples_provided_per_channel = min_samples_in_fifo_per_channel;
+
+
+ 385 for (
int i = 0; i < samples_provided_per_channel; i++) {
+ 386 for (
int j = 0; j <
self->cfg.channels; j++) {
+
+ 388 self->fifo_buffers[j]->pop(data);
+ 389 if (result16 < end) {
+ 390 if (self->cfg.adc_calibration_active) {
+
+ 392 auto err = adc_cali_raw_to_voltage(self->adc_cali_handle, (
int)data, &data_milliVolts);
+
+ 394 *result16 =
static_cast<int16_t
>(data_milliVolts);
+
+ 396 LOGE(
"adc_cali_raw_to_voltage error: %d", err);
+
+
+
+
+
+
+
+ 404 LOGE(
"Buffer write overflow, skipping data");
+
+
+
+
+ 409 bytes_provided = samples_provided_per_channel *
self->cfg.channels *
sizeof(int16_t);
- 411 bytes_provided = samples_provided_per_channel *
self->cfg.channels *
sizeof(int16_t);
-
-
- 414 if (self->cfg.is_auto_center_read) {
- 415 self->auto_center.convert(dest, bytes_provided);
-
-
-
- 419 LOGE(
"adc_continuous_read unsuccessful");
-
-
-
- 423 return bytes_provided;
-
-
-
-
+
+ 412 if (self->cfg.is_auto_center_read) {
+ 413 self->auto_center.convert(dest, bytes_provided);
+
+
+
+ 417 LOGE(
"adc_continuous_read unsuccessful");
+
+
+
+ 421 return bytes_provided;
+
+
+
+
+
+
-
+
-
-
-
-
-
-
- 437 dac_continuous_config_t cont_cfg = {
- 438 .chan_mask = cfg.
channels == 1 ? cfg.dac_mono_channel : DAC_CHANNEL_MASK_ALL,
- 439 .desc_num = (uint32_t)cfg.buffer_count,
- 440 .buf_size = (
size_t)cfg.buffer_size,
-
-
- 443 .clk_src = cfg.use_apll ? DAC_DIGI_CLK_SRC_APLL : DAC_DIGI_CLK_SRC_DEFAULT,
- 444 .chan_mode = DAC_CHANNEL_MODE_ALTER,
-
-
- 447 if (dac_continuous_new_channels(&cont_cfg, &dac_handle) != ESP_OK) {
- 448 LOGE(
"new_channels");
-
-
- 451 if (dac_continuous_enable(dac_handle) != ESP_OK) {
-
-
-
-
-
-
-
- 459 LOGE(
"DAC not supported");
-
-
-
-
-
-
-
- 467 adc_channel_t adc_channel;
-
-
-
-
-
-
-
-
-
- 477 if (adc_handle !=
nullptr) {
- 478 LOGE(
"adc unit %u continuous is already initialized. Please call end() first!", ADC_UNIT);
-
-
-
-
-
-
-
-
- 487 for (
int i = 0; i < cfg.
channels; i++) {
- 488 adc_channel = cfg.adc_channels[i];
- 489 adc_continuous_channel_to_io(ADC_UNIT, adc_channel, &io_pin);
- 490 if (!perimanClearPinBus(io_pin)) {
- 491 LOGE(
"perimanClearPinBus failed!");
-
-
-
-
-
-
-
- 499 uint32_t conv_frame_size = (uint32_t)cfg.buffer_size * SOC_ADC_DIGI_RESULT_BYTES;
- 500 #
if CONFIG_IDF_TARGET_ESP32 || CONFIG_IDF_TARGET_ESP32S2
- 501 uint8_t calc_multiple = conv_frame_size % SOC_ADC_DIGI_DATA_BYTES_PER_CONV;
- 502 if (calc_multiple != 0) {
- 503 conv_frame_size = (uint32_t) (conv_frame_size + calc_multiple);
-
-
-
-
-
-
-
-
-
-
- 514 if (conv_frame_size > 4092) {
- 515 LOGE(
"buffer_size is too big. Please set lower buffer_size.");
-
-
- 518 LOGI(
"buffer_size: %u samples, conv_frame_size: %u bytes", cfg.buffer_size, (
unsigned)conv_frame_size);
-
-
-
- 522 adc_continuous_handle_cfg_t adc_config;
- 523 adc_config.max_store_buf_size = (uint32_t)conv_frame_size * 2;
- 524 adc_config.conv_frame_size = (uint32_t) conv_frame_size;
- 525 #if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 2, 0)
- 526 adc_config.flags.flush_pool =
true;
-
- 528 err = adc_continuous_new_handle(&adc_config, &adc_handle);
-
- 530 LOGE(
"adc_continuous_new_handle failed with error: %d", err);
-
-
- 533 LOGI(
"adc_continuous_new_handle successful");
-
-
-
- 537 adc_digi_pattern_config_t adc_pattern[cfg.
channels] = {};
- 538 for (
int i = 0; i < cfg.
channels; i++) {
- 539 uint8_t ch = cfg.adc_channels[i];
- 540 adc_pattern[i].atten = (uint8_t) cfg.adc_attenuation;
- 541 adc_pattern[i].channel = (uint8_t)ch;
- 542 adc_pattern[i].unit = (uint8_t) ADC_UNIT;
- 543 adc_pattern[i].bit_width = (uint8_t) cfg.adc_bit_width;
-
-
-
- 547 adc_continuous_config_t dig_cfg = {
- 548 .pattern_num = (uint32_t) cfg.
channels,
- 549 .adc_pattern = adc_pattern,
-
- 551 .conv_mode = (adc_digi_convert_mode_t) cfg.adc_conversion_mode,
- 552 .format = (adc_digi_output_format_t) cfg.adc_output_type,
-
-
-
- 556 LOGI(
"dig_cfg.sample_freq_hz: %u", (
unsigned)dig_cfg.sample_freq_hz);
- 557 LOGI(
"dig_cfg.conv_mode: %u (1: unit 1, 2: unit 2, 3: both)", dig_cfg.conv_mode);
- 558 LOGI(
"dig_cfg.format: %u (0 is type1: [12bit data, 4bit channel])", dig_cfg.format);
- 559 for (
int i = 0; i < cfg.
channels; i++) {
- 560 LOGI(
"dig_cfg.adc_pattern[%d].atten: %u", i, dig_cfg.adc_pattern[i].atten);
- 561 LOGI(
"dig_cfg.adc_pattern[%d].channel: %u", i, dig_cfg.adc_pattern[i].channel);
- 562 LOGI(
"dig_cfg.adc_pattern[%d].unit: %u", i, dig_cfg.adc_pattern[i].unit);
- 563 LOGI(
"dig_cfg.adc_pattern[%d].bit_width: %u", i, dig_cfg.adc_pattern[i].bit_width);
-
-
-
- 567 err = adc_continuous_config(adc_handle, &dig_cfg);
-
- 569 LOGE(
"adc_continuous_config unsuccessful with error: %d", err);
-
-
- 572 LOGI(
"adc_continuous_config successful");
-
-
-
-
-
-
-
-
- 581 for (
int i = 0; i < cfg.
channels; i++) {
- 582 adc_channel = cfg.adc_channels[i];
- 583 adc_continuous_channel_to_io(ADC_UNIT, adc_channel, &io_pin);
-
- 585 if (!perimanSetPinBus(io_pin, ESP32_BUS_TYPE_ADC_CONT, (
void *)(ADC_UNIT + 1), ADC_UNIT, adc_channel)) {
- 586 LOGE(
"perimanSetPinBus to Continuous an ADC Unit %u failed!", ADC_UNIT);
-
-
-
-
-
-
- 593 err = adc_continuous_start(adc_handle);
-
- 595 LOGE(
"adc_continuous_start unsuccessful with error: %d", err);
-
-
-
-
-
-
-
- 603 size_t fifo_size = (cfg.buffer_size / cfg.
channels) + 8;
- 604 fifo_buffers =
new FIFO<ADC_DATA_TYPE>*[cfg.
channels];
- 605 for (
int i = 0; i < cfg.
channels; ++i) {
- 606 fifo_buffers[i] =
new FIFO<ADC_DATA_TYPE>(fifo_size);
-
- 608 LOGI(
"%d FIFO buffers allocated of size %d", cfg.
channels, fifo_size);
-
- 610 LOGI(
"Setup ADC successful");
-
-
-
-
-
-
-
-
- 619 adc_continuous_stop(adc_handle);
- 620 adc_continuous_deinit(adc_handle);
- 621 if (cfg.adc_calibration_active) {
- 622 #if ADC_CALI_SCHEME_CURVE_FITTING_SUPPORTED
- 623 adc_cali_delete_scheme_curve_fitting(adc_cali_handle);
- 624 #elif !defined(CONFIG_IDF_TARGET_ESP32H2)
- 625 adc_cali_delete_scheme_line_fitting(adc_cali_handle);
-
-
+
+
+
+
+ 435 dac_continuous_config_t cont_cfg = {
+ 436 .chan_mask = cfg.
channels == 1 ? cfg.dac_mono_channel : DAC_CHANNEL_MASK_ALL,
+ 437 .desc_num = (uint32_t)cfg.buffer_count,
+ 438 .buf_size = (
size_t)cfg.buffer_size,
+
+
+ 441 .clk_src = cfg.use_apll ? DAC_DIGI_CLK_SRC_APLL : DAC_DIGI_CLK_SRC_DEFAULT,
+ 442 .chan_mode = DAC_CHANNEL_MODE_ALTER,
+
+
+ 445 if (dac_continuous_new_channels(&cont_cfg, &dac_handle) != ESP_OK) {
+ 446 LOGE(
"new_channels");
+
+
+ 449 if (dac_continuous_enable(dac_handle) != ESP_OK) {
+
+
+
+
+
+
+
+ 457 LOGE(
"DAC not supported");
+
+
+
+
+
+
+
+ 465 adc_channel_t adc_channel;
+
+
+
+
+
+
+
+
+
+ 475 if (adc_handle !=
nullptr) {
+ 476 LOGE(
"adc unit %u continuous is already initialized. Please call end() first!", ADC_UNIT);
+
+
+
+
+
+
+
+
+ 485 for (
int i = 0; i < cfg.
channels; i++) {
+ 486 adc_channel = cfg.adc_channels[i];
+ 487 adc_continuous_channel_to_io(ADC_UNIT, adc_channel, &io_pin);
+ 488 if (!perimanClearPinBus(io_pin)) {
+ 489 LOGE(
"perimanClearPinBus failed!");
+
+
+
+
+
+
+
+ 497 uint32_t conv_frame_size = (uint32_t)cfg.buffer_size * SOC_ADC_DIGI_RESULT_BYTES;
+ 498 #
if CONFIG_IDF_TARGET_ESP32 || CONFIG_IDF_TARGET_ESP32S2
+ 499 uint8_t calc_multiple = conv_frame_size % SOC_ADC_DIGI_DATA_BYTES_PER_CONV;
+ 500 if (calc_multiple != 0) {
+ 501 conv_frame_size = (uint32_t) (conv_frame_size + calc_multiple);
+
+
+
+
+
+
+
+
+
+
+ 512 if (conv_frame_size > 4092) {
+ 513 LOGE(
"buffer_size is too big. Please set lower buffer_size.");
+
+
+ 516 LOGI(
"buffer_size: %u samples, conv_frame_size: %u bytes", cfg.buffer_size, (
unsigned)conv_frame_size);
+
+
+
+ 520 adc_continuous_handle_cfg_t adc_config;
+ 521 adc_config.max_store_buf_size = (uint32_t)conv_frame_size * 2;
+ 522 adc_config.conv_frame_size = (uint32_t) conv_frame_size;
+ 523 #if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 2, 0)
+ 524 adc_config.flags.flush_pool =
true;
+
+ 526 err = adc_continuous_new_handle(&adc_config, &adc_handle);
+
+ 528 LOGE(
"adc_continuous_new_handle failed with error: %d", err);
+
+
+ 531 LOGI(
"adc_continuous_new_handle successful");
+
+
+
+ 535 adc_digi_pattern_config_t adc_pattern[cfg.
channels] = {};
+ 536 for (
int i = 0; i < cfg.
channels; i++) {
+ 537 uint8_t ch = cfg.adc_channels[i];
+ 538 adc_pattern[i].atten = (uint8_t) cfg.adc_attenuation;
+ 539 adc_pattern[i].channel = (uint8_t)ch;
+ 540 adc_pattern[i].unit = (uint8_t) ADC_UNIT;
+ 541 adc_pattern[i].bit_width = (uint8_t) cfg.adc_bit_width;
+
+
+
+ 545 adc_continuous_config_t dig_cfg = {
+ 546 .pattern_num = (uint32_t) cfg.
channels,
+ 547 .adc_pattern = adc_pattern,
+
+ 549 .conv_mode = (adc_digi_convert_mode_t) cfg.adc_conversion_mode,
+ 550 .format = (adc_digi_output_format_t) cfg.adc_output_type,
+
+
+
+ 554 LOGI(
"dig_cfg.sample_freq_hz: %u", (
unsigned)dig_cfg.sample_freq_hz);
+ 555 LOGI(
"dig_cfg.conv_mode: %u (1: unit 1, 2: unit 2, 3: both)", dig_cfg.conv_mode);
+ 556 LOGI(
"dig_cfg.format: %u (0 is type1: [12bit data, 4bit channel])", dig_cfg.format);
+ 557 for (
int i = 0; i < cfg.
channels; i++) {
+ 558 LOGI(
"dig_cfg.adc_pattern[%d].atten: %u", i, dig_cfg.adc_pattern[i].atten);
+ 559 LOGI(
"dig_cfg.adc_pattern[%d].channel: %u", i, dig_cfg.adc_pattern[i].channel);
+ 560 LOGI(
"dig_cfg.adc_pattern[%d].unit: %u", i, dig_cfg.adc_pattern[i].unit);
+ 561 LOGI(
"dig_cfg.adc_pattern[%d].bit_width: %u", i, dig_cfg.adc_pattern[i].bit_width);
+
+
+
+ 565 err = adc_continuous_config(adc_handle, &dig_cfg);
+
+ 567 LOGE(
"adc_continuous_config unsuccessful with error: %d", err);
+
+
+ 570 LOGI(
"adc_continuous_config successful");
+
+
+
+
+
+
+
+
+ 579 for (
int i = 0; i < cfg.
channels; i++) {
+ 580 adc_channel = cfg.adc_channels[i];
+ 581 adc_continuous_channel_to_io(ADC_UNIT, adc_channel, &io_pin);
+
+ 583 if (!perimanSetPinBus(io_pin, ESP32_BUS_TYPE_ADC_CONT, (
void *)(ADC_UNIT + 1), ADC_UNIT, adc_channel)) {
+ 584 LOGE(
"perimanSetPinBus to Continuous an ADC Unit %u failed!", ADC_UNIT);
+
+
+
+
+
+
+ 591 err = adc_continuous_start(adc_handle);
+
+ 593 LOGE(
"adc_continuous_start unsuccessful with error: %d", err);
+
+
+
+
+
+
+
+ 601 size_t fifo_size = (cfg.buffer_size / cfg.
channels) + 8;
+ 602 fifo_buffers =
new FIFO<ADC_DATA_TYPE>*[cfg.
channels];
+ 603 for (
int i = 0; i < cfg.
channels; ++i) {
+ 604 fifo_buffers[i] =
new FIFO<ADC_DATA_TYPE>(fifo_size);
+
+ 606 LOGI(
"%d FIFO buffers allocated of size %d", cfg.
channels, fifo_size);
+
+ 608 LOGI(
"Setup ADC successful");
+
+
+
+
+
+
+
+ 617 if (dac_continuous_disable(dac_handle) != ESP_OK){
+
+ 619 LOGE(
"dac_continuous_disable failed");
+
+ 621 if (dac_continuous_del_channels(dac_handle) != ESP_OK){
+
+ 623 LOGE(
"dac_continuous_del_channels failed");
+
+
+
+
-
- 630 if (fifo_buffers !=
nullptr) {
- 631 for (
int i = 0; i < cfg.
channels; ++i) {
- 632 delete fifo_buffers[i];
-
- 634 delete[] fifo_buffers;
- 635 fifo_buffers =
nullptr;
-
-
-
-
- 640 for (
int i = 0; i < cfg.
channels; i++) {
- 641 adc_channel_t adc_channel = cfg.adc_channels[i];
-
- 643 adc_continuous_channel_to_io(ADC_UNIT, adc_channel, &io_pin);
- 644 if (perimanGetPinBusType(io_pin) == ESP32_BUS_TYPE_ADC_CONT) {
- 645 if (!perimanClearPinBus(io_pin)) {
- 646 LOGE(
"perimanClearPinBus failed!");
-
-
+
+
+ 632 adc_continuous_stop(adc_handle);
+ 633 adc_continuous_deinit(adc_handle);
+ 634 if (cfg.adc_calibration_active) {
+ 635 #if ADC_CALI_SCHEME_CURVE_FITTING_SUPPORTED
+ 636 adc_cali_delete_scheme_curve_fitting(adc_cali_handle);
+ 637 #elif !defined(CONFIG_IDF_TARGET_ESP32H2)
+ 638 adc_cali_delete_scheme_line_fitting(adc_cali_handle);
+
+
+
+
+ 643 if (fifo_buffers !=
nullptr) {
+ 644 for (
int i = 0; i < cfg.
channels; ++i) {
+ 645 delete fifo_buffers[i];
+
+ 647 delete[] fifo_buffers;
+ 648 fifo_buffers =
nullptr;
-
-
-
-
-
-
- 657 if ((cfg.adc_bit_width < SOC_ADC_DIGI_MIN_BITWIDTH) ||
- 658 (cfg.adc_bit_width > SOC_ADC_DIGI_MAX_BITWIDTH)) {
- 659 LOGE(
"adc bit width: %u cannot be set, range: %u to %u", cfg.adc_bit_width,
- 660 (
unsigned)SOC_ADC_DIGI_MIN_BITWIDTH, (
unsigned)SOC_ADC_DIGI_MAX_BITWIDTH);
-
+
+
+
+ 653 for (
int i = 0; i < cfg.
channels; i++) {
+ 654 adc_channel_t adc_channel = cfg.adc_channels[i];
+
+ 656 adc_continuous_channel_to_io(ADC_UNIT, adc_channel, &io_pin);
+ 657 if (perimanGetPinBusType(io_pin) == ESP32_BUS_TYPE_ADC_CONT) {
+ 658 if (!perimanClearPinBus(io_pin)) {
+ 659 LOGE(
"perimanClearPinBus failed!");
+
+
- 663 LOGI(
"adc bit width: %u, range: %u to %u", cfg.adc_bit_width,
- 664 (
unsigned)SOC_ADC_DIGI_MIN_BITWIDTH, (
unsigned)SOC_ADC_DIGI_MAX_BITWIDTH);
-
+
+
+
-
-
- 671 adc_channel_t adc_channel;
-
- 673 int max_channels =
sizeof(cfg.adc_channels) /
sizeof(adc_channel_t);
-
- 675 LOGE(
"number of channels: %d, max: %d", cfg.
channels, max_channels);
-
-
- 678 LOGI(
"channels: %d, max: %d", cfg.
channels, max_channels);
-
-
- 681 for (
int i = 0; i < cfg.
channels; i++) {
- 682 adc_channel = cfg.adc_channels[i];
- 683 auto err = adc_continuous_channel_to_io(ADC_UNIT, adc_channel, &io_pin);
-
- 685 LOGE(
"ADC channel %u is not available on ADC unit %u", adc_channel, ADC_UNIT);
-
-
- 688 LOGI(
"ADC channel %u is on pin %u", adc_channel, io_pin);
-
+
+ 670 if ((cfg.adc_bit_width < SOC_ADC_DIGI_MIN_BITWIDTH) ||
+ 671 (cfg.adc_bit_width > SOC_ADC_DIGI_MAX_BITWIDTH)) {
+ 672 LOGE(
"adc bit width: %u cannot be set, range: %u to %u", cfg.adc_bit_width,
+ 673 (
unsigned)SOC_ADC_DIGI_MIN_BITWIDTH, (
unsigned)SOC_ADC_DIGI_MAX_BITWIDTH);
+
+
+ 676 LOGI(
"adc bit width: %u, range: %u to %u", cfg.adc_bit_width,
+ 677 (
unsigned)SOC_ADC_DIGI_MIN_BITWIDTH, (
unsigned)SOC_ADC_DIGI_MAX_BITWIDTH);
+
+
+
+
+
+ 684 adc_channel_t adc_channel;
+
+ 686 int max_channels =
sizeof(cfg.adc_channels) /
sizeof(adc_channel_t);
+
+ 688 LOGE(
"number of channels: %d, max: %d", cfg.
channels, max_channels);
+
-
-
-
-
-
- 697 if ((sample_rate < SOC_ADC_SAMPLE_FREQ_THRES_LOW) ||
- 698 (sample_rate > SOC_ADC_SAMPLE_FREQ_THRES_HIGH)) {
- 699 LOGE(
"sample rate eff: %u can not be set, range: %u to %u", sample_rate,
- 700 SOC_ADC_SAMPLE_FREQ_THRES_LOW, SOC_ADC_SAMPLE_FREQ_THRES_HIGH);
-
-
- 703 LOGI(
"sample rate eff: %u, range: %u to %u", sample_rate,
- 704 SOC_ADC_SAMPLE_FREQ_THRES_LOW, SOC_ADC_SAMPLE_FREQ_THRES_HIGH);
-
-
-
-
-
- 711 int supported_bits = 16;
-
-
-
-
-
-
+ 691 LOGI(
"channels: %d, max: %d", cfg.
channels, max_channels);
+
+
+ 694 for (
int i = 0; i < cfg.
channels; i++) {
+ 695 adc_channel = cfg.adc_channels[i];
+ 696 auto err = adc_continuous_channel_to_io(ADC_UNIT, adc_channel, &io_pin);
+
+ 698 LOGE(
"ADC channel %u is not available on ADC unit %u", adc_channel, ADC_UNIT);
+
+
+ 701 LOGI(
"ADC channel %u is on pin %u", adc_channel, io_pin);
+
+
+
+
+
+
+
+ 710 if ((sample_rate < SOC_ADC_SAMPLE_FREQ_THRES_LOW) ||
+ 711 (sample_rate > SOC_ADC_SAMPLE_FREQ_THRES_HIGH)) {
+ 712 LOGE(
"sample rate eff: %u can not be set, range: %u to %u", sample_rate,
+ 713 SOC_ADC_SAMPLE_FREQ_THRES_LOW, SOC_ADC_SAMPLE_FREQ_THRES_HIGH);
+
+
+ 716 LOGI(
"sample rate eff: %u, range: %u to %u", sample_rate,
+ 717 SOC_ADC_SAMPLE_FREQ_THRES_LOW, SOC_ADC_SAMPLE_FREQ_THRES_HIGH);
-
-
- 721 LOGE(
"bits per sample: error. It should be: %d but is %d",
-
-
-
-
-
-
-
-
- 731 if (!cfg.adc_calibration_active)
-
-
-
-
-
-
- 738 if (adc_cali_handle == NULL) {
- 739 #if ADC_CALI_SCHEME_CURVE_FITTING_SUPPORTED
-
- 741 adc_cali_curve_fitting_config_t cali_config;
- 742 cali_config.unit_id = ADC_UNIT;
- 743 cali_config.atten = (adc_atten_t)cfg.adc_attenuation;
- 744 cali_config.bitwidth = (adc_bitwidth_t)cfg.adc_bit_width;
- 745 auto err = adc_cali_create_scheme_curve_fitting(&cali_config, &adc_cali_handle);
- 746 #elif !defined(CONFIG_IDF_TARGET_ESP32H2)
-
- 748 adc_cali_line_fitting_config_t cali_config;
- 749 cali_config.unit_id = ADC_UNIT;
- 750 cali_config.atten = (adc_atten_t)cfg.adc_attenuation;
- 751 cali_config.bitwidth = (adc_bitwidth_t)cfg.adc_bit_width;
- 752 auto err = adc_cali_create_scheme_line_fitting(&cali_config, &adc_cali_handle);
-
-
- 755 LOGE(
"creating calibration handle failed for ADC%d with atten %d and bitwidth %d",
- 756 ADC_UNIT, cfg.adc_attenuation, cfg.adc_bit_width);
-
-
- 759 LOGI(
"enabled calibration for ADC%d with atten %d and bitwidth %d",
- 760 ADC_UNIT, cfg.adc_attenuation, cfg.adc_bit_width);
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+ 724 int supported_bits = 16;
+
+
+
+
+
+
+
+
+
+ 734 LOGE(
"bits per sample: error. It should be: %d but is %d",
+
+
+
+
+
+
+
+
+ 744 if (!cfg.adc_calibration_active)
+
+
+
+
+
+
+ 751 if (adc_cali_handle == NULL) {
+ 752 #if ADC_CALI_SCHEME_CURVE_FITTING_SUPPORTED
+
+ 754 adc_cali_curve_fitting_config_t cali_config;
+ 755 cali_config.unit_id = ADC_UNIT;
+ 756 cali_config.atten = (adc_atten_t)cfg.adc_attenuation;
+ 757 cali_config.bitwidth = (adc_bitwidth_t)cfg.adc_bit_width;
+ 758 auto err = adc_cali_create_scheme_curve_fitting(&cali_config, &adc_cali_handle);
+ 759 #elif !defined(CONFIG_IDF_TARGET_ESP32H2)
+
+ 761 adc_cali_line_fitting_config_t cali_config;
+ 762 cali_config.unit_id = ADC_UNIT;
+ 763 cali_config.atten = (adc_atten_t)cfg.adc_attenuation;
+ 764 cali_config.bitwidth = (adc_bitwidth_t)cfg.adc_bit_width;
+ 765 auto err = adc_cali_create_scheme_line_fitting(&cali_config, &adc_cali_handle);
+
+
+ 768 LOGE(
"creating calibration handle failed for ADC%d with atten %d and bitwidth %d",
+ 769 ADC_UNIT, cfg.adc_attenuation, cfg.adc_bit_width);
+
+
+ 772 LOGI(
"enabled calibration for ADC%d with atten %d and bitwidth %d",
+ 773 ADC_UNIT, cfg.adc_attenuation, cfg.adc_bit_width);
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
-
+
-
+
+
+
-
-
-
+
+
+
diff --git a/classaudio__tools_1_1_analog_driver_e_s_p32_v1-members.html b/classaudio__tools_1_1_analog_driver_e_s_p32_v1-members.html
index c7add0cee..7e78380de 100644
--- a/classaudio__tools_1_1_analog_driver_e_s_p32_v1-members.html
+++ b/classaudio__tools_1_1_analog_driver_e_s_p32_v1-members.html
@@ -88,17 +88,18 @@
checkADCBitWidth() | AnalogDriverESP32V1 | inlineprotected |
checkADCChannels() | AnalogDriverESP32V1 | inlineprotected |
checkADCSampleRate() | AnalogDriverESP32V1 | inlineprotected |
- cleanup_rx() (defined in AnalogDriverESP32V1) | AnalogDriverESP32V1 | inlineprotected |
- converter (defined in AnalogDriverESP32V1) | AnalogDriverESP32V1 | protected |
- end() override | AnalogDriverESP32V1 | inlinevirtual |
- fifo_buffers (defined in AnalogDriverESP32V1) | AnalogDriverESP32V1 | protected |
- readBytes(uint8_t *dest, size_t size_bytes) override (defined in AnalogDriverESP32V1) | AnalogDriverESP32V1 | inlinevirtual |
- setup_rx() (defined in AnalogDriverESP32V1) | AnalogDriverESP32V1 | inlineprotected |
- setup_tx() (defined in AnalogDriverESP32V1) | AnalogDriverESP32V1 | inlineprotected |
- setupADCCalibration() | AnalogDriverESP32V1 | inlineprotected |
- this (defined in AnalogDriverESP32V1) | AnalogDriverESP32V1 | protected |
- write(const uint8_t *src, size_t size_bytes) override (defined in AnalogDriverESP32V1) | AnalogDriverESP32V1 | inlinevirtual |
- ~AnalogDriverESP32V1() | AnalogDriverESP32V1 | inlinevirtual |
+ cleanup_rx() | AnalogDriverESP32V1 | inlineprotected |
+ cleanup_tx() | AnalogDriverESP32V1 | inlineprotected |
+ converter (defined in AnalogDriverESP32V1) | AnalogDriverESP32V1 | protected |
+ end() override | AnalogDriverESP32V1 | inlinevirtual |
+ fifo_buffers (defined in AnalogDriverESP32V1) | AnalogDriverESP32V1 | protected |
+ readBytes(uint8_t *dest, size_t size_bytes) override (defined in AnalogDriverESP32V1) | AnalogDriverESP32V1 | inlinevirtual |
+ setup_rx() (defined in AnalogDriverESP32V1) | AnalogDriverESP32V1 | inlineprotected |
+ setup_tx() (defined in AnalogDriverESP32V1) | AnalogDriverESP32V1 | inlineprotected |
+ setupADCCalibration() | AnalogDriverESP32V1 | inlineprotected |
+ this (defined in AnalogDriverESP32V1) | AnalogDriverESP32V1 | protected |
+ write(const uint8_t *src, size_t size_bytes) override (defined in AnalogDriverESP32V1) | AnalogDriverESP32V1 | inlinevirtual |
+ ~AnalogDriverESP32V1() | AnalogDriverESP32V1 | inlinevirtual |