ODeV framework  v2
sysdebug.h
Go to the documentation of this file.
1 
32 #ifndef SYSDEBUG_H_
33 #define SYSDEBUG_H_
34 
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
38 
51 #define SYS_DBG_LEVEL_ALL 0x00
52 #define SYS_DBG_LEVEL_VERBOSE 0x01
53 #define SYS_DBG_LEVEL_LLA 0x02
54 #define SYS_DBG_LEVEL_SL 0x03
55 #define SYS_DBG_LEVEL_DEFAULT 0x04
56 #define SYS_DBG_LEVEL_WARNING 0x05
57 #define SYS_DBG_LEVEL_SEVERE 0x06
58 #define SYS_DBG_MASK_LEVEL 0x07
59 
60 #define SYS_DBG_ON 0x80U
61 #define SYS_DBG_OFF 0x00U
62 #define SYS_DBG_HALT 0x08U
63 
64 // Debug HArdware configuration
65 // ****************************
66 
67 // PINs used as Test Point
68 #define SYS_DBG_TP1_PORT GPIOH
69 #define SYS_DBG_TP1_PIN GPIO_PIN_1
70 #define SYS_DBG_TP2_PORT GPIOH
71 #define SYS_DBG_TP2_PIN GPIO_PIN_0
72 
73 
74 // UART for printf retargeting
75 #define UART_TX_PIN GPIO_PIN_2
76 #define UART_TX_GPIO_PORT GPIOA
77 #define UART_RX_PIN GPIO_PIN_3
78 #define UART_RX_GPIO_PORT GPIOA
79 
80 // Debug Configuration options.
81 // ****************************************************
82 #include <stdint.h>
83 #include "sysdebug_config.h"
84 
85 
86 /* Callback type used to call printf function */
87 typedef int (* DebugPrintfFn) (const char *format, ...);
88 extern DebugPrintfFn xSysDebugPrintfFn;
89 extern uint8_t g_sys_dbg_min_level;
90 
91 
92 #ifdef SYS_DEBUG
93 
94 typedef void (*xDebugLockUnlockFnType)(void);
95 extern xDebugLockUnlockFnType xSysDebugLockFn;
96 extern xDebugLockUnlockFnType xSysDebugUnlockFn;
97 
108 #define SYS_DBG_SET_LEVEL(control_byte, level) (((control_byte) & (~SYS_DBG_MASK_LEVEL)) | (level))
109 
115 #define _SYS_DEBUGF(debug, message) do { \
116  if ( \
117  ((debug) & SYS_DBG_ON) && \
118  ((int8_t)((debug) & SYS_DBG_MASK_LEVEL) >= g_sys_dbg_min_level)) { \
119  SYS_PLATFORM_DIAG(message); \
120  if ((debug) & SYS_DBG_HALT) { \
121  while(1); \
122  } \
123  } \
124 } while(0)
125 
126 #define SYS_PLATFORM_DIAG(_x_) do { xSysDebugLockFn();xSysDebugPrintfFn _x_;xSysDebugUnlockFn(); } while (0)
127 
128 //#define SYS_PLATFORM_ASSERT(x) do { assert(x); } while (0)
129 
137 #define SYS_DEBUGF3(module, level, message) _SYS_DEBUGF(SYS_DBG_SET_LEVEL(module, level), message)
138 
146 #define SYS_DEBUGF2(level, message) _SYS_DEBUGF(SYS_DBG_SET_LEVEL(SYS_DBG_APP, level), message)
147 
148 #else /* SYS_DEBUG */
149 #define SYS_DEBUGF3(debug, level, message)
150 #define SYS_DEBUGF2(level, message)
151 #endif /* SYS_DEBUG */
152 
159 
165 int SysDebugInit();
166 
172 
178 void SysDebugToggleLed(uint8_t nLed);
179 
185 void SysDebugLedOn(uint8_t nLed);
186 
192 void SysDebugLedOff(uint8_t nLed);
193 
194 int putChar( int ch );
195 
196 
197 
198 #ifdef __cplusplus
199 }
200 #endif
201 
202 
203 #endif /* SYSDEBUG_H_ */
int SysDebugHardwareInit()
Configure the debug log functionality.
void SysDebugLedOff(uint8_t nLed)
void SysDebugToggleLed(uint8_t nLed)
int SysDebugInit()
void SysDebugLedOn(uint8_t nLed)
void SysDebugStartRunTimeStatsTimer()