mirror of
https://github.com/espressif/esp-idf.git
synced 2025-11-29 21:59:32 +01:00
refactor(uart): use U0RXD_GPIO_NUM and U0TXD_GPIO_NUM macros when possible
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
#include "bootloader_console.h"
|
||||
#include "soc/soc_caps.h"
|
||||
#include "soc/uart_periph.h"
|
||||
#include "soc/uart_channel.h"
|
||||
#include "soc/uart_pins.h"
|
||||
#include "soc/io_mux_reg.h"
|
||||
#include "soc/gpio_sig_map.h"
|
||||
#include "soc/rtc.h"
|
||||
@@ -29,7 +29,7 @@
|
||||
static void __attribute__((unused)) release_default_console_io(void)
|
||||
{
|
||||
// Default console is UART0 with TX and RX on their IOMUX pins
|
||||
gpio_ll_output_disable(&GPIO, UART_NUM_0_TXD_DIRECT_GPIO_NUM);
|
||||
gpio_ll_output_disable(&GPIO, U0TXD_GPIO_NUM);
|
||||
esp_rom_gpio_connect_in_signal(GPIO_MATRIX_CONST_ONE_INPUT, UART_PERIPH_SIGNAL(UART_NUM_0, SOC_UART_RX_PIN_IDX), 0);
|
||||
}
|
||||
|
||||
@@ -59,8 +59,8 @@ void bootloader_console_init(void)
|
||||
|
||||
#if CONFIG_ESP_CONSOLE_UART_CUSTOM
|
||||
// Some constants to make the following code less upper-case
|
||||
const int uart_tx_gpio = (CONFIG_ESP_CONSOLE_UART_TX_GPIO >= 0) ? CONFIG_ESP_CONSOLE_UART_TX_GPIO : UART_NUM_0_TXD_DIRECT_GPIO_NUM;
|
||||
const int uart_rx_gpio = (CONFIG_ESP_CONSOLE_UART_RX_GPIO >= 0) ? CONFIG_ESP_CONSOLE_UART_RX_GPIO : UART_NUM_0_RXD_DIRECT_GPIO_NUM;
|
||||
const int uart_tx_gpio = (CONFIG_ESP_CONSOLE_UART_TX_GPIO >= 0) ? CONFIG_ESP_CONSOLE_UART_TX_GPIO : U0TXD_GPIO_NUM;
|
||||
const int uart_rx_gpio = (CONFIG_ESP_CONSOLE_UART_RX_GPIO >= 0) ? CONFIG_ESP_CONSOLE_UART_RX_GPIO : U0RXD_GPIO_NUM;
|
||||
|
||||
// Switch to the new UART (this just changes UART number used for esp_rom_printf in ROM code).
|
||||
esp_rom_output_set_as_console(uart_num);
|
||||
@@ -68,8 +68,8 @@ void bootloader_console_init(void)
|
||||
// If console is attached to UART1 or if non-default pins are used,
|
||||
// need to reconfigure pins using GPIO matrix
|
||||
if (uart_num != 0 ||
|
||||
uart_tx_gpio != UART_NUM_0_TXD_DIRECT_GPIO_NUM ||
|
||||
uart_rx_gpio != UART_NUM_0_RXD_DIRECT_GPIO_NUM) {
|
||||
uart_tx_gpio != U0TXD_GPIO_NUM ||
|
||||
uart_rx_gpio != U0RXD_GPIO_NUM) {
|
||||
release_default_console_io();
|
||||
// Route GPIO signals to/from pins
|
||||
const uint32_t tx_idx = UART_PERIPH_SIGNAL(uart_num, SOC_UART_TX_PIN_IDX);
|
||||
|
||||
Reference in New Issue
Block a user