mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
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
This commit is contained in:
parent
eff2e4eddd
commit
ab4157b6cf
@ -21,7 +21,8 @@ else()
|
|||||||
list(APPEND sources "patches/esp_rom_crc.c"
|
list(APPEND sources "patches/esp_rom_crc.c"
|
||||||
"patches/esp_rom_uart.c"
|
"patches/esp_rom_uart.c"
|
||||||
"patches/esp_rom_spiflash.c"
|
"patches/esp_rom_spiflash.c"
|
||||||
"patches/esp_rom_efuse.c")
|
"patches/esp_rom_efuse.c"
|
||||||
|
"patches/esp_rom_gpio.c")
|
||||||
|
|
||||||
|
|
||||||
# Override regi2c implementation in ROM
|
# Override regi2c implementation in ROM
|
||||||
|
@ -66,6 +66,7 @@ void esp_rom_gpio_connect_in_signal(uint32_t gpio_num, uint32_t signal_idx, bool
|
|||||||
* @brief Combine a peripheral signal which tagged as output attribute with a GPIO.
|
* @brief Combine a peripheral signal which tagged as output attribute with a GPIO.
|
||||||
*
|
*
|
||||||
* @note There's no limitation on the number of signals that a GPIO can combine with.
|
* @note There's no limitation on the number of signals that a GPIO can combine with.
|
||||||
|
* @note Internally, the signal will be connected first, then output will be enabled on the pad.
|
||||||
*
|
*
|
||||||
* @param gpio_num GPIO number
|
* @param gpio_num GPIO number
|
||||||
* @param signal_idx Peripheral signal index (tagged as output attribute). Particularly, `SIG_GPIO_OUT_IDX` means disconnect GPIO and other peripherals. Only the GPIO driver can control the output level.
|
* @param signal_idx Peripheral signal index (tagged as output attribute). Particularly, `SIG_GPIO_OUT_IDX` means disconnect GPIO and other peripherals. Only the GPIO driver can control the output level.
|
||||||
|
28
components/esp_rom/patches/esp_rom_gpio.c
Normal file
28
components/esp_rom/patches/esp_rom_gpio.c
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
/*
|
||||||
|
* 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
|
Loading…
Reference in New Issue
Block a user