From 0a0eb7a4f6ec39c162ef91f59fc37c01dc2b22f1 Mon Sep 17 00:00:00 2001 From: eightycc Date: Thu, 13 Feb 2025 06:52:12 -0800 Subject: [PATCH] Restore console_uart_printf, fix use of __ZEPHYR__. --- supervisor/shared/serial.c | 12 ++++++++++++ supervisor/shared/serial.h | 2 ++ supervisor/shared/usb/tusb_config.h | 2 +- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/supervisor/shared/serial.c b/supervisor/shared/serial.c index 3873b1b6ba49d..bc57500ed7c3e 100644 --- a/supervisor/shared/serial.c +++ b/supervisor/shared/serial.c @@ -524,3 +524,15 @@ void print_hexdump(const mp_print_t *printer, const char *prefix, const uint8_t mp_printf(printer, "\n"); } } + +int console_uart_printf(const char *fmt, ...) { + #if CIRCUITPY_CONSOLE_UART + va_list args; + va_start(args, fmt); + int ret = mp_vprintf(&console_uart_print, fmt, args); + va_end(args); + return ret; + #else + return 0; + #endif +} diff --git a/supervisor/shared/serial.h b/supervisor/shared/serial.h index 982f4fb3d7bfb..d64a316ff3271 100644 --- a/supervisor/shared/serial.h +++ b/supervisor/shared/serial.h @@ -50,4 +50,6 @@ void board_serial_write_substring(const char *text, uint32_t length); extern const mp_print_t console_uart_print; +int console_uart_printf(const char *fmt, ...); + void print_hexdump(const mp_print_t *printer, const char *prefix, const uint8_t *buf, size_t len); diff --git a/supervisor/shared/usb/tusb_config.h b/supervisor/shared/usb/tusb_config.h index fea0777d13709..1cae0b504fe1b 100644 --- a/supervisor/shared/usb/tusb_config.h +++ b/supervisor/shared/usb/tusb_config.h @@ -55,7 +55,7 @@ extern "C" { // When debugging TinyUSB, only output to the console UART link. #if CIRCUITPY_DEBUG_TINYUSB > 0 && defined(CIRCUITPY_CONSOLE_UART) #define CFG_TUSB_DEBUG CIRCUITPY_DEBUG_TINYUSB -#if __ZEPHYR__ +#ifdef __ZEPHYR__ #define CFG_TUSB_DEBUG_PRINTF zephyr_printk #else #define CFG_TUSB_DEBUG_PRINTF console_uart_printf