@@ -69,17 +69,19 @@ static bool adcDetachBus(void * pin){
69
69
return false;
70
70
}
71
71
adc_handle [adc_unit ].adc_oneshot_handle = NULL ;
72
+ if (adc_handle [adc_unit ].adc_cali_handle != NULL ){
72
73
#if ADC_CALI_SCHEME_CURVE_FITTING_SUPPORTED
73
- err = adc_cali_delete_scheme_curve_fitting (adc_handle [adc_unit ].adc_cali_handle );
74
- if (err != ESP_OK ){
75
- return false;
76
- }
74
+ err = adc_cali_delete_scheme_curve_fitting (adc_handle [adc_unit ].adc_cali_handle );
75
+ if (err != ESP_OK ){
76
+ return false;
77
+ }
77
78
#elif !defined(CONFIG_IDF_TARGET_ESP32H2 )
78
- err = adc_cali_delete_scheme_line_fitting (adc_handle [adc_unit ].adc_cali_handle );
79
- if (err != ESP_OK ){
80
- return false;
81
- }
79
+ err = adc_cali_delete_scheme_line_fitting (adc_handle [adc_unit ].adc_cali_handle );
80
+ if (err != ESP_OK ){
81
+ return false;
82
+ }
82
83
#endif
84
+ }
83
85
adc_handle [adc_unit ].adc_cali_handle = NULL ;
84
86
}
85
87
return true;
@@ -220,6 +222,7 @@ esp_err_t __analogInit(uint8_t pin, adc_channel_t channel, adc_unit_t adc_unit){
220
222
return err ;
221
223
}
222
224
}
225
+ perimanSetBusDeinit (ESP32_BUS_TYPE_ADC_ONESHOT , adcDetachBus );
223
226
224
227
if (!perimanSetPinBus (pin , ESP32_BUS_TYPE_ADC_ONESHOT , (void * )(pin + 1 ), adc_unit , channel )){
225
228
adcDetachBus ((void * )(pin + 1 ));
@@ -236,7 +239,6 @@ esp_err_t __analogInit(uint8_t pin, adc_channel_t channel, adc_unit_t adc_unit){
236
239
log_e ("adc_oneshot_config_channel failed with error: %d" , err );
237
240
return err ;
238
241
}
239
- perimanSetBusDeinit (ESP32_BUS_TYPE_ADC_ONESHOT , adcDetachBus );
240
242
return ESP_OK ;
241
243
}
242
244
@@ -377,18 +379,19 @@ static bool adcContinuousDetachBus(void * adc_unit_number){
377
379
return false;
378
380
}
379
381
adc_handle [adc_unit ].adc_continuous_handle = NULL ;
380
-
381
- #if ADC_CALI_SCHEME_CURVE_FITTING_SUPPORTED
382
- err = adc_cali_delete_scheme_curve_fitting (adc_handle [adc_unit ].adc_cali_handle );
383
- if (err != ESP_OK ){
384
- return false;
385
- }
382
+ if ( adc_handle [ adc_unit ]. adc_cali_handle != NULL ){
383
+ #if ADC_CALI_SCHEME_CURVE_FITTING_SUPPORTED
384
+ err = adc_cali_delete_scheme_curve_fitting (adc_handle [adc_unit ].adc_cali_handle );
385
+ if (err != ESP_OK ){
386
+ return false;
387
+ }
386
388
#elif !defined(CONFIG_IDF_TARGET_ESP32H2 )
387
- err = adc_cali_delete_scheme_line_fitting (adc_handle [adc_unit ].adc_cali_handle );
388
- if (err != ESP_OK ){
389
- return false;
390
- }
389
+ err = adc_cali_delete_scheme_line_fitting (adc_handle [adc_unit ].adc_cali_handle );
390
+ if (err != ESP_OK ){
391
+ return false;
392
+ }
391
393
#endif
394
+ }
392
395
adc_handle [adc_unit ].adc_cali_handle = NULL ;
393
396
394
397
//set all used pins to INIT state
0 commit comments