|
|
@ -1,9 +1,10 @@ |
|
|
|
#include "zlog.h" |
|
|
|
#include "zbase.h" |
|
|
|
|
|
|
|
#include "project_configs.h" |
|
|
|
#include "zbase.h" |
|
|
|
|
|
|
|
bool g_xs_enable_log = true; |
|
|
|
extern UART_HandleTypeDef DEBUG_UART; |
|
|
|
bool g_xs_enable_log = true; |
|
|
|
UART_HandleTypeDef* debuguart; |
|
|
|
/********************************************************************* |
|
|
|
* @fn _write |
|
|
|
* |
|
|
@ -19,12 +20,14 @@ __attribute__((used)) int _write(int fd, char* buf, int size) { |
|
|
|
|
|
|
|
for (i = 0; i < size; i++) { |
|
|
|
uint8_t c = *buf++; |
|
|
|
HAL_UART_Transmit(&DEBUG_UART, &c, 1, 100); |
|
|
|
if (debuguart) HAL_UART_Transmit(debuguart, &c, 1, 100); |
|
|
|
} |
|
|
|
|
|
|
|
return size; |
|
|
|
} |
|
|
|
|
|
|
|
void zlog_init(UART_HandleTypeDef* uart) { debuguart = uart; } |
|
|
|
|
|
|
|
void zlog_enable(bool enable) { g_xs_enable_log = enable; } |
|
|
|
void zlog(const char* fmt, ...) { |
|
|
|
if (g_xs_enable_log) { |
|
|
@ -35,7 +38,7 @@ void zlog(const char* fmt, ...) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
void zlog_raw(const char* info){ |
|
|
|
void zlog_raw(const char* info) { |
|
|
|
if (g_xs_enable_log) { |
|
|
|
printf(info); |
|
|
|
} |
|
|
|