I'm trying to write data to the UART while my custom ISR is active. The ISR gets triggered on incoming UART data. And is able to send the bytes back (echo). This however only works when the tx_buffer in `uart_driver_install()` is 0. But when It's 0 then any `uart_write_bytes()` outside of the ISR don't really send anything (up to 10 bytes per boot). So when I set a tx buffer (512 in the code below) the ISR is not able to echo the data and any `uart_write_bytes()` function outside of the ISR report that all the bytes are written but the tx buffer seem to be never handeled. Please see my code below.
Code: Select all
ESP_LOGI("MAIN", "hello world!");
ESP_LOGD("UART", "START");
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_DISABLE,
.rx_flow_ctrl_thresh = 122
};
ESP_ERROR_CHECK(uart_param_config(UART_NUM_0, &uart_config));
ESP_ERROR_CHECK(uart_set_pin(UART_NUM_0, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE));
ESP_ERROR_CHECK(uart_driver_install(UART_NUM_0, 1024, 512, 0, NULL, 0));
ESP_ERROR_CHECK(uart_isr_free(UART_NUM_0));
ESP_ERROR_CHECK(uart_isr_register(UART_NUM_0, uart_intr_handle, NULL, ESP_INTR_FLAG_IRAM, &handle_console));
ESP_ERROR_CHECK(uart_enable_rx_intr(UART_NUM_0));
const char test[] = "CCis is a test string.\n";
ESP_LOGI("UART", "write:%d",uart_write_bytes(UART_NUM_0, "4444\n", 5));
ESP_LOGI("UART", "write:%d",uart_write_bytes(UART_NUM_0, "4444\n", 5));
ESP_LOGI("UART", "write:%d",uart_write_bytes(UART_NUM_0, "55555\n", 6));
ESP_LOGI("UART", "write:%d",uart_write_bytes(UART_NUM_0, "666666\n", 7));
ESP_LOGI("UART", "write:%d",uart_write_bytes(UART_NUM_0, test, 23));
ESP_LOGI("MAIN", "Job done!");
Code: Select all
I (112) MAIN: hello world!
D (112) UART: START
D (112) intr_alloc: Connected src 34 to int 13 (cpu 0)
D (112) intr_alloc: Connected src 34 to int 13 (cpu 0)
I (112) UART: write:5
I (112) UART: write:5
I (112) UART: write:6
I (112) UART: write:7
I (112) UART: write:23
I (112) MAIN: Job done!