summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/device/usbd.c31
-rw-r--r--src/device/usbd_control.c11
2 files changed, 30 insertions, 12 deletions
diff --git a/src/device/usbd.c b/src/device/usbd.c
index f0b7fcefc..1f660f0f2 100644
--- a/src/device/usbd.c
+++ b/src/device/usbd.c
@@ -232,15 +232,15 @@ bool usbd_control_xfer_cb (uint8_t rhport, uint8_t ep_addr, xfer_result_t event,
#if CFG_TUSB_DEBUG >= 2
static char const* const _usbd_event_str[DCD_EVENT_COUNT] =
{
- "INVALID" ,
- "BUS_RESET" ,
- "UNPLUGGED" ,
+ "Invalid" ,
+ "Bus Reset" ,
+ "Unplugged" ,
"SOF" ,
- "SUSPEND" ,
- "RESUME" ,
- "SETUP_RECEIVED" ,
- "XFER_COMPLETE" ,
- "FUNC_CALL"
+ "Suspend" ,
+ "Resume" ,
+ "Setup Received" ,
+ "Xfer Complete" ,
+ "Func Call"
};
static char const* const _tusb_std_request_str[] =
@@ -260,6 +260,19 @@ static char const* const _tusb_std_request_str[] =
"Synch Frame"
};
+// for usbd_control to print the name of control complete driver
+void usbd_driver_print_control_complete_name(bool (*control_complete) (uint8_t, tusb_control_request_t const * ))
+{
+ for (uint8_t i = 0; i < USBD_CLASS_DRIVER_COUNT; i++)
+ {
+ if (_usbd_driver[i].control_complete == control_complete )
+ {
+ TU_LOG2(" %s control complete\r\n", _usbd_driver[i].name);
+ return;
+ }
+ }
+}
+
#endif
//--------------------------------------------------------------------+
@@ -356,7 +369,7 @@ void tud_task (void)
if ( !osal_queue_receive(_usbd_q, &event) ) return;
- TU_LOG2("USBD: %s", event.event_id < DCD_EVENT_COUNT ? _usbd_event_str[event.event_id] : "CORRUPTED");
+ TU_LOG2("USBD %s", event.event_id < DCD_EVENT_COUNT ? _usbd_event_str[event.event_id] : "CORRUPTED");
TU_LOG2("%s", (event.event_id != DCD_EVENT_XFER_COMPLETE && event.event_id != DCD_EVENT_SETUP_RECEIVED) ? "\r\n" : " ");
switch ( event.event_id )
diff --git a/src/device/usbd_control.c b/src/device/usbd_control.c
index b0ae85e3b..2778a0d77 100644
--- a/src/device/usbd_control.c
+++ b/src/device/usbd_control.c
@@ -58,6 +58,7 @@ static uint8_t _usbd_ctrl_buf[CFG_TUD_ENDPOINT0_SIZE];
// Application API
//--------------------------------------------------------------------+
+// Queue ZLP status transaction
static inline bool _status_stage_xact(uint8_t rhport, tusb_control_request_t const * request)
{
// Opposite to endpoint in Data Phase
@@ -81,7 +82,7 @@ bool tud_control_status(uint8_t rhport, tusb_control_request_t const * request)
return _status_stage_xact(rhport, request);
}
-// Transfer an transaction in Data Stage
+// Queue an transaction in Data Stage
// Each transaction has up to Endpoint0's max packet size.
// This function can also transfer an zero-length packet
static bool _data_stage_xact(uint8_t rhport)
@@ -102,7 +103,6 @@ static bool _data_stage_xact(uint8_t rhport)
}
// Transmit data to/from the control endpoint.
-//
// If the request's wLength is zero, a status packet is sent instead.
bool tud_control_xfer(uint8_t rhport, tusb_control_request_t const * request, void* buffer, uint16_t len)
{
@@ -182,7 +182,7 @@ bool usbd_control_xfer_cb (uint8_t rhport, uint8_t ep_addr, xfer_result_t result
// Data Stage is complete when all request's length are transferred or
// a short packet is sent including zero-length packet.
- if ( (_ctrl_xfer.request.wLength == _ctrl_xfer.total_xferred) || xferred_bytes < CFG_TUD_ENDPOINT0_SIZE )
+ if ( (_ctrl_xfer.request.wLength == _ctrl_xfer.total_xferred) || (xferred_bytes < CFG_TUD_ENDPOINT0_SIZE) )
{
// DATA stage is complete
bool is_ok = true;
@@ -191,6 +191,11 @@ bool usbd_control_xfer_cb (uint8_t rhport, uint8_t ep_addr, xfer_result_t result
// callback can still stall control in status phase e.g out data does not make sense
if ( _ctrl_xfer.complete_cb )
{
+ #if CFG_TUSB_DEBUG >= 2
+ extern void usbd_driver_print_control_complete_name(bool (*control_complete) (uint8_t, tusb_control_request_t const *));
+ usbd_driver_print_control_complete_name(_ctrl_xfer.complete_cb);
+ #endif
+
is_ok = _ctrl_xfer.complete_cb(rhport, &_ctrl_xfer.request);
}