@@ -183,7 +183,7 @@ class AnalogDriverESP32V1 : public AnalogDriverBase {
183
183
bool active_rx = false ;
184
184
ConverterAutoCenter auto_center;
185
185
#ifdef HAS_ESP32_DAC
186
- dac_continuous_handle_t dac_handle;
186
+ dac_continuous_handle_t dac_handle = nullptr ;
187
187
#endif
188
188
189
189
// create array of FIFO buffers, one for each channel
@@ -268,8 +268,6 @@ class AnalogDriverESP32V1 : public AnalogDriverBase {
268
268
uint16_t *result16 = (uint16_t *)dest; // pointer to the destination buffer
269
269
uint16_t *end = (uint16_t *)(dest + size_bytes); // pointer to the end of the destination buffer
270
270
271
-
272
-
273
271
// 1) read the requested bytes from the buffer
274
272
// LOGI("adc_continuous_read request:%d samples %d bytes requested", samples_requested, (uint32_t)(samples_requested * sizeof(adc_digi_output_data_t)));
275
273
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 {
422
420
}
423
421
424
422
protected:
425
- AnalogDriverESP32V1 *self;
423
+ AnalogDriverESP32V1 *self = nullptr ;
426
424
427
425
} io{this };
428
426
@@ -614,6 +612,7 @@ class AnalogDriverESP32V1 : public AnalogDriverBase {
614
612
bool cleanup_tx () {
615
613
bool ok = true ;
616
614
#ifdef HAS_ESP32_DAC
615
+ if (dac_handle==nullptr ) return true ;
617
616
if (dac_continuous_disable (dac_handle) != ESP_OK){
618
617
ok = false ;
619
618
LOGE (" dac_continuous_disable failed" );
@@ -622,13 +621,14 @@ class AnalogDriverESP32V1 : public AnalogDriverBase {
622
621
ok = false ;
623
622
LOGE (" dac_continuous_del_channels failed" );
624
623
}
624
+ dac_handle = nullptr ;
625
625
#endif
626
626
return ok;
627
627
}
628
628
629
629
// / Cleanup Analog to Digital Converter
630
630
bool cleanup_rx () {
631
-
631
+ if (adc_handle== nullptr ) return true ;
632
632
adc_continuous_stop (adc_handle);
633
633
adc_continuous_deinit (adc_handle);
634
634
if (cfg.adc_calibration_active ) {
@@ -661,7 +661,7 @@ class AnalogDriverESP32V1 : public AnalogDriverBase {
661
661
}
662
662
}
663
663
#endif
664
-
664
+ adc_handle = nullptr ;
665
665
return true ; // Return true to indicate successful cleanup
666
666
}
667
667
0 commit comments