many changes
This commit is contained in:
52
Debug.h
52
Debug.h
@@ -2,7 +2,9 @@
|
||||
#define DEBUG_H
|
||||
|
||||
#include <cstdint>
|
||||
#include "Platforms.h"
|
||||
|
||||
/*
|
||||
extern "C" {
|
||||
#include "ets_sys.h"
|
||||
#include "c_types.h"
|
||||
@@ -21,26 +23,11 @@ extern "C" {
|
||||
|
||||
#include "driver/uart.h"
|
||||
}
|
||||
|
||||
void hexdump(const uint8_t* buf, uint8_t len) {
|
||||
for (int i = 0; i < len; ++i) {
|
||||
os_printf("%02x ", buf[i]);
|
||||
}
|
||||
os_printf("\n");
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
|
||||
#define debug(str) os_printf(str)
|
||||
#define debugMod(module, str) os_printf("[%s] %s\n", module, str)
|
||||
#define debugMod1(module, str, val) os_printf("[%s] ", module); os_printf(str, val); os_printf("\n");
|
||||
#define debugMod2(module, str, v1, v2) os_printf("[%s] ", module); os_printf(str, v1, v2); os_printf("\n");
|
||||
#define debugMod3(module, str, v1, v2, v3) os_printf("[%s] ", module); os_printf(str, v1, v2, v3); os_printf("\n");
|
||||
#define IF_DEBUG(a) a
|
||||
#define debugShow(buf, len) hexdump(buf,len)
|
||||
*/
|
||||
|
||||
|
||||
#else
|
||||
|
||||
#if (!defined(DEBUG))
|
||||
|
||||
#define debug(str)
|
||||
#define debugMod(module, str)
|
||||
@@ -50,6 +37,35 @@ void hexdump(const uint8_t* buf, uint8_t len) {
|
||||
#define IF_DEBUG(a)
|
||||
#define debugShow(a, b)
|
||||
|
||||
#elif (PLATFORM == WEMOS_D1_MINI) || (PLATFORM == NODE_MCU)
|
||||
|
||||
#define debug(str) os_printf(str)
|
||||
#define debugMod(module, str) os_printf("[%s] %s\n", module, str)
|
||||
#define debugMod1(module, str, val) os_printf("[%s] ", module); os_printf(str, val); os_printf("\n");
|
||||
#define debugMod2(module, str, v1, v2) os_printf("[%s] ", module); os_printf(str, v1, v2); os_printf("\n");
|
||||
#define debugMod3(module, str, v1, v2, v3) os_printf("[%s] ", module); os_printf(str, v1, v2, v3); os_printf("\n");
|
||||
#define IF_DEBUG(a) a
|
||||
#define debugShow(buf, len) hexdump(buf,len)
|
||||
|
||||
void hexdump(const uint8_t* buf, uint8_t len) {
|
||||
for (int i = 0; i < len; ++i) {
|
||||
os_printf("%02x ", buf[i]);
|
||||
}
|
||||
os_printf("\n");
|
||||
}
|
||||
|
||||
#elif (PLATFORM == WROOM32_DEVKIT)
|
||||
|
||||
#define debug(str) ESP_LOGI("", str);
|
||||
#define debugMod(module, str) ESP_LOGI(module, str);
|
||||
#define debugMod1(module, str, val) ESP_LOGI(module, str, val);
|
||||
#define debugMod2(module, str, v1, v2) ESP_LOGI(module, str, v1, v2);
|
||||
#define debugMod3(module, str, v1, v2, v3) ESP_LOGI(module, str, v1, v2, v3);
|
||||
#define IF_DEBUG(a) a
|
||||
#define debugShow(buf, len) hexdump(buf,len)
|
||||
|
||||
#else
|
||||
#error "unsupported platform"
|
||||
#endif
|
||||
|
||||
#endif // DEBUG_H
|
||||
|
||||
Reference in New Issue
Block a user