@@ -58,16 +58,14 @@ void tu_print_mem(void const *buf, uint32_t count, uint8_t indent);
58
58
#define tu_printf printf
59
59
#endif
60
60
61
- static inline void tu_print_arr (uint8_t const * buf , uint32_t bufsize )
62
- {
61
+ static inline void tu_print_buf (uint8_t const * buf , uint32_t bufsize ) {
63
62
for (uint32_t i = 0 ; i < bufsize ; i ++ ) tu_printf ("%02X " , buf [i ]);
64
63
}
65
64
66
65
// Log with Level
67
66
#define TU_LOG (n , ...) TU_XSTRCAT(TU_LOG, n)(__VA_ARGS__)
68
67
#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__)
68
+ #define TU_LOG_BUF (n , ...) TU_XSTRCAT3(TU_LOG, n, _BUF)(__VA_ARGS__)
71
69
#define TU_LOG_INT (n , ...) TU_XSTRCAT3(TU_LOG, n, _INT)(__VA_ARGS__)
72
70
#define TU_LOG_HEX (n , ...) TU_XSTRCAT3(TU_LOG, n, _HEX)(__VA_ARGS__)
73
71
#define TU_LOG_LOCATION () tu_printf("%s: %d:\r\n", __PRETTY_FUNCTION__, __LINE__)
@@ -76,17 +74,15 @@ static inline void tu_print_arr(uint8_t const* buf, uint32_t bufsize)
76
74
// Log Level 1: Error
77
75
#define TU_LOG1 tu_printf
78
76
#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)))
77
+ #define TU_LOG1_BUF (_x , _n ) tu_print_buf((uint8_t const*)(_x), _n)
81
78
#define TU_LOG1_INT (_x ) tu_printf(#_x " = %ld\r\n", (unsigned long) (_x) )
82
79
#define TU_LOG1_HEX (_x ) tu_printf(#_x " = %lX\r\n", (unsigned long) (_x) )
83
80
84
81
// Log Level 2: Warn
85
82
#if CFG_TUSB_DEBUG >= 2
86
83
#define TU_LOG2 TU_LOG1
87
84
#define TU_LOG2_MEM TU_LOG1_MEM
88
- #define TU_LOG2_ARR TU_LOG1_ARR
89
- #define TU_LOG2_PTR TU_LOG1_PTR
85
+ #define TU_LOG2_BUF TU_LOG1_BUF
90
86
#define TU_LOG2_INT TU_LOG1_INT
91
87
#define TU_LOG2_HEX TU_LOG1_HEX
92
88
#endif
@@ -95,30 +91,25 @@ static inline void tu_print_arr(uint8_t const* buf, uint32_t bufsize)
95
91
#if CFG_TUSB_DEBUG >= 3
96
92
#define TU_LOG3 TU_LOG1
97
93
#define TU_LOG3_MEM TU_LOG1_MEM
98
- #define TU_LOG3_ARR TU_LOG1_ARR
99
- #define TU_LOG3_PTR TU_LOG1_PTR
94
+ #define TU_LOG3_BUF TU_LOG1_BUF
100
95
#define TU_LOG3_INT TU_LOG1_INT
101
96
#define TU_LOG3_HEX TU_LOG1_HEX
102
97
#endif
103
98
104
- typedef struct
105
- {
99
+ typedef struct {
106
100
uint32_t key ;
107
101
const char * data ;
108
102
} tu_lookup_entry_t ;
109
103
110
- typedef struct
111
- {
104
+ typedef struct {
112
105
uint16_t count ;
113
106
tu_lookup_entry_t const * items ;
114
107
} tu_lookup_table_t ;
115
108
116
- static inline const char * tu_lookup_find (tu_lookup_table_t const * p_table , uint32_t key )
117
- {
109
+ static inline const char * tu_lookup_find (tu_lookup_table_t const * p_table , uint32_t key ) {
118
110
tu_static char not_found [11 ];
119
111
120
- for (uint16_t i = 0 ; i < p_table -> count ; i ++ )
121
- {
112
+ for (uint16_t i = 0 ; i < p_table -> count ; i ++ ) {
122
113
if (p_table -> items [i ].key == key ) return p_table -> items [i ].data ;
123
114
}
124
115
@@ -133,8 +124,7 @@ static inline const char* tu_lookup_find(tu_lookup_table_t const* p_table, uint3
133
124
#ifndef TU_LOG
134
125
#define TU_LOG (n , ...)
135
126
#define TU_LOG_MEM (n , ...)
136
- #define TU_LOG_ARR (n , ...)
137
- #define TU_LOG_PTR (n , ...)
127
+ #define TU_LOG_BUF (n , ...)
138
128
#define TU_LOG_INT (n , ...)
139
129
#define TU_LOG_HEX (n , ...)
140
130
#define TU_LOG_LOCATION ()
@@ -145,34 +135,30 @@ static inline const char* tu_lookup_find(tu_lookup_table_t const* p_table, uint3
145
135
146
136
#define TU_LOG0 (...)
147
137
#define TU_LOG0_MEM (...)
148
- #define TU_LOG0_ARR (...)
149
- #define TU_LOG0_PTR (...)
138
+ #define TU_LOG0_BUF (...)
150
139
#define TU_LOG0_INT (...)
151
140
#define TU_LOG0_HEX (...)
152
141
153
142
#ifndef TU_LOG1
154
143
#define TU_LOG1 (...)
155
144
#define TU_LOG1_MEM (...)
156
- #define TU_LOG1_ARR (...)
157
- #define TU_LOG1_PTR (...)
145
+ #define TU_LOG1_BUF (...)
158
146
#define TU_LOG1_INT (...)
159
147
#define TU_LOG1_HEX (...)
160
148
#endif
161
149
162
150
#ifndef TU_LOG2
163
151
#define TU_LOG2 (...)
164
152
#define TU_LOG2_MEM (...)
165
- #define TU_LOG2_ARR (...)
166
- #define TU_LOG2_PTR (...)
153
+ #define TU_LOG2_BUF (...)
167
154
#define TU_LOG2_INT (...)
168
155
#define TU_LOG2_HEX (...)
169
156
#endif
170
157
171
158
#ifndef TU_LOG3
172
159
#define TU_LOG3 (...)
173
160
#define TU_LOG3_MEM (...)
174
- #define TU_LOG3_ARR (...)
175
- #define TU_LOG3_PTR (...)
161
+ #define TU_LOG3_BUF (...)
176
162
#define TU_LOG3_INT (...)
177
163
#define TU_LOG3_HEX (...)
178
164
#endif
0 commit comments