Code: Select all
uart_config_t uart_config = {
.baud_rate = 250000,
.data_bits = UART_DATA_8_BITS,
.parity = UART_PARITY_DISABLE,
.stop_bits = UART_STOP_BITS_2,
.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, 2048, 0, 0, NULL, 0); // Expecting blocking TX calls as TX buffer is set to 0
uint8_t buffer[] = { 0xAA, 0xBB, 0xCC, 0xDD, 0xEE}; // First byte will be sent using lower baudrate
while(1) {
// The slow part
uart_set_baudrate(UART_NUM_2, 50000));
uart_write_bytes(UART_NUM_2, (const char *) buffer, 1);
// uart_wait_tx_done(UART_NUM_2, 1000 / portTICK_PERIOD_MS); <- also tried with this one, though with 0 TX buffer it seems to be pointless
// The fast part
uart_set_baudrate(UART_NUM_2, 200000));
uart_write_bytes(UART_NUM_2, (const char *) buffer, 5);
}