From 39d411dc683f2f287f22d1e2a35dbf4a98da30d2 Mon Sep 17 00:00:00 2001 From: CTCaer Date: Thu, 20 Jan 2022 12:39:32 +0200 Subject: [PATCH] bdk: uart: add uart va print --- bdk/soc/uart.c | 19 +++++++++++++++++++ bdk/soc/uart.h | 3 +++ 2 files changed, 22 insertions(+) diff --git a/bdk/soc/uart.c b/bdk/soc/uart.c index 582bca1..00ee1ad 100644 --- a/bdk/soc/uart.c +++ b/bdk/soc/uart.c @@ -172,3 +172,22 @@ void uart_empty_fifo(u32 idx, u32 which) } } } + +#ifdef DEBUG_UART_PORT +#include +#include + +#include + +void uart_print(const char *fmt, ...) +{ + va_list ap; + char text[256]; + + va_start(ap, fmt); + s_vprintf(text, fmt, ap); + va_end(ap); + + uart_send(DEBUG_UART_PORT, (u8 *)text, strlen(text)); +} +#endif diff --git a/bdk/soc/uart.h b/bdk/soc/uart.h index 6a4c073..103db13 100644 --- a/bdk/soc/uart.h +++ b/bdk/soc/uart.h @@ -94,5 +94,8 @@ void uart_invert(u32 idx, bool enable, u32 invert_mask); u32 uart_get_IIR(u32 idx); void uart_set_IIR(u32 idx); void uart_empty_fifo(u32 idx, u32 which); +#ifdef DEBUG_UART_PORT +void uart_print(const char *fmt, ...); +#endif #endif