mirror of
https://github.com/espressif/esp-idf.git
synced 2026-04-27 19:13:21 +00:00
feat(lp_adc): Set LP ADC calibration params
This commit sets the calibration parameters for a a given LP ADC unit and channel to improve the raw LP ADC reading when read from the LP core. The calibration params are set from the HP core.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2024-2026 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -10,6 +10,8 @@
|
||||
#include "ulp_lp_core_lp_adc_shared.h"
|
||||
#include "hal/adc_types.h"
|
||||
#include "hal/adc_ll.h"
|
||||
#include "hal/adc_hal_common.h"
|
||||
#include "esp_private/adc_share_hw_ctrl.h"
|
||||
|
||||
#define VREF (1100) /* Internal Reference voltage in millivolts (1.1V) */
|
||||
#define INV_ATTEN_0DB (1000) /* Inverse of 10^0 * 1000 */
|
||||
@@ -75,8 +77,19 @@ esp_err_t lp_core_lp_adc_config_channel(adc_unit_t unit_id, adc_channel_t channe
|
||||
.bitwidth = chan_config->bitwidth,
|
||||
};
|
||||
|
||||
return (adc_oneshot_config_channel(s_adc1_handle, channel, &config));
|
||||
ret = adc_oneshot_config_channel(s_adc_unit_handles[unit_id], channel, &config);
|
||||
if (ret != ESP_OK) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Set the calibration parameters for the ADC unit and channel */
|
||||
#if SOC_ADC_CALIBRATION_V1_SUPPORTED
|
||||
adc_hal_calibration_init(unit_id);
|
||||
adc_set_hw_calibration_code(unit_id, chan_config->atten);
|
||||
#endif /* SOC_ADC_CALIBRATION_V1_SUPPORTED */
|
||||
#endif /* IS_ULP_COCPU */
|
||||
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t lp_core_lp_adc_read_channel_raw(adc_unit_t unit_id, adc_channel_t channel, int *adc_raw)
|
||||
|
||||
Reference in New Issue
Block a user