fix(uart,usj...): Fix wrong serial number that has been parsed to rom functions,

Closes https://github.com/espressif/esp-idf/issues/12958
This commit is contained in:
Cao Sen Miao
2024-01-17 17:19:49 +08:00
parent e6b18a13cd
commit 6768805d20
76 changed files with 285 additions and 119 deletions

View File

@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2016-2021 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2016-2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@@ -16,17 +16,17 @@ static uint32_t s_test_start, s_test_stop;
void unity_putc(int c)
{
if (c == '\n') {
esp_rom_uart_tx_one_char('\r');
esp_rom_uart_tx_one_char('\n');
esp_rom_output_tx_one_char('\r');
esp_rom_output_tx_one_char('\n');
} else if (c == '\r') {
} else {
esp_rom_uart_tx_one_char(c);
esp_rom_output_tx_one_char(c);
}
}
void unity_flush(void)
{
esp_rom_uart_tx_wait_idle(CONFIG_ESP_CONSOLE_UART_NUM);
esp_rom_output_tx_wait_idle(CONFIG_ESP_CONSOLE_ROM_SERIAL_PORT_NUM);
}
#define iscontrol(c) ((c) <= '\x1f' || (c) == '\x7f')
@@ -37,7 +37,7 @@ static void esp_unity_readline(char* dst, size_t len)
size_t write_index = 0;
for (;;) {
char c = 0;
bool got_char = esp_rom_uart_rx_one_char((uint8_t*)&c) == 0;
bool got_char = esp_rom_output_rx_one_char((uint8_t*)&c) == 0;
if (!got_char) {
continue;
}
@@ -50,9 +50,9 @@ static void esp_unity_readline(char* dst, size_t len)
if (write_index > 0) {
/* Delete previously entered character */
write_index--;
esp_rom_uart_tx_one_char('\b');
esp_rom_uart_tx_one_char(' ');
esp_rom_uart_tx_one_char('\b');
esp_rom_output_tx_one_char('\b');
esp_rom_output_tx_one_char(' ');
esp_rom_output_tx_one_char('\b');
}
} else if (len > 0 && write_index < len - 1 && !iscontrol(c)) {
/* Write a max of len - 1 characters to allow for null terminator */
@@ -83,7 +83,7 @@ void unity_gets(char *dst, size_t len)
}
/* Flush anything already in the RX buffer */
uint8_t ignore;
while (esp_rom_uart_rx_one_char(&ignore) == 0) { }
while (esp_rom_output_rx_one_char(&ignore) == 0) { }
/* Read input */
esp_unity_readline(dst, len);
}