1 #include <stdbool.h> 2 3 #ifndef NDEBUG 4 #define ITMSTDERR (0) 5 #define ITMSIGNAL (1) 6 #define ITMCMDRSP (2) 7 #define ITMCHANNELS (3) 8 #define dbgPrint(fmt, ...) fprintf(stderr, "%s: " fmt, GetLogStamp(), ##__VA_ARGS__); 9 #define dbgPrintAppend(fmt, ...) fprintf(stderr, fmt, ##__VA_ARGS__); 10 #define itmPrint(__channel, fmt, ...) fprintf(g_itm[__channel], "%s: " fmt, GetLogStamp(), ##__VA_ARGS__); 11 #define itmPrintAppend(__channel, fmt, ...) fprintf(g_itm[__channel], fmt, ##__VA_ARGS__); 12 #else 13 #define dbgPrint(fmt, ...) ((void)0) 14 #define dbgPrintAppend(fmt, ...) ((void)0) 15 #endif 16 #define logError(fmt, ...) dbgPrint("[ERROR] %s (%s@%u) - " fmt, __func__, __FILE__, __LINE__, ##__VA_ARGS__); 17 #define logWarning(fmt, ...) dbgPrint("[WARNING] %s (%s@%u) - " fmt, __func__, __FILE__, __LINE__, ##__VA_ARGS__); 18 #define logInfo(fmt, ...) dbgPrint("[Info] %s (%s@%u) - " fmt, __func__, __FILE__, __LINE__, ##__VA_ARGS__); 19 extern char logStampStr[40]; 20 extern void* g_itm[ITMCHANNELS]; 21 22 #define ITMFILENO (4) 23 #define ITMCHANNELNO (32) 24 void ITM_Out(uint32_t port, uint8_t ch); 25 26 char* GetLogStamp(void); 27 int BlueButtonTransitionDetected(void); 28 void SetDutyCycleIndicator(bool on); 29 void KillUSBLink(void); 30 void SetRealTimeClock(time_t tm); 31 void ReadMcuInfo(unsigned char* serial, uint16_t *flashSize, uint16_t *mcuType, uint16_t *mcuRev); 32 void PerformSystemReset(void); 33 void InitializeITM(); 34