Well, you set all four pins to "not-used" when you used:
UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE
(I think uart_pin_no_change is ambiguous and should something like uart_pin_not_used or something, but it is what it is)
I leave uart-0 system messages on the usb port (which I only use for flashing and testing), but re-purpose the uart pins. I also use uart1 and uart2 streaming at 230400:
// TTY_UART is USB-serial port 0 -- console/debug at 115200-baud:
#define TTY_UART_PORT UART_NUM_0
#define TTY_UART_BAUD (115200)
#define TTY_UART_RXBUF_SIZE (160) // hw fifo fills this via driver; must be > 128
#define TTY_UART_TXBUF_SIZE (256) //
#define TTY_UART_TX_PIN UART_PIN_NO_CHANGE // (for usb, no pin change)
#define TTY_UART_RX_PIN UART_PIN_NO_CHANGE // (for usb, no pin change)
// ADC_UART is serial port 1 -- ADC interface at 230400-baud:
#define ADC_UART_PORT UART_NUM_1
#define ADC_UART_BAUD (230400)
#define ADC_UART_RXBUF_SIZE (160) // hw fifo fills this via driver; must be > 128
#define ADC_UART_TXBUF_SIZE (256)
#define ADC_UART_TX_PIN (GPIO_NUM_3)
#define ADC_UART_RX_PIN (GPIO_NUM_8)
////#define SEND_STR_TO_ADC(s) uart_write_bytes(ADC_UART_PORT, (const char *)(s), strlen((const char *)(s)))
// HOST_UART is serial port 2 -- PC interface at 230400-baud:
#define HOST_UART_PORT UART_NUM_2
#define HOST_UART_BAUD (230400)
#define HOST_UART_RXBUF_SIZE (160) // hw fifo fills this via driver; must be > 128
#define HOST_UART_TXBUF_SIZE (256)
#define HOST_UART_TX_PIN (GPIO_NUM_16)
#define HOST_UART_RX_PIN (GPIO_NUM_15)
////#define SEND_TO_HOST(s uart_write_bytes(HOST_UART_PORT, (const char *)(s), strlen((const char *)(s)))
I have init funcs like this:
//------------------------------------------------------------------------------
/**
Inits HOST_UART and starts ISR
@param void *parameter
@return void
*/
void host_uart_init_task(void *parameter)
{
#if defined (HOST_UART_PORT)
while (1)
{
// --- install UART driver/isr and set UART configuration:
// Note: UART ISR handler will be attached to the same CPU core on which this function is running.
//
// params for uart_driver_install(...)
// UART port number
// RX ring buffer size -- should be greater than UART_HW_FIFO_LEN(uart_num) (128 currently)
// TX ring buffer size -- should be either zero or greater than UART_HW_FIFO_LEN(uart_num) (128 currently)
// (if zero, driver will not use buf and will block task until all data sent)
// UART event queue size/depth
// UART event queue handle (new queue handle is written here to provide access to UART events)
// (if set to NULL, driver will not use an event queue)
// Flags used to allocate the interrupt. One or multiple (ORred) ESP_INTR_FLAG_* values. See esp_intr_alloc.h.
// (do not set ESP_INTR_FLAG_IRAM here since the driver's ISR handler is not located in IRAM)
ESP_ERROR_CHECK(uart_driver_install(HOST_UART_PORT, HOST_UART_RXBUF_SIZE, HOST_UART_TXBUF_SIZE, 0, NULL, 0));
// config the port:
uart_config_t uart_config =
{
.baud_rate = HOST_UART_BAUD,
.data_bits = UART_DATA_8_BITS,
.parity = UART_PARITY_DISABLE,
.stop_bits = UART_STOP_BITS_1,
.flow_ctrl = UART_HW_FLOWCTRL_DISABLE,
.source_clk = UART_SCLK_DEFAULT,
.rx_flow_ctrl_thresh = 122,
};
ESP_ERROR_CHECK(uart_param_config(HOST_UART_PORT, &uart_config));
ESP_ERROR_CHECK(uart_set_pin(HOST_UART_PORT, HOST_UART_TX_PIN, HOST_UART_RX_PIN, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE));
ESP_ERROR_CHECK(uart_flush(HOST_UART_PORT));
// and kill this task:
vTaskDelete(NULL);
}
#endif
}
From app_main I start the uarts (uart0 on core 0 with other system stuff, and others I put on core 1):
g_log(TAG, "----- Init StreamBuffers, ADC_UART, and HOST_UART");
init_streambuffers();
xTaskCreatePinnedToCore(adc_uart_init_task, "adc_uart_init_task", STACK_SIZE_UART_INIT_TASK, NULL, PRIORITY_FROM_ADCUART_TASK, NULL, CORE_ADC_UART_TASK);
vTaskDelay(pdMS_TO_TICKS(50));
xTaskCreatePinnedToCore(host_uart_init_task, "host_uart_init_task", STACK_SIZE_UART_INIT_TASK, NULL, PRIORITY_FROM_HOSTUART_TASK, NULL, CORE_HOST_UART_TASK);
vTaskDelay(pdMS_TO_TICKS(50));