You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

45 lines
949 B

#include "zlog.h"
#include "project_configs.h"
#include "zbase.h"
bool g_xs_enable_log = true;
UART_HandleTypeDef* debuguart;
/*********************************************************************
* @fn _write
*
* @brief Support Printf Function
*
* @param *buf - UART send Data.
* size - Data length
*
* @return size: Data length
*/
__attribute__((used)) int _write(int fd, char* buf, int size) {
int i;
for (i = 0; i < size; i++) {
uint8_t c = *buf++;
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) {
va_list args;
va_start(args, fmt);
vprintf(fmt, args);
va_end(args);
}
}
void zlog_raw(const char* info) {
if (g_xs_enable_log) {
printf(info);
}
}