1 /*
2 * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
7 #include "sdkconfig.h"
8 #include "esp_attr.h"
9 #include "esp_rom_gpio.h"
10 #include "soc/gpio_reg.h"
11
12 #if CONFIG_IDF_TARGET_ESP32 || CONFIG_IDF_TARGET_ESP32S2
13 // On such targets, the ROM code for this function enabled output for the pad first, and then connected the signal
14 // This could result in an undesired glitch at the pad
esp_rom_gpio_connect_out_signal(uint32_t gpio_num,uint32_t signal_idx,bool out_inv,bool oen_inv)15 IRAM_ATTR void esp_rom_gpio_connect_out_signal(uint32_t gpio_num, uint32_t signal_idx, bool out_inv, bool oen_inv)
16 {
17 uint32_t value = signal_idx << GPIO_FUNC0_OUT_SEL_S;
18 if (out_inv) {
19 value |= GPIO_FUNC0_OUT_INV_SEL_M;
20 }
21 if (oen_inv) {
22 value |= GPIO_FUNC0_OEN_INV_SEL_M;
23 }
24 REG_WRITE(GPIO_FUNC0_OUT_SEL_CFG_REG + (gpio_num * 4), value);
25
26 REG_WRITE(GPIO_ENABLE_W1TS_REG, (1 << gpio_num));
27 }
28 #endif
29