From 403577e3ffd0c4d81c35689a9db6ff88d579aabe Mon Sep 17 00:00:00 2001 From: "Michael (XIAO Xufeng)" Date: Mon, 17 Jan 2022 13:58:56 +0000 Subject: [PATCH] adc_cal: fixed the assertion failure or returning wrong error code when ADC2 failed the arbitration Issue exist since first IDF version supporting ESP32-S2. --- components/esp_adc_cal/esp_adc_cal_common.c | 7 +++++-- components/hal/CMakeLists.txt | 1 - components/hal/esp32s2/adc_hal.c | 0 3 files changed, 5 insertions(+), 3 deletions(-) delete mode 100644 components/hal/esp32s2/adc_hal.c diff --git a/components/esp_adc_cal/esp_adc_cal_common.c b/components/esp_adc_cal/esp_adc_cal_common.c index 809c001625..67dbc32ab8 100644 --- a/components/esp_adc_cal/esp_adc_cal_common.c +++ b/components/esp_adc_cal/esp_adc_cal_common.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2020-2021 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2020-2022 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -33,6 +33,9 @@ esp_err_t esp_adc_cal_get_voltage(adc_channel_t channel, ESP_RETURN_ON_FALSE(channel < SOC_ADC_CHANNEL_NUM(1), ESP_ERR_INVALID_ARG, TAG, "Invalid channel"); ret = adc2_get_raw(channel, chars->bit_width, &adc_reading); } - *voltage = esp_adc_cal_raw_to_voltage((uint32_t)adc_reading, chars); + + if (ret == ESP_OK) { + *voltage = esp_adc_cal_raw_to_voltage((uint32_t)adc_reading, chars); + } return ret; } diff --git a/components/hal/CMakeLists.txt b/components/hal/CMakeLists.txt index fd05f07fd8..e59c6ea37d 100644 --- a/components/hal/CMakeLists.txt +++ b/components/hal/CMakeLists.txt @@ -70,7 +70,6 @@ if(NOT BOOTLOADER_BUILD) "twai_hal.c" "twai_hal_iram.c" "aes_hal.c" - "esp32s2/adc_hal.c" "esp32s2/brownout_hal.c" "esp32s2/cp_dma_hal.c" "esp32s2/touch_sensor_hal.c" diff --git a/components/hal/esp32s2/adc_hal.c b/components/hal/esp32s2/adc_hal.c deleted file mode 100644 index e69de29bb2..0000000000