Skip to content

Commit

Permalink
AnalogDriverESP32V1
Browse files Browse the repository at this point in the history
  • Loading branch information
pschatzmann committed Nov 21, 2024
1 parent eb8063c commit 6f2d956
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/AudioTools/CoreAudio/AudioAnalog/AnalogDriverESP32V1.h
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ class AnalogDriverESP32V1 : public AnalogDriverBase {
bool active_rx = false;
ConverterAutoCenter auto_center;
#ifdef HAS_ESP32_DAC
dac_continuous_handle_t dac_handle;
dac_continuous_handle_t dac_handle = nullptr;
#endif

// create array of FIFO buffers, one for each channel
Expand Down Expand Up @@ -268,8 +268,6 @@ class AnalogDriverESP32V1 : public AnalogDriverBase {
uint16_t *result16 = (uint16_t *)dest; // pointer to the destination buffer
uint16_t *end = (uint16_t *)(dest + size_bytes); // pointer to the end of the destination buffer



// 1) read the requested bytes from the buffer
// LOGI("adc_continuous_read request:%d samples %d bytes requested", samples_requested, (uint32_t)(samples_requested * sizeof(adc_digi_output_data_t)));
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) {
Expand Down Expand Up @@ -422,7 +420,7 @@ class AnalogDriverESP32V1 : public AnalogDriverBase {
}

protected:
AnalogDriverESP32V1 *self;
AnalogDriverESP32V1 *self = nullptr;

} io{this};

Expand Down Expand Up @@ -614,6 +612,7 @@ class AnalogDriverESP32V1 : public AnalogDriverBase {
bool cleanup_tx() {
bool ok = true;
#ifdef HAS_ESP32_DAC
if (dac_handle==nullptr) return true;
if (dac_continuous_disable(dac_handle) != ESP_OK){
ok = false;
LOGE("dac_continuous_disable failed");
Expand All @@ -622,13 +621,14 @@ class AnalogDriverESP32V1 : public AnalogDriverBase {
ok = false;
LOGE("dac_continuous_del_channels failed");
}
dac_handle = nullptr;
#endif
return ok;
}

/// Cleanup Analog to Digital Converter
bool cleanup_rx() {

if (adc_handle==nullptr) return true;
adc_continuous_stop(adc_handle);
adc_continuous_deinit(adc_handle);
if (cfg.adc_calibration_active) {
Expand Down Expand Up @@ -661,7 +661,7 @@ class AnalogDriverESP32V1 : public AnalogDriverBase {
}
}
#endif

adc_handle = nullptr;
return true; // Return true to indicate successful cleanup
}

Expand Down

0 comments on commit 6f2d956

Please sign in to comment.