@@ -183,7 +183,7 @@ class AnalogDriverESP32V1 : public AnalogDriverBase {
183183 bool active_rx = false ;
184184 ConverterAutoCenter auto_center;
185185 #ifdef HAS_ESP32_DAC
186- dac_continuous_handle_t dac_handle;
186+ dac_continuous_handle_t dac_handle = nullptr ;
187187 #endif
188188
189189 // create array of FIFO buffers, one for each channel
@@ -268,8 +268,6 @@ class AnalogDriverESP32V1 : public AnalogDriverBase {
268268 uint16_t *result16 = (uint16_t *)dest; // pointer to the destination buffer
269269 uint16_t *end = (uint16_t *)(dest + size_bytes); // pointer to the end of the destination buffer
270270
271-
272-
273271 // 1) read the requested bytes from the buffer
274272 // LOGI("adc_continuous_read request:%d samples %d bytes requested", samples_requested, (uint32_t)(samples_requested * sizeof(adc_digi_output_data_t)));
275273 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) {
@@ -422,7 +420,7 @@ class AnalogDriverESP32V1 : public AnalogDriverBase {
422420 }
423421
424422 protected:
425- AnalogDriverESP32V1 *self;
423+ AnalogDriverESP32V1 *self = nullptr ;
426424
427425 } io{this };
428426
@@ -614,6 +612,7 @@ class AnalogDriverESP32V1 : public AnalogDriverBase {
614612 bool cleanup_tx () {
615613 bool ok = true ;
616614#ifdef HAS_ESP32_DAC
615+ if (dac_handle==nullptr ) return true ;
617616 if (dac_continuous_disable (dac_handle) != ESP_OK){
618617 ok = false ;
619618 LOGE (" dac_continuous_disable failed" );
@@ -622,13 +621,14 @@ class AnalogDriverESP32V1 : public AnalogDriverBase {
622621 ok = false ;
623622 LOGE (" dac_continuous_del_channels failed" );
624623 }
624+ dac_handle = nullptr ;
625625#endif
626626 return ok;
627627 }
628628
629629 // / Cleanup Analog to Digital Converter
630630 bool cleanup_rx () {
631-
631+ if (adc_handle== nullptr ) return true ;
632632 adc_continuous_stop (adc_handle);
633633 adc_continuous_deinit (adc_handle);
634634 if (cfg.adc_calibration_active ) {
@@ -661,7 +661,7 @@ class AnalogDriverESP32V1 : public AnalogDriverBase {
661661 }
662662 }
663663 #endif
664-
664+ adc_handle = nullptr ;
665665 return true ; // Return true to indicate successful cleanup
666666 }
667667
0 commit comments