console: allow use apb clock for uart to achieve high baud rate

Console sets UART clock source to REF_TICK on ESP32 and ESP32S2 by
default, however, APB clock frequency does not change when power
management is disabled. Using APB clock source allows higher baud rates
for UART console.

Closes https://github.com/espressif/esp-idf/pull/8572
This commit is contained in:
Vladimir Chistyakov 2022-03-15 17:38:29 +07:00 committed by morris
parent c49e99f9e7
commit 7a4cacfcd0

View File

@ -225,16 +225,24 @@ esp_err_t esp_console_new_repl_uart(const esp_console_dev_uart_config_t *dev_con
/* Configure UART. Note that REF_TICK/XTAL is used so that the baud rate remains
* correct while APB frequency is changing in light sleep mode.
*/
#if SOC_UART_SUPPORT_REF_TICK
uart_sclk_t clk_source = UART_SCLK_REF_TICK;
// REF_TICK clock can't provide a high baudrate
if (dev_config->baud_rate > 1 * 1000 * 1000) {
clk_source = UART_SCLK_DEFAULT;
ESP_LOGW(TAG, "light sleep UART wakeup might not work at the configured baud rate");
}
#elif SOC_UART_SUPPORT_XTAL_CLK
uart_sclk_t clk_source = UART_SCLK_XTAL;
#else
#error "No UART clock source is aware of DFS"
#endif // SOC_UART_SUPPORT_xxx
const uart_config_t uart_config = {
.baud_rate = dev_config->baud_rate,
.data_bits = UART_DATA_8_BITS,
.parity = UART_PARITY_DISABLE,
.stop_bits = UART_STOP_BITS_1,
#if CONFIG_IDF_TARGET_ESP32 || CONFIG_IDF_TARGET_ESP32S2
.source_clk = UART_SCLK_REF_TICK,
#else
.source_clk = UART_SCLK_XTAL,
#endif
.source_clk = clk_source,
};
uart_param_config(dev_config->channel, &uart_config);
@ -484,9 +492,9 @@ static void esp_console_repl_task(void *args)
/* This message shall be printed here and not earlier as the stdout
* has just been set above. */
printf("\r\n"
"Type 'help' to get the list of commands.\r\n"
"Use UP/DOWN arrows to navigate through command history.\r\n"
"Press TAB when typing command name to auto-complete.\r\n");
"Type 'help' to get the list of commands.\r\n"
"Use UP/DOWN arrows to navigate through command history.\r\n"
"Press TAB when typing command name to auto-complete.\r\n");
if (linenoiseIsDumbMode()) {
printf("\r\n"