1 /* 2 * SPDX-FileCopyrightText: 2019-2024 Espressif Systems (Shanghai) CO LTD 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 #pragma once 7 8 #include "soc/soc_caps.h" 9 #include "soc/uart_reg.h" 10 #include "soc/uart_struct.h" 11 #include "soc/periph_defs.h" 12 #include "soc/gpio_sig_map.h" 13 #include "soc/io_mux_reg.h" 14 #include "soc/uart_pins.h" 15 #include "soc/uart_struct.h" 16 #include "soc/uart_reg.h" 17 18 #ifdef __cplusplus 19 extern "C" { 20 #endif 21 22 #define SOC_UART_TX_PIN_IDX (0) 23 #define SOC_UART_RX_PIN_IDX (1) 24 #define SOC_UART_RTS_PIN_IDX (2) 25 #define SOC_UART_CTS_PIN_IDX (3) 26 27 /** 28 * @brief Macro that can be used to retrieve the signal of a certain pin for a 29 * certain UART. 30 */ 31 #define UART_PERIPH_SIGNAL(IDX, PIN) (uart_periph_signal[(IDX)].pins[(PIN)].signal) 32 33 typedef struct { 34 /* Default GPIO number for this UART pin in the IOMUX. 35 * This value can be -1 if there is no default GPIO for a pin. 36 * For example, ESP32-C3 doesn't have any default GPIO for 37 * U0CTS and U0RTS. */ 38 int32_t default_gpio : 15; 39 /* Func which should be assigned to the GPIO to be used as UART */ 40 int32_t iomux_func : 4; 41 /* Marks if the current UART pin is input (or not) */ 42 uint32_t input : 1; 43 /* Signal in the GPIO signal map. */ 44 uint32_t signal : 12; 45 } uart_periph_sig_t; 46 47 typedef struct { 48 const uart_periph_sig_t pins[SOC_UART_PINS_COUNT]; 49 const uint8_t irq; 50 const periph_module_t module; 51 } uart_signal_conn_t; 52 53 extern const uart_signal_conn_t uart_periph_signal[SOC_UART_NUM]; 54 55 #ifdef __cplusplus 56 } 57 #endif 58