46#if CFG_TUSB_DEBUG >= 2
47extern char const*
const tu_str_speed[];
48extern char const*
const tu_str_std_request[];
49extern char const*
const tu_str_xfer_result[];
52void tu_print_mem(
void const *buf, uint32_t count, uint8_t indent);
54#ifdef CFG_TUSB_DEBUG_PRINTF
55 extern int CFG_TUSB_DEBUG_PRINTF(
const char *format, ...);
56 #define tu_printf CFG_TUSB_DEBUG_PRINTF
58 #define tu_printf printf
61static inline void tu_print_arr(uint8_t
const* buf, uint32_t bufsize)
63 for(uint32_t i=0; i<bufsize; i++) tu_printf(
"%02X ", buf[i]);
67#define TU_LOG(n, ...) TU_XSTRCAT(TU_LOG, n)(__VA_ARGS__)
68#define TU_LOG_MEM(n, ...) TU_XSTRCAT3(TU_LOG, n, _MEM)(__VA_ARGS__)
69#define TU_LOG_ARR(n, ...) TU_XSTRCAT3(TU_LOG, n, _ARR)(__VA_ARGS__)
70#define TU_LOG_PTR(n, ...) TU_XSTRCAT3(TU_LOG, n, _PTR)(__VA_ARGS__)
71#define TU_LOG_INT(n, ...) TU_XSTRCAT3(TU_LOG, n, _INT)(__VA_ARGS__)
72#define TU_LOG_HEX(n, ...) TU_XSTRCAT3(TU_LOG, n, _HEX)(__VA_ARGS__)
73#define TU_LOG_LOCATION() tu_printf("%s: %d:\r\n", __PRETTY_FUNCTION__, __LINE__)
74#define TU_LOG_FAILED() tu_printf("%s: %d: Failed\r\n", __PRETTY_FUNCTION__, __LINE__)
77#define TU_LOG1 tu_printf
78#define TU_LOG1_MEM tu_print_mem
79#define TU_LOG1_ARR(_x, _n) tu_print_arr((uint8_t const*)(_x), _n)
80#define TU_LOG1_PTR(_x) tu_print_arr((uint8_t const*)(_x), sizeof(*(_x)))
81#define TU_LOG1_INT(_x) tu_printf(#_x " = %ld\r\n", (unsigned long) (_x) )
82#define TU_LOG1_HEX(_x) tu_printf(#_x " = %lX\r\n", (unsigned long) (_x) )
85#if CFG_TUSB_DEBUG >= 2
86 #define TU_LOG2 TU_LOG1
87 #define TU_LOG2_MEM TU_LOG1_MEM
88 #define TU_LOG2_ARR TU_LOG1_ARR
89 #define TU_LOG2_PTR TU_LOG1_PTR
90 #define TU_LOG2_INT TU_LOG1_INT
91 #define TU_LOG2_HEX TU_LOG1_HEX
95#if CFG_TUSB_DEBUG >= 3
96 #define TU_LOG3 TU_LOG1
97 #define TU_LOG3_MEM TU_LOG1_MEM
98 #define TU_LOG3_ARR TU_LOG1_ARR
99 #define TU_LOG3_PTR TU_LOG1_PTR
100 #define TU_LOG3_INT TU_LOG1_INT
101 #define TU_LOG3_HEX TU_LOG1_HEX
113 tu_lookup_entry_t
const* items;
116static inline const char* tu_lookup_find(tu_lookup_table_t
const* p_table, uint32_t key)
118 tu_static
char not_found[11];
120 for(uint16_t i=0; i<p_table->count; i++)
122 if (p_table->items[i].key == key)
return p_table->items[i].data;
126 snprintf(not_found,
sizeof(not_found),
"0x%08lX", (
unsigned long) key);
134 #define TU_LOG(n, ...)
135 #define TU_LOG_MEM(n, ...)
136 #define TU_LOG_PTR(n, ...)
137 #define TU_LOG_INT(n, ...)
138 #define TU_LOG_HEX(n, ...)
139 #define TU_LOG_LOCATION()
140 #define TU_LOG_FAILED()
146#define TU_LOG0_MEM(...)
147#define TU_LOG0_PTR(...)
148#define TU_LOG0_INT(...)
149#define TU_LOG0_HEX(...)
153 #define TU_LOG1_MEM(...)
154 #define TU_LOG1_PTR(...)
155 #define TU_LOG1_INT(...)
156 #define TU_LOG1_HEX(...)
161 #define TU_LOG2_MEM(...)
162 #define TU_LOG2_PTR(...)
163 #define TU_LOG2_INT(...)
164 #define TU_LOG2_HEX(...)
169 #define TU_LOG3_MEM(...)
170 #define TU_LOG3_PTR(...)
171 #define TU_LOG3_INT(...)
172 #define TU_LOG3_HEX(...)