From 3e9c1ae62b021e29601c2ecf0f50d84e12c87bef Mon Sep 17 00:00:00 2001 From: gaoxu Date: Mon, 28 Oct 2024 09:38:13 +0800 Subject: [PATCH] fix(adc): fix adc1 error after bootloader random --- .../src/bootloader_random_esp32p4.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/components/bootloader_support/src/bootloader_random_esp32p4.c b/components/bootloader_support/src/bootloader_random_esp32p4.c index df88e8d7b2..bcae51ef43 100644 --- a/components/bootloader_support/src/bootloader_random_esp32p4.c +++ b/components/bootloader_support/src/bootloader_random_esp32p4.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2023-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -94,7 +94,15 @@ void bootloader_random_enable(void) void bootloader_random_disable(void) { - // No-op for now TODO IDF-6497 - // ADC should be set to defaults here, once ADC API is implemented - // OR just keep this empty and let application continue to use RNG initialized by the bootloader + //TODO IDF-4714 + // disable timer + REG_CLR_BIT(ADC_CTRL2_REG, ADC_TIMER_EN); + // Write reset value of this register + REG_WRITE(ADC_SAR1_PATT_TAB1_REG, 0xFFFFFF); + // Revert ADC I2C configuration and initial voltage source setting + REGI2C_WRITE_MASK(I2C_SAR_ADC, I2C_SAR_ADC_SAR1_INIT_CODE_MSB, 0); + REGI2C_WRITE_MASK(I2C_SAR_ADC, I2C_SAR_ADC_SAR1_INIT_CODE_LSB, 0); + + REGI2C_WRITE_MASK(I2C_SAR_ADC, I2C_SAR_ADC_ENT_VDD_GRP1, 0); + REGI2C_WRITE_MASK(I2C_SAR_ADC, I2C_SAR_ADC_DTEST_VDD_GRP1, 0); }