initial commit
This commit is contained in:
46
project/ble_peripheral/ble_app_vivaMayo/debug_print.h
Normal file
46
project/ble_peripheral/ble_app_vivaMayo/debug_print.h
Normal file
@@ -0,0 +1,46 @@
|
||||
// file: debug_print.h
|
||||
#ifndef DEBUG_PRINT_H
|
||||
#define DEBUG_PRINT_H
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#include "nrf_delay.h"
|
||||
#include "SEGGER_RTT.h"
|
||||
|
||||
/* Output selection: 0=UART(printf), 1=RTT */
|
||||
#define USE_RTT_OUTPUT 1
|
||||
|
||||
#define ENABLE_PRINTF 1 // Set to 0 to disable globally (DBG_PRINTF off, LOG_PRINTF still works)
|
||||
#define LOG_FLUSH_MS 0 // UART flush delay (0 recommended due to blocking behavior)
|
||||
|
||||
#if USE_RTT_OUTPUT
|
||||
/* RTT output */
|
||||
#if ENABLE_PRINTF
|
||||
#define DBG_PRINTF(...) SEGGER_RTT_printf(0, __VA_ARGS__)
|
||||
#else
|
||||
#define DBG_PRINTF(...) // Do nothing
|
||||
#endif
|
||||
#define LOG_PRINTF(...) do { if (g_log_enable) SEGGER_RTT_printf(0, __VA_ARGS__); } while(0)
|
||||
#else
|
||||
/* UART output */
|
||||
#if ENABLE_PRINTF
|
||||
#define DBG_PRINTF(...) printf(__VA_ARGS__)
|
||||
#else
|
||||
#define DBG_PRINTF(...) // Do nothing
|
||||
#endif
|
||||
#if LOG_FLUSH_MS > 0
|
||||
#define LOG_PRINTF(...) do { \
|
||||
if (g_log_enable) { \
|
||||
printf(__VA_ARGS__); \
|
||||
nrf_delay_ms(LOG_FLUSH_MS); \
|
||||
} \
|
||||
} while(0)
|
||||
#else
|
||||
#define LOG_PRINTF(...) do { if (g_log_enable) printf(__VA_ARGS__); } while(0)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Log macro linked to g_log_enable flag (runtime controllable) */
|
||||
extern bool g_log_enable;
|
||||
|
||||
#endif // DEBUG_PRINT_H
|
||||
Reference in New Issue
Block a user