]> rtime.felk.cvut.cz Git - lincan.git/blob - embedded/libs4c/usb/base/usb/usbdebug.h
Merge branch 'master' into can-usb1
[lincan.git] / embedded / libs4c / usb / base / usb / usbdebug.h
1 /* Global debug macros, variables, functions - header file */
2 /* R.B. - 23.4.2003 */
3
4 #ifndef _USB_DEBUG_H_
5 #define _USB_DEBUG_H_
6
7 #if 1
8   #include <stdio.h>
9   #define usb_printf printf
10 #else
11   int simple_printf(const char *f, ...);
12   #define usb_printf simple_printf
13 #endif
14
15 /* Debug levels */
16 #define DEBUG_LEVEL_NONE    0
17 #define DEBUG_LEVEL_LOW     1
18 #define DEBUG_LEVEL_MEDIUM  2
19 #define DEBUG_LEVEL_HIGH    3
20 #define DEBUG_LEVEL_VERBOSE 4
21
22 #ifndef DEBUG_STATIC_LEVEL
23 /* Global static debug level */
24 #define DEBUG_STATIC_LEVEL     DEBUG_LEVEL_NONE
25 #endif
26
27 /* If it is defined, current global debug level is
28    in 'global_debug_level' variable. Otherwise will
29    be used 'DEBUG_STATIC_LEVEL' as current global
30    debug level
31 */
32 /*#define DEBUG_USE_DYNAMIC_LEVEL*/
33
34 /* #define DEBUG */
35
36 /*****************************************************************************/
37 /*****************************************************************************/
38 /*****************************************************************************/
39
40 #ifdef DEBUG
41
42 /* use static or dynamic global debug level */
43 #if defined(DEBUG_USE_DYNAMIC_LEVEL) /* use dynamic debug level */
44   extern unsigned char usb_debug_level;
45 #else /* use only static debug level */
46   #define usb_debug_level DEBUG_STATIC_LEVEL
47 #endif
48
49
50 /* usb_debug_print( level, printargs) print debug info in printargs if
51    level is lower or equal to 'global_debug_level'/'DEBUG_STATIC_LEVEL'.
52    'printargs' is with parenthesis.
53    usage : usb_debug_print( DEBUG_LEVEL_MEDIUM,("i=%d",i));
54 */
55 #define usb_debug_print( _lvl_, _prnargs_)      \
56   do {                                          \
57     if ( usb_debug_level >= _lvl_) {            \
58       usb_printf _prnargs_;                     \
59     }                                           \
60   } while(0)
61
62 /* usb_debug_info( printargs) print debug info always
63    usage : usb_debug_info( "debug info");
64 */
65 #define usb_debug_info usb_printf  /* FIXME: this is not correct */
66
67 #else /* DEBUG */
68   #define usb_debug_print( _lvl_, _prnargs_)
69   #define usb_debug_info(...) 
70 #endif /* DEBUG */
71
72
73   void usb_debug_set_level(int level);
74
75   char *usb_debug_get_req_recipient( char rqt);
76   char *usb_debug_get_req_type( char rqt);
77   char *usb_debug_get_std_request( char req);
78   char *usb_debug_get_std_descriptor( unsigned char desc);
79
80   
81 #endif /* _GLOBAL_DEBUG_H_ */