mirror of
https://gitee.com/dlmu-cone/bf_original_balance_chassis
synced 2026-07-24 03:27:45 +08:00
add log.c
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
#include "memory.h"
|
||||
|
||||
/* can instance ptrs storage, used for recv callback */
|
||||
static can_instance *instance[MX_REGISTER_DEVICE_CNT]={NULL};
|
||||
static can_instance *instance[MX_REGISTER_DEVICE_CNT] = {NULL};
|
||||
|
||||
/* ----------------two static function called by CANRegister()-------------------- */
|
||||
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
#include "bsp_log.h"
|
||||
|
||||
#include "SEGGER_RTT.h"
|
||||
#include "SEGGER_RTT_Conf.h"
|
||||
#include <stdio.h>
|
||||
|
||||
#define BUFFER_INDEX 0
|
||||
|
||||
void BSP_Log_Init() { SEGGER_RTT_Init(); }
|
||||
|
||||
int printf_log(const char *fmt, ...)
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
int n = SEGGER_RTT_vprintf(BUFFER_INDEX, fmt, &args);
|
||||
va_end(args);
|
||||
return n;
|
||||
}
|
||||
|
||||
void Float2Str(char *str, float va)
|
||||
{
|
||||
int flag = va < 0;
|
||||
int head = (int)va;
|
||||
int point = (int)((va - head) * 1000);
|
||||
head = abs(head);
|
||||
point = abs(point);
|
||||
if (flag)
|
||||
sprintf(str, "-%d.%d", head, point);
|
||||
else
|
||||
sprintf(str, "%d.%d", head, point);
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
#ifndef _BSP_LOG_H
|
||||
#define _BSP_LOG_H
|
||||
|
||||
void BSP_Log_Init();
|
||||
int printf_log(const char *fmt, ...);
|
||||
void Float2Str(char *str, float va);
|
||||
|
||||
#endif
|
||||
5
bsp/bsp_log.md
Normal file
5
bsp/bsp_log.md
Normal file
@@ -0,0 +1,5 @@
|
||||
# bsp_log
|
||||
|
||||
<p align='right'>neozng1@hnu.edu.cn</p>
|
||||
|
||||
## 使用说明
|
||||
@@ -13,7 +13,7 @@
|
||||
|
||||
/* usart service instance, modules' info would be recoreded here using USARTRegister() */
|
||||
/* usart服务实例,所有注册了usart的模块信息会被保存在这里 */
|
||||
static usart_instance *instance[DEVICE_USART_CNT]={NULL};
|
||||
static usart_instance *instance[DEVICE_USART_CNT] = {NULL};
|
||||
|
||||
/**
|
||||
* @brief usart service will start automatically, after each module registered
|
||||
|
||||
Reference in New Issue
Block a user