mirror of
https://gitee.com/dlmu-cone/bf_original_balance_chassis
synced 2026-07-24 19:47:44 +08:00
重构bsp层,bsp层将和HAL的配置一致,修改CubeMX之后不需要修改bsp。重构bmi088。
This commit is contained in:
34
bsp/log/bsp_log.c
Normal file
34
bsp/log/bsp_log.c
Normal file
@@ -0,0 +1,34 @@
|
||||
#include "bsp_log.h"
|
||||
|
||||
#include "SEGGER_RTT.h"
|
||||
#include "SEGGER_RTT_Conf.h"
|
||||
#include <stdio.h>
|
||||
|
||||
#define BUFFER_INDEX 0
|
||||
|
||||
void BSPLogInit()
|
||||
{
|
||||
SEGGER_RTT_Init();
|
||||
}
|
||||
|
||||
int PrintLog(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);
|
||||
}
|
||||
Reference in New Issue
Block a user