sentry_gimbal_hzz/bsp/log/bsp_log.h

62 lines
1.6 KiB
C
Raw Normal View History

2022-11-11 21:20:58 +08:00
#ifndef _BSP_LOG_H
#define _BSP_LOG_H
2023-03-19 11:11:40 +08:00
#include "SEGGER_RTT.h"
#include "SEGGER_RTT_Conf.h"
#include <stdio.h>
#define BUFFER_INDEX 0
/**
* @brief
*
*/
void BSPLogInit();
2023-01-01 17:32:22 +08:00
/**
* @brief ,LOGI,LOGW,LOGE等使用
2023-01-01 17:32:22 +08:00
*
*/
#define LOG_PROTO(type,color,format,...) \
SEGGER_RTT_printf(BUFFER_INDEX," %s%s"format"\r\n%s", \
color, \
type, \
##__VA_ARGS__, \
RTT_CTRL_RESET)
2023-03-19 11:11:40 +08:00
/*------下面是日志输出的接口--------*/
/* 清屏 */
#define LOG_CLEAR() SEGGER_RTT_WriteString(0, " "RTT_CTRL_CLEAR)
/* 无颜色日志输出 */
#define LOG(format,...) LOG_PROTO("","",format,##__VA_ARGS__)
2023-03-19 11:11:40 +08:00
/* 有颜色格式日志输出,建议使用这些宏来输出日志 */
// information level
#define LOGINFO(format,...) LOG_PROTO("I:", RTT_CTRL_TEXT_BRIGHT_GREEN , format, ##__VA_ARGS__)
2023-03-19 11:11:40 +08:00
// warning level
#define LOGWARNING(format,...) LOG_PROTO("W:", RTT_CTRL_TEXT_BRIGHT_YELLOW, format, ##__VA_ARGS__)
2023-03-19 11:11:40 +08:00
// error level
#define LOGERROR(format,...) LOG_PROTO("E:", RTT_CTRL_TEXT_BRIGHT_RED , format, ##__VA_ARGS__)
2022-12-02 23:10:36 +08:00
2023-01-01 17:32:22 +08:00
/**
2023-03-19 11:11:40 +08:00
* @brief segger RTT打印日志,,printf.
2023-01-01 17:32:22 +08:00
*
* @param fmt
* @param ...
* @return int log字符数
2023-01-01 17:32:22 +08:00
*/
int PrintLog(const char *fmt, ...);
2022-12-02 23:10:36 +08:00
2023-01-01 17:32:22 +08:00
/**
* @brief sprintf(),float转换为字符串进行打印
*
* @param str
* @param va float
*/
2022-11-11 21:20:58 +08:00
void Float2Str(char *str, float va);
#endif