实现大部分小板通信命令
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
|
||||
|
||||
#include "board.h"
|
||||
#include "if_rtt.h"
|
||||
#include "stdio.h"
|
||||
#include "stdarg.h"
|
||||
@@ -8,19 +8,44 @@
|
||||
#ifdef RT_THREAD
|
||||
#include "rtthread.h"
|
||||
#endif
|
||||
#define DBG_DEV rtt()
|
||||
|
||||
|
||||
#if 0
|
||||
|
||||
|
||||
#define DBG_DEV_INIT() rtt()->init()
|
||||
#define DBG_DEV_WRITE(d,len) rtt()->write(d,len)
|
||||
|
||||
#else
|
||||
|
||||
#define DBG_DEV_INIT()\
|
||||
{\
|
||||
g_data.uart=dev_get("uart1");\
|
||||
if(g_data.uart){\
|
||||
g_data.uart->init(g_data.uart,0);\
|
||||
}\
|
||||
}
|
||||
#define DBG_DEV_WRITE(d,len)\
|
||||
{\
|
||||
if(g_data.uart){\
|
||||
g_data.uart->write(g_data.uart,d,len);\
|
||||
}\
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#define CONSOLEBUF_SIZE 1024
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
typedef struct{
|
||||
int inited;
|
||||
#ifdef RT_THREAD
|
||||
struct rt_mutex mutex;
|
||||
#endif
|
||||
uart_def *uart;
|
||||
}self_def;
|
||||
|
||||
static self_def g_data;
|
||||
@@ -32,8 +57,8 @@ int debug_init(void)
|
||||
#ifdef RT_THREAD
|
||||
rt_mutex_init(&g_data.mutex,"debug_mutex",RT_IPC_FLAG_FIFO);
|
||||
#endif
|
||||
DBG_DEV->init();
|
||||
DBG_DEV->write((const uint8_t *)"\r\n",2);
|
||||
DBG_DEV_INIT();
|
||||
DBG_DEV_WRITE((const uint8_t *)"\r\n",2);
|
||||
g_data.inited=1;
|
||||
DBG_LOG("debug inited.\r\n");
|
||||
}
|
||||
@@ -64,7 +89,7 @@ void debug_log(const char *file,const char *fun,int line,int level,const char *f
|
||||
va_end(args);
|
||||
memcpy(&log_buf[length],"\r\n",2);
|
||||
length+=2;
|
||||
DBG_DEV->write((const uint8_t *)log_buf,length);
|
||||
DBG_DEV_WRITE((const uint8_t *)log_buf,length);
|
||||
#ifdef RT_THREAD
|
||||
rt_mutex_release(&g_data.mutex);
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user