AvrIO  1.4.5
Bibliothèque C modulaire pour ATMEL AVR
debug.h
1 
21 #include <avrio/defs.h>
22 #include <avrio/led.h>
23 #include <stdio.h>
24 
25 __BEGIN_C_DECLS
26 /* ========================================================================== */
35 #if defined(__DOXYGEN__)
36  /*
37  * __DOXYGEN__ defined
38  * Partie documentation ne devant pas être compilée.
39  * =========================================================================
40  */
41 #define vDbgPutc(c)
42 #define vDbgNewLine()
43 #define vDbgPuts(s)
44 #define vDbgPuts_P(s)
45 #define vDbgPutHexByte(b)
46 #define vDbgPutHexWord(w)
47 #define vDbgPutHexDword(d)
48 #define vDbgPutHexBytes(d,l)
49 #define vDbgPutDec(w)
50 #define vDbgLedSet(m)
51 #define vDbgLedClear(m)
52 #define vDbgLedToggle(m)
53 #define dprintf(fmt, ...)
54 #define eprintf(fmt, ...)
55 
60 #else
61  /*
62  * __DOXYGEN__ not defined
63  * Partie ne devant pas être documentée.
64  * =========================================================================
65  */
66 
67 /* macros =================================================================== */
68 #ifdef DEBUG_USE_PROGMEM
69 #include <avr/pgmspace.h>
70 #define dprintf(fmt, ...) printf_P(PSTR(fmt), ##__VA_ARGS__)
71 #define eprintf(fmt, ...) fprintf_P(stderr, PSTR(fmt), ##__VA_ARGS__)
72 #else
73 #define dprintf(fmt,...) printf(fmt, ##__VA_ARGS__)
74 #define eprintf(fmt,...) fprintf(stderr, fmt, ##__VA_ARGS__)
75 #endif
76 
77 #ifndef AVRIO_DEBUG_STREAM
78 // -----------------------------------------------------------------------------
79 
80 #define vDbgPutc(c)
81 #define vDbgNewLine()
82 #define vDbgPuts(s)
83 #define vDbgPuts_P(s)
84 #define vDbgPutHexByte(b)
85 #define vDbgPutHexWord(w)
86 #define vDbgPutHexDword(d)
87 #define vDbgPutHexBytes(d,l)
88 #define vDbgPutDec(w)
89 
90 #else
91 // -----------------------------------------------------------------------------
92 #include <avrio/term.h>
93 
94 #define vDbgPutc(c) fputc(c, AVRIO_DEBUG_STREAM)
95 #define vDbgNewLine() vDbgPutc('\r')
96 #define vDbgPuts(s) fputs(s, AVRIO_DEBUG_STREAM)
97 #define vDbgPuts_P(s) fputs_P(s, AVRIO_DEBUG_STREAM)
98 #define vDbgPutHexByte(b) vTermPutHexByte(b, AVRIO_DEBUG_STREAM)
99 #define vDbgPutHexWord(w) vTermPutHexWord(w, AVRIO_DEBUG_STREAM)
100 #define vDbgPutHexDword(d) vTermPutHexDword(d, AVRIO_DEBUG_STREAM)
101 #define vDbgPutHexBytes(d,l) vTermPutHexBytes(d, l, AVRIO_DEBUG_STREAM)
102 #define vDbgPutDec(w) vTermPutDec(w, AVRIO_DEBUG_STREAM)
103 
104 // -----------------------------------------------------------------------------
105 #endif /* AVRIO_DEBUG_STREAM defined */
106 
107 #ifndef AVRIO_DEBUG_LED
108 // -----------------------------------------------------------------------------
109 
110 #define vDbgLedSet(m)
111 #define vDbgLedClear(m)
112 #define vDbgLedToggle(m)
113 
114 #else
115 // -----------------------------------------------------------------------------
116 
117 #define vDbgLedSet(m) vLedSet(m)
118 #define vDbgLedClear(m) vLedClear (m)
119 #define vDbgLedToggle(m) vLedToggle (m)
120 
121 // -----------------------------------------------------------------------------
122 #endif /* AVRIO_DEBUG_LED defined */
123 
124 #endif /* __DOXYGEN__ not defined */
125 
126 /* ========================================================================== */
127 __END_C_DECLS