Skip to content

Commit e472fb6

Browse files
sylvioalveskartben
authored andcommitted
drivers: adc: esp32: delete previous calibration curve
In case channel_setup is called with a new attenuation config, make sure previous calibration scheme is deleted properly. Signed-off-by: Sylvio Alves <[email protected]>
1 parent 40b474c commit e472fb6

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

drivers/adc/adc_esp32.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -535,6 +535,11 @@ static int adc_esp32_channel_setup(const struct device *dev, const struct adc_ch
535535
conf->unit, cfg->channel_id, data->attenuation[cfg->channel_id],
536536
data->resolution[cfg->channel_id]);
537537

538+
if (data->cal_handle[cfg->channel_id] != NULL) {
539+
/* delete pre-existing calib scheme */
540+
adc_cali_delete_scheme_curve_fitting(data->cal_handle[cfg->channel_id]);
541+
}
542+
538543
adc_cali_create_scheme_curve_fitting(&cal_config,
539544
&data->cal_handle[cfg->channel_id]);
540545
#endif /* ADC_CALI_SCHEME_CURVE_FITTING_SUPPORTED */
@@ -553,6 +558,11 @@ static int adc_esp32_channel_setup(const struct device *dev, const struct adc_ch
553558
conf->unit, cfg->channel_id, data->attenuation[cfg->channel_id],
554559
data->resolution[cfg->channel_id]);
555560

561+
if (data->cal_handle[cfg->channel_id] != NULL) {
562+
/* delete pre-existing calib scheme */
563+
adc_cali_delete_scheme_curve_fitting(data->cal_handle[cfg->channel_id]);
564+
}
565+
556566
adc_cali_create_scheme_line_fitting(&cal_config,
557567
&data->cal_handle[cfg->channel_id]);
558568
#endif /* ADC_CALI_SCHEME_LINE_FITTING_SUPPORTED */

0 commit comments

Comments
 (0)