Skip to content

Commit 21befbb

Browse files
committed
Refactor spurious prints
1 parent a6481d5 commit 21befbb

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

src/USBHost/dbg.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,37 +24,37 @@
2424
#define DEBUG_EVENT 1
2525

2626
#if (DEBUG > 3)
27-
#define USB_DBG(x, ...) std::printf("[USB_DBG: %s:%d]" x "\r\n", __FILE__, __LINE__, ##__VA_ARGS__);
27+
#define USB_DBG(x, ...) if (rtos::ThisThread::get_id() != 0) { printf("[USB_DBG: %s:%d]" x "\r\n", __FILE__, __LINE__, ##__VA_ARGS__); }
2828
#else
2929
#define USB_DBG(x, ...)
3030
#endif
3131

3232
#if (DEBUG > 2)
33-
#define USB_INFO(x, ...) std::printf("[USB_INFO: %s:%d]" x "\r\n", __FILE__, __LINE__, ##__VA_ARGS__);
33+
#define USB_INFO(x, ...) if (rtos::ThisThread::get_id() != 0) { printf("[USB_INFO: %s:%d]" x "\r\n", __FILE__, __LINE__, ##__VA_ARGS__); }
3434
#else
3535
#define USB_INFO(x, ...)
3636
#endif
3737

3838
#if (DEBUG > 1)
39-
#define USB_WARN(x, ...) std::printf("[USB_WARNING: %s:%d]" x "\r\n", __FILE__, __LINE__, ##__VA_ARGS__);
39+
#define USB_WARN(x, ...) if (rtos::ThisThread::get_id() != 0) { printf("[USB_WARNING: %s:%d]" x "\r\n", __FILE__, __LINE__, ##__VA_ARGS__); }
4040
#else
4141
#define USB_WARN(x, ...)
4242
#endif
4343

4444
#if (DEBUG > 0)
45-
#define USB_ERR(x, ...) std::printf("[USB_ERR: %s:%d]" x "\r\n", __FILE__, __LINE__, ##__VA_ARGS__);
45+
#define USB_ERR(x, ...) if (rtos::ThisThread::get_id() != 0) { printf("[USB_ERR: %s:%d]" x "\r\n", __FILE__, __LINE__, ##__VA_ARGS__); }
4646
#else
4747
#define USB_ERR(x, ...)
4848
#endif
4949

5050
#if (DEBUG_TRANSFER)
51-
#define USB_DBG_TRANSFER(x, ...) std::printf("[USB_TRANSFER: %s:%d]" x "\r\n", __FILE__, __LINE__, ##__VA_ARGS__);
51+
#define USB_DBG_TRANSFER(x, ...) if (rtos::ThisThread::get_id() != 0) { printf("[USB_TRANSFER: %s:%d]" x "\r\n", __FILE__, __LINE__, ##__VA_ARGS__); }
5252
#else
5353
#define USB_DBG_TRANSFER(x, ...)
5454
#endif
5555

5656
#if (DEBUG_EVENT)
57-
#define USB_DBG_EVENT(x, ...) std::printf("[USB_EVENT: %s:%d]" x "\r\n", __FILE__, __LINE__, ##__VA_ARGS__);
57+
#define USB_DBG_EVENT(x, ...) if (rtos::ThisThread::get_id() != 0) { std::printf("[USB_EVENT: %s:%d]" x "\r\n", __FILE__, __LINE__, ##__VA_ARGS__); }
5858
#else
5959
#define USB_DBG_EVENT(x, ...)
6060
#endif

src/targets/TARGET_STM/USBHALHost_STM.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ void HAL_HCD_HC_NotifyURBChange_Callback(HCD_HandleTypeDef *hhcd, uint8_t chnum,
114114
return;
115115
#if defined(MAX_NYET_RETRY)
116116
} else {
117-
USB_ERR("urb_state != URB_NOTREADY");
117+
//USB_ERR("urb_state != URB_NOTREADY");
118118
}
119119
#endif
120120
break;
@@ -133,7 +133,7 @@ void HAL_HCD_HC_NotifyURBChange_Callback(HCD_HandleTypeDef *hhcd, uint8_t chnum,
133133
(obj->*func)(addr);
134134
} else {
135135
if (urb_state != 0) {
136-
USB_DBG_EVENT("spurious %d %d", chnum, urb_state);
136+
//USB_DBG_EVENT("spurious %d %d", chnum, urb_state);
137137
}
138138
}
139139
}
@@ -190,7 +190,7 @@ void USBHALHost::enableList(ENDPOINT_TYPE type)
190190
if (control_disable == 0) {
191191
NVIC_EnableIRQ(USBHAL_IRQn);
192192
} else {
193-
printf("reent\n");
193+
//printf("reent\n");
194194
}
195195
}
196196
}
@@ -202,7 +202,7 @@ bool USBHALHost::disableList(ENDPOINT_TYPE type)
202202
NVIC_DisableIRQ(USBHAL_IRQn);
203203
control_disable++;
204204
if (control_disable > 1) {
205-
printf("disable reentrance !!!\n");
205+
//printf("disable reentrance !!!\n");
206206
}
207207
return true;
208208
}

0 commit comments

Comments
 (0)