mirror of
https://github.com/hathach/tinyusb.git
synced 2025-02-20 18:40:57 +00:00
Merge pull request #2389 from IngHK/improve_debug_prints
improved hex debug print, improved USBH debug prints, added pid/vid debug print
This commit is contained in:
commit
382f686f19
@ -60,6 +60,7 @@ void tu_print_mem(void const *buf, uint32_t count, uint8_t indent);
|
||||
|
||||
static inline void tu_print_buf(uint8_t const* buf, uint32_t bufsize) {
|
||||
for(uint32_t i=0; i<bufsize; i++) tu_printf("%02X ", buf[i]);
|
||||
tu_printf("\r\n");
|
||||
}
|
||||
|
||||
// Log with Level
|
||||
@ -76,7 +77,7 @@ static inline void tu_print_buf(uint8_t const* buf, uint32_t bufsize) {
|
||||
#define TU_LOG1_MEM tu_print_mem
|
||||
#define TU_LOG1_BUF(_x, _n) tu_print_buf((uint8_t const*)(_x), _n)
|
||||
#define TU_LOG1_INT(_x) tu_printf(#_x " = %ld\r\n", (unsigned long) (_x) )
|
||||
#define TU_LOG1_HEX(_x) tu_printf(#_x " = %lX\r\n", (unsigned long) (_x) )
|
||||
#define TU_LOG1_HEX(_x) tu_printf(#_x " = 0x%lX\r\n", (unsigned long) (_x) )
|
||||
|
||||
// Log Level 2: Warn
|
||||
#if CFG_TUSB_DEBUG >= 2
|
||||
|
@ -500,7 +500,6 @@ void tud_task_ext(uint32_t timeout_ms, bool in_isr)
|
||||
|
||||
case DCD_EVENT_SETUP_RECEIVED:
|
||||
TU_LOG_BUF(CFG_TUD_LOG_LEVEL, &event.setup_received, 8);
|
||||
TU_LOG_USBD("\r\n");
|
||||
|
||||
// Mark as connected after receiving 1st setup packet.
|
||||
// But it is easier to set it every time instead of wasting time to check then set
|
||||
|
@ -343,12 +343,12 @@ bool tuh_init(uint8_t controller_id) {
|
||||
if ( tuh_inited() ) return true;
|
||||
|
||||
TU_LOG_USBH("USBH init on controller %u\r\n", controller_id);
|
||||
TU_LOG_INT(CFG_TUH_LOG_LEVEL, sizeof(usbh_device_t));
|
||||
TU_LOG_INT(CFG_TUH_LOG_LEVEL, sizeof(hcd_event_t));
|
||||
TU_LOG_INT(CFG_TUH_LOG_LEVEL, sizeof(_ctrl_xfer));
|
||||
TU_LOG_INT(CFG_TUH_LOG_LEVEL, sizeof(tuh_xfer_t));
|
||||
TU_LOG_INT(CFG_TUH_LOG_LEVEL, sizeof(tu_fifo_t));
|
||||
TU_LOG_INT(CFG_TUH_LOG_LEVEL, sizeof(tu_edpt_stream_t));
|
||||
TU_LOG_INT_USBH(sizeof(usbh_device_t));
|
||||
TU_LOG_INT_USBH(sizeof(hcd_event_t));
|
||||
TU_LOG_INT_USBH(sizeof(_ctrl_xfer));
|
||||
TU_LOG_INT_USBH(sizeof(tuh_xfer_t));
|
||||
TU_LOG_INT_USBH(sizeof(tu_fifo_t));
|
||||
TU_LOG_INT_USBH(sizeof(tu_edpt_stream_t));
|
||||
|
||||
// Event queue
|
||||
_usbh_q = osal_queue_create( &_usbh_qdef );
|
||||
@ -588,8 +588,7 @@ bool tuh_control_xfer (tuh_xfer_t* xfer) {
|
||||
TU_LOG_USBH("[%u:%u] %s: ", rhport, daddr,
|
||||
(xfer->setup->bmRequestType_bit.type == TUSB_REQ_TYPE_STANDARD && xfer->setup->bRequest <= TUSB_REQ_SYNCH_FRAME) ?
|
||||
tu_str_std_request[xfer->setup->bRequest] : "Class Request");
|
||||
TU_LOG_BUF(CFG_TUH_LOG_LEVEL, xfer->setup, 8);
|
||||
TU_LOG_USBH("\r\n");
|
||||
TU_LOG_BUF_USBH(xfer->setup, 8);
|
||||
|
||||
if (xfer->complete_cb) {
|
||||
TU_ASSERT( hcd_setup_send(rhport, daddr, (uint8_t const*) &_ctrl_xfer.request) );
|
||||
@ -660,9 +659,8 @@ static bool usbh_control_xfer_cb (uint8_t dev_addr, uint8_t ep_addr, xfer_result
|
||||
tusb_control_request_t const * request = &_ctrl_xfer.request;
|
||||
|
||||
if (XFER_RESULT_SUCCESS != result) {
|
||||
TU_LOG1("[%u:%u] Control %s, xferred_bytes = %lu\r\n", rhport, dev_addr, result == XFER_RESULT_STALLED ? "STALLED" : "FAILED", xferred_bytes);
|
||||
TU_LOG1_BUF(request, 8);
|
||||
TU_LOG1("\r\n");
|
||||
TU_LOG_USBH("[%u:%u] Control %s, xferred_bytes = %lu\r\n", rhport, dev_addr, result == XFER_RESULT_STALLED ? "STALLED" : "FAILED", xferred_bytes);
|
||||
TU_LOG_BUF_USBH(request, 8);
|
||||
|
||||
// terminate transfer if any stage failed
|
||||
_xfer_complete(dev_addr, result);
|
||||
@ -680,7 +678,7 @@ static bool usbh_control_xfer_cb (uint8_t dev_addr, uint8_t ep_addr, xfer_result
|
||||
case CONTROL_STAGE_DATA:
|
||||
if (request->wLength) {
|
||||
TU_LOG_USBH("[%u:%u] Control data:\r\n", rhport, dev_addr);
|
||||
TU_LOG_MEM(CFG_TUH_LOG_LEVEL, _ctrl_xfer.buffer, xferred_bytes, 2);
|
||||
TU_LOG_MEM_USBH(_ctrl_xfer.buffer, xferred_bytes, 2);
|
||||
}
|
||||
|
||||
_ctrl_xfer.actual_len = (uint16_t) xferred_bytes;
|
||||
|
@ -35,7 +35,11 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define TU_LOG_USBH(...) TU_LOG(CFG_TUH_LOG_LEVEL, __VA_ARGS__)
|
||||
#define TU_LOG_USBH(...) TU_LOG(CFG_TUH_LOG_LEVEL, __VA_ARGS__)
|
||||
#define TU_LOG_MEM_USBH(...) TU_LOG_MEM(CFG_TUH_LOG_LEVEL, __VA_ARGS__)
|
||||
#define TU_LOG_BUF_USBH(...) TU_LOG_BUF(CFG_TUH_LOG_LEVEL, __VA_ARGS__)
|
||||
#define TU_LOG_INT_USBH(...) TU_LOG_INT(CFG_TUH_LOG_LEVEL, __VA_ARGS__)
|
||||
#define TU_LOG_HEX_USBH(...) TU_LOG_HEX(CFG_TUH_LOG_LEVEL, __VA_ARGS__)
|
||||
|
||||
enum {
|
||||
USBH_EPSIZE_BULK_MAX = (TUH_OPT_HIGH_SPEED ? TUSB_EPSIZE_BULK_HS : TUSB_EPSIZE_BULK_FS)
|
||||
|
Loading…
x
Reference in New Issue
Block a user