Skip to content

Commit 0b3503c

Browse files
committed
clean up usbd log level
1 parent 4639cac commit 0b3503c

File tree

2 files changed

+36
-36
lines changed

2 files changed

+36
-36
lines changed

examples/host/bare_api/src/main.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@ void tuh_mount_cb (uint8_t daddr)
8484
{
8585
printf("Device attached, address = %d\r\n", daddr);
8686

87-
// Get Device Descriptor sync API
88-
// TODO: invoking control trannsfer now has issue with mounting hub with multiple devices attached, fix later
87+
// Get Device Descriptor
88+
// TODO: invoking control transfer now has issue with mounting hub with multiple devices attached, fix later
8989
tuh_descriptor_get_device(daddr, &desc_device, 18, print_device_descriptor, 0);
9090
}
9191

src/device/usbd.c

+34-34
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ void usbd_driver_print_control_complete_name(usbd_control_xfer_cb_t callback)
318318
usbd_class_driver_t const * driver = get_driver(i);
319319
if ( driver->control_xfer_cb == callback )
320320
{
321-
TU_LOG2(" %s control complete\r\n", driver->name);
321+
TU_LOG(USBD_DBG, " %s control complete\r\n", driver->name);
322322
return;
323323
}
324324
}
@@ -384,8 +384,8 @@ bool tud_init (uint8_t rhport)
384384
// skip if already initialized
385385
if ( tud_inited() ) return true;
386386

387-
TU_LOG2("USBD init on controller %u\r\n", rhport);
388-
TU_LOG2_INT(sizeof(usbd_device_t));
387+
TU_LOG(USBD_DBG, "USBD init on controller %u\r\n", rhport);
388+
TU_LOG_INT(USBD_DBG, sizeof(usbd_device_t));
389389

390390
tu_varclr(&_usbd_dev);
391391

@@ -409,7 +409,7 @@ bool tud_init (uint8_t rhport)
409409
for (uint8_t i = 0; i < TOTAL_DRIVER_COUNT; i++)
410410
{
411411
usbd_class_driver_t const * driver = get_driver(i);
412-
TU_LOG2("%s init\r\n", driver->name);
412+
TU_LOG(USBD_DBG, "%s init\r\n", driver->name);
413413
driver->init();
414414
}
415415

@@ -480,29 +480,29 @@ void tud_task_ext(uint32_t timeout_ms, bool in_isr)
480480
if ( !osal_queue_receive(_usbd_q, &event, timeout_ms) ) return;
481481

482482
#if CFG_TUSB_DEBUG >= 2
483-
if (event.event_id == DCD_EVENT_SETUP_RECEIVED) TU_LOG2("\r\n"); // extra line for setup
484-
TU_LOG2("USBD %s ", event.event_id < DCD_EVENT_COUNT ? _usbd_event_str[event.event_id] : "CORRUPTED");
483+
if (event.event_id == DCD_EVENT_SETUP_RECEIVED) TU_LOG(USBD_DBG, "\r\n"); // extra line for setup
484+
TU_LOG(USBD_DBG, "USBD %s ", event.event_id < DCD_EVENT_COUNT ? _usbd_event_str[event.event_id] : "CORRUPTED");
485485
#endif
486486

487487
switch ( event.event_id )
488488
{
489489
case DCD_EVENT_BUS_RESET:
490-
TU_LOG2(": %s Speed\r\n", tu_str_speed[event.bus_reset.speed]);
490+
TU_LOG(USBD_DBG, ": %s Speed\r\n", tu_str_speed[event.bus_reset.speed]);
491491
usbd_reset(event.rhport);
492492
_usbd_dev.speed = event.bus_reset.speed;
493493
break;
494494

495495
case DCD_EVENT_UNPLUGGED:
496-
TU_LOG2("\r\n");
496+
TU_LOG(USBD_DBG, "\r\n");
497497
usbd_reset(event.rhport);
498498

499499
// invoke callback
500500
if (tud_umount_cb) tud_umount_cb();
501501
break;
502502

503503
case DCD_EVENT_SETUP_RECEIVED:
504-
TU_LOG2_VAR(&event.setup_received);
505-
TU_LOG2("\r\n");
504+
TU_LOG_VAR(USBD_DBG, &event.setup_received);
505+
TU_LOG(USBD_DBG, "\r\n");
506506

507507
// Mark as connected after receiving 1st setup packet.
508508
// But it is easier to set it every time instead of wasting time to check then set
@@ -517,7 +517,7 @@ void tud_task_ext(uint32_t timeout_ms, bool in_isr)
517517
// Process control request
518518
if ( !process_control_request(event.rhport, &event.setup_received) )
519519
{
520-
TU_LOG2(" Stall EP0\r\n");
520+
TU_LOG(USBD_DBG, " Stall EP0\r\n");
521521
// Failed -> stall both control endpoint IN and OUT
522522
dcd_edpt_stall(event.rhport, 0);
523523
dcd_edpt_stall(event.rhport, 0 | TUSB_DIR_IN_MASK);
@@ -531,7 +531,7 @@ void tud_task_ext(uint32_t timeout_ms, bool in_isr)
531531
uint8_t const epnum = tu_edpt_number(ep_addr);
532532
uint8_t const ep_dir = tu_edpt_dir(ep_addr);
533533

534-
TU_LOG2("on EP %02X with %u bytes\r\n", ep_addr, (unsigned int) event.xfer_complete.len);
534+
TU_LOG(USBD_DBG, "on EP %02X with %u bytes\r\n", ep_addr, (unsigned int) event.xfer_complete.len);
535535

536536
_usbd_dev.ep_status[epnum][ep_dir].busy = false;
537537
_usbd_dev.ep_status[epnum][ep_dir].claimed = 0;
@@ -545,7 +545,7 @@ void tud_task_ext(uint32_t timeout_ms, bool in_isr)
545545
usbd_class_driver_t const * driver = get_driver( _usbd_dev.ep2drv[epnum][ep_dir] );
546546
TU_ASSERT(driver, );
547547

548-
TU_LOG2(" %s xfer callback\r\n", driver->name);
548+
TU_LOG(USBD_DBG, " %s xfer callback\r\n", driver->name);
549549
driver->xfer_cb(event.rhport, ep_addr, (xfer_result_t)event.xfer_complete.result, event.xfer_complete.len);
550550
}
551551
}
@@ -557,27 +557,27 @@ void tud_task_ext(uint32_t timeout_ms, bool in_isr)
557557
// e.g suspend -> resume -> unplug/plug. Skip suspend/resume if not connected
558558
if ( _usbd_dev.connected )
559559
{
560-
TU_LOG2(": Remote Wakeup = %u\r\n", _usbd_dev.remote_wakeup_en);
560+
TU_LOG(USBD_DBG, ": Remote Wakeup = %u\r\n", _usbd_dev.remote_wakeup_en);
561561
if (tud_suspend_cb) tud_suspend_cb(_usbd_dev.remote_wakeup_en);
562562
}else
563563
{
564-
TU_LOG2(" Skipped\r\n");
564+
TU_LOG(USBD_DBG, " Skipped\r\n");
565565
}
566566
break;
567567

568568
case DCD_EVENT_RESUME:
569569
if ( _usbd_dev.connected )
570570
{
571-
TU_LOG2("\r\n");
571+
TU_LOG(USBD_DBG, "\r\n");
572572
if (tud_resume_cb) tud_resume_cb();
573573
}else
574574
{
575-
TU_LOG2(" Skipped\r\n");
575+
TU_LOG(USBD_DBG, " Skipped\r\n");
576576
}
577577
break;
578578

579579
case USBD_EVENT_FUNC_CALL:
580-
TU_LOG2("\r\n");
580+
TU_LOG(USBD_DBG, "\r\n");
581581
if ( event.func_call.func ) event.func_call.func(event.func_call.param);
582582
break;
583583

@@ -602,7 +602,7 @@ void tud_task_ext(uint32_t timeout_ms, bool in_isr)
602602
static bool invoke_class_control(uint8_t rhport, usbd_class_driver_t const * driver, tusb_control_request_t const * request)
603603
{
604604
usbd_control_set_complete_callback(driver->control_xfer_cb);
605-
TU_LOG2(" %s control request\r\n", driver->name);
605+
TU_LOG(USBD_DBG, " %s control request\r\n", driver->name);
606606
return driver->control_xfer_cb(rhport, CONTROL_STAGE_SETUP, request);
607607
}
608608

@@ -626,8 +626,8 @@ static bool process_control_request(uint8_t rhport, tusb_control_request_t const
626626
#if CFG_TUSB_DEBUG >= 2
627627
if (TUSB_REQ_TYPE_STANDARD == p_request->bmRequestType_bit.type && p_request->bRequest <= TUSB_REQ_SYNCH_FRAME)
628628
{
629-
TU_LOG2(" %s", tu_str_std_request[p_request->bRequest]);
630-
if (TUSB_REQ_GET_DESCRIPTOR != p_request->bRequest) TU_LOG2("\r\n");
629+
TU_LOG(USBD_DBG, " %s", tu_str_std_request[p_request->bRequest]);
630+
if (TUSB_REQ_GET_DESCRIPTOR != p_request->bRequest) TU_LOG(USBD_DBG, "\r\n");
631631
}
632632
#endif
633633

@@ -905,7 +905,7 @@ static bool process_set_config(uint8_t rhport, uint8_t cfg_num)
905905
if ( (sizeof(tusb_desc_interface_t) <= drv_len) && (drv_len <= remaining_len) )
906906
{
907907
// Open successfully
908-
TU_LOG2(" %s opened\r\n", driver->name);
908+
TU_LOG(USBD_DBG, " %s opened\r\n", driver->name);
909909

910910
// Some drivers use 2 or more interfaces but may not have IAD e.g MIDI (always) or
911911
// BTH (even CDC) with class in device descriptor (single interface)
@@ -964,7 +964,7 @@ static bool process_get_descriptor(uint8_t rhport, tusb_control_request_t const
964964
{
965965
case TUSB_DESC_DEVICE:
966966
{
967-
TU_LOG2(" Device\r\n");
967+
TU_LOG(USBD_DBG, " Device\r\n");
968968

969969
void* desc_device = (void*) (uintptr_t) tud_descriptor_device_cb();
970970

@@ -988,7 +988,7 @@ static bool process_get_descriptor(uint8_t rhport, tusb_control_request_t const
988988

989989
case TUSB_DESC_BOS:
990990
{
991-
TU_LOG2(" BOS\r\n");
991+
TU_LOG(USBD_DBG, " BOS\r\n");
992992

993993
// requested by host if USB > 2.0 ( i.e 2.1 or 3.x )
994994
if (!tud_descriptor_bos_cb) return false;
@@ -1010,12 +1010,12 @@ static bool process_get_descriptor(uint8_t rhport, tusb_control_request_t const
10101010

10111011
if ( desc_type == TUSB_DESC_CONFIGURATION )
10121012
{
1013-
TU_LOG2(" Configuration[%u]\r\n", desc_index);
1013+
TU_LOG(USBD_DBG, " Configuration[%u]\r\n", desc_index);
10141014
desc_config = (uintptr_t) tud_descriptor_configuration_cb(desc_index);
10151015
}else
10161016
{
10171017
// Host only request this after getting Device Qualifier descriptor
1018-
TU_LOG2(" Other Speed Configuration\r\n");
1018+
TU_LOG(USBD_DBG, " Other Speed Configuration\r\n");
10191019
TU_VERIFY( tud_descriptor_other_speed_configuration_cb );
10201020
desc_config = (uintptr_t) tud_descriptor_other_speed_configuration_cb(desc_index);
10211021
}
@@ -1031,7 +1031,7 @@ static bool process_get_descriptor(uint8_t rhport, tusb_control_request_t const
10311031

10321032
case TUSB_DESC_STRING:
10331033
{
1034-
TU_LOG2(" String[%u]\r\n", desc_index);
1034+
TU_LOG(USBD_DBG, " String[%u]\r\n", desc_index);
10351035

10361036
// String Descriptor always uses the desc set from user
10371037
uint8_t const* desc_str = (uint8_t const*) tud_descriptor_string_cb(desc_index, tu_le16toh(p_request->wIndex));
@@ -1044,7 +1044,7 @@ static bool process_get_descriptor(uint8_t rhport, tusb_control_request_t const
10441044

10451045
case TUSB_DESC_DEVICE_QUALIFIER:
10461046
{
1047-
TU_LOG2(" Device Qualifier\r\n");
1047+
TU_LOG(USBD_DBG, " Device Qualifier\r\n");
10481048

10491049
TU_VERIFY( tud_descriptor_device_qualifier_cb );
10501050

@@ -1237,7 +1237,7 @@ bool usbd_edpt_xfer(uint8_t rhport, uint8_t ep_addr, uint8_t * buffer, uint16_t
12371237
// TODO skip ready() check for now since enumeration also use this API
12381238
// TU_VERIFY(tud_ready());
12391239

1240-
TU_LOG2(" Queue EP %02X with %u bytes ...\r\n", ep_addr, total_bytes);
1240+
TU_LOG(USBD_DBG, " Queue EP %02X with %u bytes ...\r\n", ep_addr, total_bytes);
12411241

12421242
// Attempt to transfer on a busy endpoint, sound like an race condition !
12431243
TU_ASSERT(_usbd_dev.ep_status[epnum][dir].busy == 0);
@@ -1254,7 +1254,7 @@ bool usbd_edpt_xfer(uint8_t rhport, uint8_t ep_addr, uint8_t * buffer, uint16_t
12541254
// DCD error, mark endpoint as ready to allow next transfer
12551255
_usbd_dev.ep_status[epnum][dir].busy = false;
12561256
_usbd_dev.ep_status[epnum][dir].claimed = 0;
1257-
TU_LOG2("FAILED\r\n");
1257+
TU_LOG(USBD_DBG, "FAILED\r\n");
12581258
TU_BREAKPOINT();
12591259
return false;
12601260
}
@@ -1271,7 +1271,7 @@ bool usbd_edpt_xfer_fifo(uint8_t rhport, uint8_t ep_addr, tu_fifo_t * ff, uint16
12711271
uint8_t const epnum = tu_edpt_number(ep_addr);
12721272
uint8_t const dir = tu_edpt_dir(ep_addr);
12731273

1274-
TU_LOG2(" Queue ISO EP %02X with %u bytes ... ", ep_addr, total_bytes);
1274+
TU_LOG(USBD_DBG, " Queue ISO EP %02X with %u bytes ... ", ep_addr, total_bytes);
12751275

12761276
// Attempt to transfer on a busy endpoint, sound like an race condition !
12771277
TU_ASSERT(_usbd_dev.ep_status[epnum][dir].busy == 0);
@@ -1282,14 +1282,14 @@ bool usbd_edpt_xfer_fifo(uint8_t rhport, uint8_t ep_addr, tu_fifo_t * ff, uint16
12821282

12831283
if (dcd_edpt_xfer_fifo(rhport, ep_addr, ff, total_bytes))
12841284
{
1285-
TU_LOG2("OK\r\n");
1285+
TU_LOG(USBD_DBG, "OK\r\n");
12861286
return true;
12871287
}else
12881288
{
12891289
// DCD error, mark endpoint as ready to allow next transfer
12901290
_usbd_dev.ep_status[epnum][dir].busy = false;
12911291
_usbd_dev.ep_status[epnum][dir].claimed = 0;
1292-
TU_LOG2("failed\r\n");
1292+
TU_LOG(USBD_DBG, "failed\r\n");
12931293
TU_BREAKPOINT();
12941294
return false;
12951295
}
@@ -1360,7 +1360,7 @@ void usbd_edpt_close(uint8_t rhport, uint8_t ep_addr)
13601360
rhport = _usbd_rhport;
13611361

13621362
TU_ASSERT(dcd_edpt_close, /**/);
1363-
TU_LOG2(" CLOSING Endpoint: 0x%02X\r\n", ep_addr);
1363+
TU_LOG(USBD_DBG, " CLOSING Endpoint: 0x%02X\r\n", ep_addr);
13641364

13651365
uint8_t const epnum = tu_edpt_number(ep_addr);
13661366
uint8_t const dir = tu_edpt_dir(ep_addr);

0 commit comments

Comments
 (0)