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.
|
|
#include "logger.h"
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
static UART_HandleTypeDef* m_huart; bool g_enable_log = true; /*********************************************************************
* @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 (m_huart != NULL) HAL_UART_Transmit(m_huart, &c, 1, 100); }
return size; }
void zlog_init(UART_HandleTypeDef* huart) { m_huart = huart; } void zlog_enable(bool enable) { g_enable_log = enable; } void zlog(const char* fmt, ...) { if (g_enable_log) { va_list args; va_start(args, fmt); vprintf(fmt, args); va_end(args); } }
void zlog_raw(const char* info) { if (g_enable_log) { printf(info); } }
|