I'm setting up flow control through the following:
Code: Select all
static const int RX_BUF_SIZE = 4096;
#define TXD_PIN (GPIO_NUM_15)
#define RXD_PIN (GPIO_NUM_13)
#define RTS_PIN (GPIO_NUM_14)
#define CTS_PIN (GPIO_NUM_12)
static void InitUART(void)
{
ESP_LOGI(SPP_TAG, "Configuring UART");
const uart_config_t uart_config = {
.baud_rate = 921600,
.data_bits = UART_DATA_8_BITS,
.parity = UART_PARITY_DISABLE,
.stop_bits = UART_STOP_BITS_1,
.flow_ctrl = UART_HW_FLOWCTRL_CTS_RTS,
.source_clk = UART_SCLK_APB,
};
// We won't use a buffer for sending data.
// uart_set_pin(UART_NUM_1, TXD_PIN, RXD_PIN, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE);
uart_set_pin(UART_NUM_1, TXD_PIN, RXD_PIN, RTS_PIN, CTS_PIN);
ESP_ERROR_CHECK(uart_set_hw_flow_ctrl(UART_NUM_1, UART_HW_FLOWCTRL_CTS_RTS, UART_FIFO_LEN - 8));
uart_driver_install(UART_NUM_1, RX_BUF_SIZE * 2, 0, 0, NULL, 0);
uart_param_config(UART_NUM_1, &uart_config);
}