diff --git a/Debug.cpp b/Debug.cpp index ef1a0af5..fb0d8086 100644 --- a/Debug.cpp +++ b/Debug.cpp @@ -1,11 +1,11 @@ #include "Sys.h" // 仅用于调试使用的一些函数实现,RTM不需要 -#define MEM_DEBUG 1 +#define MEM_DEBUG DEBUG #if MEM_DEBUG #define mem_printf debug_printf #else - __inline void mem_printf( const char *format, ... ) {} + #define mem_printf(format, ...) #endif extern uint __heap_base; diff --git a/Flash.cpp b/Flash.cpp index af1f1427..6879e579 100644 --- a/Flash.cpp +++ b/Flash.cpp @@ -1,7 +1,7 @@ #include "Flash.h" #include -#define FLASH_DEBUG 1 +#define FLASH_DEBUG DEBUG //static const uint STM32_FLASH_KEY1 = 0x45670123; //static const uint STM32_FLASH_KEY2 = 0xcdef89ab; diff --git a/Sys.cpp b/Sys.cpp index 8aa615cd..b187c3f0 100644 --- a/Sys.cpp +++ b/Sys.cpp @@ -270,10 +270,10 @@ typedef struct void TSys::ShowInfo() { +#if DEBUG // 刚刚初始化完成的时间 ulong initedTime = Time.Current(); -#if DEBUG byte* ver = (byte*)&Version; debug_printf("%s::%s Code:%04X ", Company, Name, Code); debug_printf("Ver:%x.%x Build:%s\r\n", *ver++, *ver++, BuildTime); diff --git a/Sys.h b/Sys.h index 3d279c7e..1ff7f772 100644 --- a/Sys.h +++ b/Sys.h @@ -17,7 +17,7 @@ extern "C" #else -__inline void debug_printf( const char *format, ... ) {} +#define debug_printf(format, ...) #endif } diff --git a/TinyNet/TinyMessage.cpp b/TinyNet/TinyMessage.cpp index 95c4b56d..6bbc600f 100644 --- a/TinyNet/TinyMessage.cpp +++ b/TinyNet/TinyMessage.cpp @@ -7,7 +7,7 @@ #if MSG_DEBUG #define msg_printf debug_printf #else - __inline void msg_printf( const char *format, ... ) {} + #define msg_printf(format, ...) #endif void SendTask(void* param); @@ -585,6 +585,7 @@ void StatTask(void* param) // 显示统计信息 void TinyController::ShowStat() { +#if MSG_DEBUG static uint lastSend = 0; static uint lastReceive = 0; @@ -606,6 +607,7 @@ void TinyController::ShowStat() if(Last.Msg + Total.Msg > 0) retry = (Last.Send + tsend) * 100 / (Last.Msg + Total.Msg); msg_printf("Tiny::State 成功=%d%% 平均=%dus 速度=%d Byte/s 重发=%d.%02d 收发=%d/%d \r\n", rate, cost, speed, retry/100, retry%100, Last.Receive + Total.Receive, Last.Msg + Total.Msg); +#endif } void MessageNode::SetMessage(TinyMessage& msg)