Song Ruo Jing d555ea2b00 fix(gpio): patched esp_rom_gpio_connect_out_signal for esp32 and esp32s2
The original ROM function enabled output for the pad first, and then connected the signal
This could result in an undesired level change at the pad

Closes https://github.com/espressif/esp-idf/issues/12826
2024-12-25 13:56:46 +08:00

29 lines
884 B
C

/*
* SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#include "sdkconfig.h"
#include "esp_attr.h"
#include "esp_rom_gpio.h"
#include "soc/gpio_reg.h"
#if CONFIG_IDF_TARGET_ESP32 || CONFIG_IDF_TARGET_ESP32S2
// On such targets, the ROM code for this function enabled output for the pad first, and then connected the signal
// This could result in an undesired glitch at the pad
IRAM_ATTR void esp_rom_gpio_connect_out_signal(uint32_t gpio_num, uint32_t signal_idx, bool out_inv, bool oen_inv)
{
uint32_t value = signal_idx << GPIO_FUNC0_OUT_SEL_S;
if (out_inv) {
value |= GPIO_FUNC0_OUT_INV_SEL_M;
}
if (oen_inv) {
value |= GPIO_FUNC0_OEN_INV_SEL_M;
}
REG_WRITE(GPIO_FUNC0_OUT_SEL_CFG_REG + (gpio_num * 4), value);
REG_WRITE(GPIO_ENABLE_W1TS_REG, (1 << gpio_num));
}
#endif