Skip to content

Commit

Permalink
Added debug level option
Browse files Browse the repository at this point in the history
  • Loading branch information
Heltec-Aaron-Lee committed Feb 11, 2020
1 parent 024c402 commit 2d4e2d8
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 69 deletions.
2 changes: 1 addition & 1 deletion cores/asr650x/board/board.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ void BoardEnableIrq( void );
/*!
* \brief Initializes the mcu.
*/
void BoardInitMcu( void );
void boardInitMcu( void );

/*!
* \brief Resets the mcu.
Expand Down
91 changes: 24 additions & 67 deletions cores/asr650x/board/inc/debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,9 @@
#ifndef __DEBUG_H__
#define __DEBUG_H__

#ifdef __cplusplus
extern "C" {
#endif

/* Includes ------------------------------------------------------------------*/
#include <string.h>
#include <stdio.h>
#include "hw_conf.h"
#include "timeServer.h"
//#include <stdio.h>
#include "utilities.h"

/* Exported types ------------------------------------------------------------*/
Expand All @@ -72,73 +66,36 @@ typedef enum LOG_LEVEL_E {
LL_ALL
} LOG_LEVEL;

#ifdef CONFIG_DEBUG_LINKWAN
extern LOG_LEVEL g_log_level;
#define ERR_PRINTF(format, ...) do { \
if(g_log_level>=LL_ERR) { \
TimerTime_t ts = TimerGetCurrentTime(); \
printf("[%llu]", ts); \
printf(format, ##__VA_ARGS__); \
} \
}while(0)

#define WARN_PRINTF(format, ...) do { \
if(g_log_level>=LL_WARN) { \
TimerTime_t ts = TimerGetCurrentTime(); \
printf("[%llu]", ts); \
printf(format, ##__VA_ARGS__); \
} \
}while(0)

#define DBG_PRINTF(format, ...) do { \
if(g_log_level>=LL_DEBUG) { \
TimerTime_t ts = TimerGetCurrentTime(); \
printf("[%llu]", ts); \
printf(format, ##__VA_ARGS__); \
} \
}while(0)

#define VDBG_PRINTF(format, ...) do { \
if(g_log_level>=LL_VDEBUG) { \
TimerTime_t ts = TimerGetCurrentTime(); \
printf("[%llu]", ts); \
printf(format, ##__VA_ARGS__); \
} \
}while(0)

#define PRINTF_RAW(...) do { \
if(g_log_level>=LL_DEBUG) printf(__VA_ARGS__); \
}while(0)

#define PRINTF_AT(...) printf(__VA_ARGS__)

#define DBG_PRINTF_CRITICAL(p)
#else
#define ERR_PRINTF(format, ...) do {}while(0)
#define WARN_PRINTF(format, ...) do {}while(0)
#define DBG_PRINTF(format, ...) do {}while(0)
#define VDBG_PRINTF(format, ...) do {}while(0)
#define PRINTF_RAW(...)
#define PRINTF_AT(...) printf(__VA_ARGS__)
#define DBG_PRINTF_CRITICAL(p)
#endif

#ifdef __cplusplus
extern "C" {
#endif

/* Exported functions ------------------------------------------------------- */

/**
* @brief Initializes the debug
* @param None
* @retval None
*/
void DBG_Init(void);
int DBG_LogLevelGet();
void DBG_LogLevelSet(int level);

#ifdef __cplusplus
}
#endif


#define ERR_PRINTF(format, ...) do {}while(0)
#define WARN_PRINTF(format, ...) do {}while(0)
#define VDBG_PRINTF(format, ...) do {}while(0)
#define PRINTF_RAW(...)
#define PRINTF_AT(...)
#define DBG_PRINTF_CRITICAL(p)
#define DBG_PRINTF(format, ...) do {}while(0)

#if LoRaWAN_DEBUG_LEVEL >= 2
#define FREQ_PRINTF(format, ...) printf(format, ##__VA_ARGS__)
#define DIO_PRINTF(format, ...) printf(format, ##__VA_ARGS__)
#elif LoRaWAN_DEBUG_LEVEL == 1
#define FREQ_PRINTF(format, ...) printf(format, ##__VA_ARGS__)
#define DIO_PRINTF(format, ...)
#else
#define FREQ_PRINTF(format, ...) do {}while(0)
#define DIO_PRINTF(format, ...) do {}while(0)
#endif

#endif /* __DEBUG_H__*/

/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
2 changes: 1 addition & 1 deletion tools/platform.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ compiler.warning_flags.all=-Wall -Wextra
compiler.path={runtime.platform.path}/tools/gcc-arm-none-eabi/bin/

compiler.sdk.path={runtime.platform.path}/cores/asr650x
compiler.cpreprocessor.flags=-D{build.band} -DARDUINO={runtime.ide.version} -DACTIVE_REGION=LORAMAC_{build.band} -DLORAWAN_CLASS={build.LORAWAN_CLASS} -DLORAWAN_NETMODE={build.LORAWAN_NETMODE} -DLORAWAN_ADR={build.LORAWAN_ADR} -DLORAWAN_UPLINKMODE={build.LORAWAN_UPLINKMODE} -DLORAWAN_Net_Reserve={build.LORAWAN_Net_Reserve} -DAT_SUPPORT={build.LORAWAN_AT_SUPPORT} -DLoraWan_RGB={build.RGB} -DCY_CORE_ID=0 -DCONFIG_LORA_USE_TCXO -DCONFIG_MANUFACTURER="ASR" -DCONFIG_DEVICE_MODEL="6501" -DCONFIG_VERSION="v4.0" -D__ASR6501__ "-I{compiler.sdk.path}/board/" "-I{compiler.sdk.path}/board/src/" "-I{compiler.sdk.path}/board/inc/" "-I{compiler.sdk.path}/device/asr6501_lrwan/" "-I{compiler.sdk.path}/device/sx126x/" "-I{compiler.sdk.path}/kernel/protocols/lorawan/lora/mac/" "-I{compiler.sdk.path}/kernel/protocols/lorawan/lora/mac/region/" "-I{compiler.sdk.path}/kernel/protocols/lorawan/lora/system/" "-I{compiler.sdk.path}/kernel/protocols/lorawan/lora/system/crypto/" "-I{compiler.sdk.path}/port/" "-I{compiler.sdk.path}/port/include/" "-I{compiler.sdk.path}/projects/" "-I{compiler.sdk.path}/projects/PSoC4/" "-I{compiler.sdk.path}/cores/" "-I{compiler.sdk.path}/Serial/" "-I{compiler.sdk.path}/Wire/" "-I{compiler.sdk.path}/SPI/"
compiler.cpreprocessor.flags=-D{build.band} -DARDUINO={runtime.ide.version} -DACTIVE_REGION=LORAMAC_{build.band} -DLORAWAN_CLASS={build.LORAWAN_CLASS} -DLORAWAN_NETMODE={build.LORAWAN_NETMODE} -DLORAWAN_ADR={build.LORAWAN_ADR} -DLORAWAN_UPLINKMODE={build.LORAWAN_UPLINKMODE} -DLORAWAN_NET_RESERVE={build.LORAWAN_Net_Reserve} -DAT_SUPPORT={build.LORAWAN_AT_SUPPORT} -DLoraWan_RGB={build.RGB} -DLoRaWAN_DEBUG_LEVEL={build.LORAWAN_DebugLevel} -DCY_CORE_ID=0 -DCONFIG_LORA_USE_TCXO -DCONFIG_MANUFACTURER="ASR" -DCONFIG_DEVICE_MODEL="6501" -DCONFIG_VERSION="v4.0" -D__ASR6501__ "-I{compiler.sdk.path}/board/" "-I{compiler.sdk.path}/board/src/" "-I{compiler.sdk.path}/board/inc/" "-I{compiler.sdk.path}/device/asr6501_lrwan/" "-I{compiler.sdk.path}/device/sx126x/" "-I{compiler.sdk.path}/loramac/mac/" "-I{compiler.sdk.path}/loramac/mac/region/" "-I{compiler.sdk.path}/loramac/system/" "-I{compiler.sdk.path}/loramac/system/crypto/" "-I{compiler.sdk.path}/port/" "-I{compiler.sdk.path}/port/include/" "-I{compiler.sdk.path}/projects/" "-I{compiler.sdk.path}/projects/PSoC4/" "-I{compiler.sdk.path}/cores/" "-I{compiler.sdk.path}/Serial/" "-I{compiler.sdk.path}/Wire/" "-I{compiler.sdk.path}/SPI/"

compiler.c.cmd=arm-none-eabi-gcc
compiler.c.flags=-mcpu=cortex-m0plus -mthumb -g -gdwarf-2 -MMD -w -Os -mapcs-frame -mthumb-interwork -Wall -ffunction-sections -ffat-lto-objects -Os -fno-common -fno-builtin-printf -fno-builtin-fflush -fno-builtin-sprintf -fno-builtin-snprintf -Wno-strict-aliasing -c
Expand Down

2 comments on commit 2d4e2d8

@Bwooce
Copy link
Contributor

@Bwooce Bwooce commented on 2d4e2d8 Feb 14, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work, thanks. The debug goes out the SWD port (which I've never connected) or the UART?

@Heltec-Aaron-Lee
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @Bwooce, via UART.

Please sign in to comment.