@@ -58,16 +58,14 @@ void tu_print_mem(void const *buf, uint32_t count, uint8_t indent);
5858 #define tu_printf printf
5959#endif
6060
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 ) {
6362 for (uint32_t i = 0 ; i < bufsize ; i ++ ) tu_printf ("%02X " , buf [i ]);
6463}
6564
6665// Log with Level
6766#define TU_LOG (n , ...) TU_XSTRCAT(TU_LOG, n)(__VA_ARGS__)
6867#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__)
7169#define TU_LOG_INT (n , ...) TU_XSTRCAT3(TU_LOG, n, _INT)(__VA_ARGS__)
7270#define TU_LOG_HEX (n , ...) TU_XSTRCAT3(TU_LOG, n, _HEX)(__VA_ARGS__)
7371#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)
7674// Log Level 1: Error
7775#define TU_LOG1 tu_printf
7876#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)
8178#define TU_LOG1_INT (_x ) tu_printf(#_x " = %ld\r\n", (unsigned long) (_x) )
8279#define TU_LOG1_HEX (_x ) tu_printf(#_x " = %lX\r\n", (unsigned long) (_x) )
8380
8481// Log Level 2: Warn
8582#if CFG_TUSB_DEBUG >= 2
8683 #define TU_LOG2 TU_LOG1
8784 #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
9086 #define TU_LOG2_INT TU_LOG1_INT
9187 #define TU_LOG2_HEX TU_LOG1_HEX
9288#endif
@@ -95,30 +91,25 @@ static inline void tu_print_arr(uint8_t const* buf, uint32_t bufsize)
9591#if CFG_TUSB_DEBUG >= 3
9692 #define TU_LOG3 TU_LOG1
9793 #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
10095 #define TU_LOG3_INT TU_LOG1_INT
10196 #define TU_LOG3_HEX TU_LOG1_HEX
10297#endif
10398
104- typedef struct
105- {
99+ typedef struct {
106100 uint32_t key ;
107101 const char * data ;
108102} tu_lookup_entry_t ;
109103
110- typedef struct
111- {
104+ typedef struct {
112105 uint16_t count ;
113106 tu_lookup_entry_t const * items ;
114107} tu_lookup_table_t ;
115108
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 ) {
118110 tu_static char not_found [11 ];
119111
120- for (uint16_t i = 0 ; i < p_table -> count ; i ++ )
121- {
112+ for (uint16_t i = 0 ; i < p_table -> count ; i ++ ) {
122113 if (p_table -> items [i ].key == key ) return p_table -> items [i ].data ;
123114 }
124115
@@ -133,8 +124,7 @@ static inline const char* tu_lookup_find(tu_lookup_table_t const* p_table, uint3
133124#ifndef TU_LOG
134125 #define TU_LOG (n , ...)
135126 #define TU_LOG_MEM (n , ...)
136- #define TU_LOG_ARR (n , ...)
137- #define TU_LOG_PTR (n , ...)
127+ #define TU_LOG_BUF (n , ...)
138128 #define TU_LOG_INT (n , ...)
139129 #define TU_LOG_HEX (n , ...)
140130 #define TU_LOG_LOCATION ()
@@ -145,34 +135,30 @@ static inline const char* tu_lookup_find(tu_lookup_table_t const* p_table, uint3
145135
146136#define TU_LOG0 (...)
147137#define TU_LOG0_MEM (...)
148- #define TU_LOG0_ARR (...)
149- #define TU_LOG0_PTR (...)
138+ #define TU_LOG0_BUF (...)
150139#define TU_LOG0_INT (...)
151140#define TU_LOG0_HEX (...)
152141
153142#ifndef TU_LOG1
154143 #define TU_LOG1 (...)
155144 #define TU_LOG1_MEM (...)
156- #define TU_LOG1_ARR (...)
157- #define TU_LOG1_PTR (...)
145+ #define TU_LOG1_BUF (...)
158146 #define TU_LOG1_INT (...)
159147 #define TU_LOG1_HEX (...)
160148#endif
161149
162150#ifndef TU_LOG2
163151 #define TU_LOG2 (...)
164152 #define TU_LOG2_MEM (...)
165- #define TU_LOG2_ARR (...)
166- #define TU_LOG2_PTR (...)
153+ #define TU_LOG2_BUF (...)
167154 #define TU_LOG2_INT (...)
168155 #define TU_LOG2_HEX (...)
169156#endif
170157
171158#ifndef TU_LOG3
172159 #define TU_LOG3 (...)
173160 #define TU_LOG3_MEM (...)
174- #define TU_LOG3_ARR (...)
175- #define TU_LOG3_PTR (...)
161+ #define TU_LOG3_BUF (...)
176162 #define TU_LOG3_INT (...)
177163 #define TU_LOG3_HEX (...)
178164#endif
0 commit comments