I have problem with UART response. I am sending a frame of bytes to RX and send them back to TX. Delay between end of RX transmission end start of TX is 150 ms. I need to shorten it to 40 ms.
What am I doing wrong?
Code: Select all
#define ECHO_TEST_TXD (GPIO_NUM_4)
#define ECHO_TEST_RXD (GPIO_NUM_5)
#define ECHO_TEST_RTS (UART_PIN_NO_CHANGE)
#define ECHO_TEST_CTS (UART_PIN_NO_CHANGE)
#define BUF_SIZE (128)
static void echo_task()
{
uint8_t data[8];
while (1)
{
int len = uart_read_bytes(UART_NUM_2, data, 8, 1);
uart_write_bytes(UART_NUM_2, (const char *)data, len);
}
}
enum mgos_app_init_result mgos_app_init(void)
{
uart_config_t uart_config = {
.baud_rate = 450,
.data_bits = UART_DATA_8_BITS,
.parity = UART_PARITY_DISABLE,
.stop_bits = UART_STOP_BITS_1,
.flow_ctrl = UART_HW_FLOWCTRL_DISABLE};
uart_param_config(UART_NUM_2, &uart_config);
uart_set_pin(UART_NUM_2, ECHO_TEST_TXD, ECHO_TEST_RXD, ECHO_TEST_RTS, ECHO_TEST_CTS);
uart_driver_install(UART_NUM_2, BUF_SIZE * 2, 0, 0, NULL, 0);
xTaskCreate(echo_task, "uart_echo_task", 1024, NULL, 10, NULL);
return MGOS_APP_INIT_SUCCESS;
}