Skip to content

Commit 1d6bcb8

Browse files
committed
fix(gpio): removed unnecessary step when routing input signal to a pin
1 parent a88bd15 commit 1d6bcb8

File tree

5 files changed

+3
-7
lines changed

5 files changed

+3
-7
lines changed

components/esp_driver_gpio/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ When a peripheral driver does de-initialization, to de-configure the pin as the
2020

2121
If the signal is routed through IO MUX to the pin, then only needs to call `gpio_iomux_input` to select the IO MUX function index and direct the signal to IO MUX. Input will be enabled for the IO internally.
2222

23-
If the signal is routed through GPIO Matrix to the pin, then first call `gpio_func_sel` to let the pin use `PIN_FUNC_GPIO` function, follow by calling `gpio_input_enable` and `esp_rom_gpio_connect_in_signal` to enable the input and connect the signal to the pin.
23+
If the signal is routed through GPIO Matrix to the pin, then call `gpio_input_enable` and `esp_rom_gpio_connect_in_signal` to enable the input and connect the signal to the pin.
2424

2525
When a peripheral driver does de-initialization, to de-configure the pin as the peripheral signal input, use `esp_rom_gpio_connect_in_signal` to connect the signal to CONST_ONE or CONST_ZERO, so that it is disconnected from the pin. It is not desired to call `gpio_input_disable`, because there might be other drivers still using this pin as an input.
2626

components/esp_driver_parlio/src/parlio_rx.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,6 @@ static esp_err_t s_parlio_rx_unit_set_gpio(parlio_rx_unit_handle_t rx_unit, cons
258258
if (config->clk_src == PARLIO_CLK_SRC_EXTERNAL) {
259259
ESP_RETURN_ON_FALSE(config->clk_in_gpio_num >= 0, ESP_ERR_INVALID_ARG, TAG, "clk_in_gpio_num must be set while the clock input from external");
260260
/* Connect the clock in signal to the GPIO matrix if it is set */
261-
gpio_func_sel(config->clk_in_gpio_num, PIN_FUNC_GPIO);
262261
gpio_input_enable(config->clk_in_gpio_num);
263262

264263
// deprecated, to be removed in in esp-idf v6.0
@@ -290,7 +289,6 @@ static esp_err_t s_parlio_rx_unit_set_gpio(parlio_rx_unit_handle_t rx_unit, cons
290289

291290
/* Initialize the valid GPIO as input */
292291
if (config->valid_gpio_num >= 0) {
293-
gpio_func_sel(config->valid_gpio_num, PIN_FUNC_GPIO);
294292
gpio_input_enable(config->valid_gpio_num);
295293

296294
// deprecated, to be removed in in esp-idf v6.0
@@ -305,7 +303,6 @@ static esp_err_t s_parlio_rx_unit_set_gpio(parlio_rx_unit_handle_t rx_unit, cons
305303
for (int i = 0; i < config->data_width; i++) {
306304
/* Loop the data_gpio_nums to connect data and valid signals via GPIO matrix */
307305
if (config->data_gpio_nums[i] >= 0) {
308-
gpio_func_sel(config->data_gpio_nums[i], PIN_FUNC_GPIO);
309306
gpio_input_enable(config->data_gpio_nums[i]);
310307

311308
// deprecated, to be removed in in esp-idf v6.0

components/esp_driver_parlio/src/parlio_tx.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,6 @@ static esp_err_t parlio_tx_unit_configure_gpio(parlio_tx_unit_t *tx_unit, const
183183
parlio_periph_signals.groups[group_id].tx_units[unit_id].clk_out_sig, false, false);
184184
}
185185
if (config->clk_in_gpio_num >= 0) {
186-
gpio_func_sel(config->clk_in_gpio_num, PIN_FUNC_GPIO);
187186
gpio_input_enable(config->clk_in_gpio_num);
188187

189188
// deprecated, to be removed in in esp-idf v6.0

components/esp_driver_uart/src/uart.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -768,7 +768,6 @@ esp_err_t uart_set_pin(uart_port_t uart_num, int tx_io_num, int rx_io_num, int r
768768
if (rx_io_num >= 0 && (tx_rx_same_io || !uart_try_set_iomux_pin(uart_num, rx_io_num, SOC_UART_RX_PIN_IDX))) {
769769
io_reserve_mask &= ~BIT64(rx_io_num); // input IO via GPIO matrix does not need to be reserved
770770
if (uart_num < SOC_UART_HP_NUM) {
771-
gpio_func_sel(rx_io_num, PIN_FUNC_GPIO);
772771
gpio_input_enable(rx_io_num);
773772
esp_rom_gpio_connect_in_signal(rx_io_num, UART_PERIPH_SIGNAL(uart_num, SOC_UART_RX_PIN_IDX), 0);
774773
}
@@ -803,7 +802,6 @@ esp_err_t uart_set_pin(uart_port_t uart_num, int tx_io_num, int rx_io_num, int r
803802
if (cts_io_num >= 0 && !uart_try_set_iomux_pin(uart_num, cts_io_num, SOC_UART_CTS_PIN_IDX)) {
804803
io_reserve_mask &= ~BIT64(cts_io_num); // input IO via GPIO matrix does not need to be reserved
805804
if (uart_num < SOC_UART_HP_NUM) {
806-
gpio_func_sel(cts_io_num, PIN_FUNC_GPIO);
807805
gpio_pullup_en(cts_io_num);
808806
gpio_input_enable(cts_io_num);
809807
esp_rom_gpio_connect_in_signal(cts_io_num, UART_PERIPH_SIGNAL(uart_num, SOC_UART_CTS_PIN_IDX), 0);

components/esp_driver_uart/test_apps/uart/main/test_uart.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include "driver/uart.h"
1111
#include "esp_log.h"
1212
#include "esp_rom_gpio.h"
13+
#include "esp_private/gpio.h"
1314
#if SOC_LP_GPIO_MATRIX_SUPPORTED
1415
#include "driver/lp_io.h"
1516
#include "driver/rtc_io.h"
@@ -463,6 +464,7 @@ TEST_CASE("uart int state restored after flush", "[uart]")
463464
/* Make sure UART's TX signal is connected to RX pin
464465
* This creates a loop that lets us receive anything we send on the UART */
465466
if (uart_num < SOC_UART_HP_NUM) {
467+
gpio_func_sel(uart_rx, PIN_FUNC_GPIO);
466468
esp_rom_gpio_connect_out_signal(uart_rx, uart_tx_signal, false, false);
467469
#if SOC_UART_LP_NUM > 0
468470
} else {

0 commit comments

Comments
 (0)