Skip to content

Commit 9ed617f

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

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,6 +20,6 @@ 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 call `gpio_iomux_out` to select the IO MUX function index, and also call `gpio_iomux_in` to 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.

components/esp_driver_parlio/src/parlio_rx.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,6 @@ static esp_err_t s_parlio_rx_unit_set_gpio(parlio_rx_unit_handle_t rx_unit, cons
256256
if (config->clk_src == PARLIO_CLK_SRC_EXTERNAL) {
257257
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");
258258
/* Connect the clock in signal to the GPIO matrix if it is set */
259-
gpio_func_sel(config->clk_in_gpio_num, PIN_FUNC_GPIO);
260259
gpio_input_enable(config->clk_in_gpio_num);
261260

262261
// deprecated, to be removed in in esp-idf v6.0
@@ -288,7 +287,6 @@ static esp_err_t s_parlio_rx_unit_set_gpio(parlio_rx_unit_handle_t rx_unit, cons
288287

289288
/* Initialize the valid GPIO as input */
290289
if (config->valid_gpio_num >= 0) {
291-
gpio_func_sel(config->valid_gpio_num, PIN_FUNC_GPIO);
292290
gpio_input_enable(config->valid_gpio_num);
293291

294292
// deprecated, to be removed in in esp-idf v6.0
@@ -303,7 +301,6 @@ static esp_err_t s_parlio_rx_unit_set_gpio(parlio_rx_unit_handle_t rx_unit, cons
303301
for (int i = 0; i < config->data_width; i++) {
304302
/* Loop the data_gpio_nums to connect data and valid signals via GPIO matrix */
305303
if (config->data_gpio_nums[i] >= 0) {
306-
gpio_func_sel(config->data_gpio_nums[i], PIN_FUNC_GPIO);
307304
gpio_input_enable(config->data_gpio_nums[i]);
308305

309306
// 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
@@ -182,7 +182,6 @@ static esp_err_t parlio_tx_unit_configure_gpio(parlio_tx_unit_t *tx_unit, const
182182
parlio_periph_signals.groups[group_id].tx_units[unit_id].clk_out_sig, false, false);
183183
}
184184
if (config->clk_in_gpio_num >= 0) {
185-
gpio_func_sel(config->clk_in_gpio_num, PIN_FUNC_GPIO);
186185
gpio_input_enable(config->clk_in_gpio_num);
187186

188187
// 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
@@ -771,7 +771,6 @@ esp_err_t uart_set_pin(uart_port_t uart_num, int tx_io_num, int rx_io_num, int r
771771
if (rx_io_num >= 0 && (tx_rx_same_io || !uart_try_set_iomux_pin(uart_num, rx_io_num, SOC_UART_RX_PIN_IDX))) {
772772
io_reserve_mask &= ~BIT64(rx_io_num); // input IO via GPIO matrix does not need to be reserved
773773
if (uart_num < SOC_UART_HP_NUM) {
774-
gpio_func_sel(rx_io_num, PIN_FUNC_GPIO);
775774
gpio_input_enable(rx_io_num);
776775
esp_rom_gpio_connect_in_signal(rx_io_num, UART_PERIPH_SIGNAL(uart_num, SOC_UART_RX_PIN_IDX), 0);
777776
}
@@ -806,7 +805,6 @@ esp_err_t uart_set_pin(uart_port_t uart_num, int tx_io_num, int rx_io_num, int r
806805
if (cts_io_num >= 0 && !uart_try_set_iomux_pin(uart_num, cts_io_num, SOC_UART_CTS_PIN_IDX)) {
807806
io_reserve_mask &= ~BIT64(cts_io_num); // input IO via GPIO matrix does not need to be reserved
808807
if (uart_num < SOC_UART_HP_NUM) {
809-
gpio_func_sel(cts_io_num, PIN_FUNC_GPIO);
810808
gpio_pullup_en(cts_io_num);
811809
gpio_input_enable(cts_io_num);
812810
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)