Use UART for all other chips too

This commit is contained in:
okhsunrog 2024-09-23 04:00:46 +03:00
parent 7a9d6c82fa
commit 26b482f57c

View file

@ -23,11 +23,11 @@
#include "xvprintf.h" #include "xvprintf.h"
#if CONFIG_IDF_TARGET_ESP32C3 #if CONFIG_IDF_TARGET_ESP32C3
#include <driver/usb_serial_jtag_vfs.h> #include <driver/usb_serial_jtag_vfs.h>
#include "driver/usb_serial_jtag.h" #include "driver/usb_serial_jtag.h"
#else #else
#include <driver/uart_vfs.h> #include <driver/uart_vfs.h>
#include "driver/uart.h" #include "driver/uart.h"
#endif #endif
#if CONFIG_LOG_COLORS #if CONFIG_LOG_COLORS
@ -105,11 +105,11 @@ void console_task_tx(void* arg) {
linenoiseHide(&ls); linenoiseHide(&ls);
if (msg_to_print != NULL) { if (msg_to_print != NULL) {
// if zero-length string - just refresh prompt. used for updating prompt // if zero-length string - just refresh prompt. used for updating prompt
if(msg_to_print[0] != '\0') { if (msg_to_print[0] != '\0') {
write(fd, msg_to_print, msg_to_print_size); write(fd, msg_to_print, msg_to_print_size);
flushWrite(); flushWrite();
} }
vRingbufferReturnItem(uart_tx_ringbuf, (void *) msg_to_print); vRingbufferReturnItem(uart_tx_ringbuf, (void*) msg_to_print);
} }
linenoiseShow(&ls); linenoiseShow(&ls);
xSemaphoreGive(stdout_taken_sem); xSemaphoreGive(stdout_taken_sem);
@ -120,7 +120,7 @@ void console_task_tx(void* arg) {
void console_task_interactive(void* arg) { void console_task_interactive(void* arg) {
console_taken_sem = xSemaphoreCreateMutex(); console_taken_sem = xSemaphoreCreateMutex();
stdout_taken_sem = xSemaphoreCreateMutex(); stdout_taken_sem = xSemaphoreCreateMutex();
char *buf = calloc(1, console_config.max_cmdline_length); char* buf = calloc(1, console_config.max_cmdline_length);
/* Figure out if the terminal supports escape sequences */ /* Figure out if the terminal supports escape sequences */
printf("Testing your console...\n"); printf("Testing your console...\n");
const int probe_status = linenoiseProbe(); const int probe_status = linenoiseProbe();
@ -190,7 +190,21 @@ void initialize_console(void) {
/* Disable buffering on stdin */ /* Disable buffering on stdin */
setvbuf(stdin, NULL, _IONBF, 0); setvbuf(stdin, NULL, _IONBF, 0);
#if CONFIG_IDF_TARGET_ESP32 #if CONFIG_IDF_TARGET_ESP32C3
/* Minicom, screen, idf_monitor send CR when ENTER key is pressed */
usb_serial_jtag_vfs_set_rx_line_endings(ESP_LINE_ENDINGS_CR);
/* Move the caret to the beginning of the next line on '\n' */
usb_serial_jtag_vfs_set_tx_line_endings(ESP_LINE_ENDINGS_CRLF);
usb_serial_jtag_driver_config_t usb_serial_jtag_config = USB_SERIAL_JTAG_DRIVER_CONFIG_DEFAULT();
/* Install USB-SERIAL-JTAG driver for interrupt-driven reads and writes */
ESP_ERROR_CHECK(usb_serial_jtag_driver_install(&usb_serial_jtag_config));
/* Asign vfs to JTAG */
usb_serial_jtag_vfs_use_driver();
#else
/* Set up UART for the console */ /* Set up UART for the console */
const uart_config_t uart_config = { const uart_config_t uart_config = {
.baud_rate = 115200, .baud_rate = 115200,
@ -205,23 +219,10 @@ void initialize_console(void) {
uart_param_config(UART_NUM_0, &uart_config); uart_param_config(UART_NUM_0, &uart_config);
/* Asign VFS to UART */ /* Asign VFS to UART */
//uart_vfs_dev_use_driver(UART_NUM_0); // uart_vfs_dev_use_driver(UART_NUM_0);
uart_vfs_dev_use_driver(UART_NUM_0); uart_vfs_dev_use_driver(UART_NUM_0);
#elif CONFIG_IDF_TARGET_ESP32C3
/* Minicom, screen, idf_monitor send CR when ENTER key is pressed */
usb_serial_jtag_vfs_set_rx_line_endings(ESP_LINE_ENDINGS_CR);
/* Move the caret to the beginning of the next line on '\n' */ #endif
usb_serial_jtag_vfs_set_tx_line_endings(ESP_LINE_ENDINGS_CRLF);
usb_serial_jtag_driver_config_t usb_serial_jtag_config = USB_SERIAL_JTAG_DRIVER_CONFIG_DEFAULT();
/* Install USB-SERIAL-JTAG driver for interrupt-driven reads and writes */
ESP_ERROR_CHECK(usb_serial_jtag_driver_install(&usb_serial_jtag_config));
/* Asign vfs to JTAG */
usb_serial_jtag_vfs_use_driver();
#endif
/* Enable non-blocking mode on stdin and stdout */ /* Enable non-blocking mode on stdin and stdout */
fcntl(fileno(stdout), F_SETFL, 0); fcntl(fileno(stdout), F_SETFL, 0);