|
|
@@ -95,15 +95,25 @@ static void usbd_class_event_notify_handler(uint8_t busid, uint8_t event, void *
|
|
|
|
|
|
static void usbd_print_setup(struct usb_setup_packet *setup)
|
|
|
{
|
|
|
- USB_LOG_INFO("Setup: "
|
|
|
- "bmRequestType 0x%02x, bRequest 0x%02x, wValue 0x%04x, wIndex 0x%04x, wLength 0x%04x\r\n",
|
|
|
- setup->bmRequestType,
|
|
|
- setup->bRequest,
|
|
|
- setup->wValue,
|
|
|
- setup->wIndex,
|
|
|
- setup->wLength);
|
|
|
+ USB_LOG_ERR("Setup: "
|
|
|
+ "bmRequestType 0x%02x, bRequest 0x%02x, wValue 0x%04x, wIndex 0x%04x, wLength 0x%04x\r\n",
|
|
|
+ setup->bmRequestType,
|
|
|
+ setup->bRequest,
|
|
|
+ setup->wValue,
|
|
|
+ setup->wIndex,
|
|
|
+ setup->wLength);
|
|
|
}
|
|
|
|
|
|
+#if (CONFIG_USB_DBG_LEVEL >= USB_DBG_LOG)
|
|
|
+static const char *usb_ep0_state_string[] = {
|
|
|
+ "setup",
|
|
|
+ "indata",
|
|
|
+ "outdata",
|
|
|
+ "instatus",
|
|
|
+ "outstatus"
|
|
|
+};
|
|
|
+#endif
|
|
|
+
|
|
|
static bool is_device_configured(uint8_t busid)
|
|
|
{
|
|
|
return (g_usbd_core[busid].configuration != 0);
|
|
|
@@ -524,8 +534,6 @@ static bool usbd_set_interface(uint8_t busid, uint8_t iface, uint8_t alt_setting
|
|
|
if_desc = (void *)p;
|
|
|
}
|
|
|
|
|
|
- USB_LOG_DBG("Current iface %u alt setting %u",
|
|
|
- cur_iface, cur_alt_setting);
|
|
|
break;
|
|
|
|
|
|
case USB_DESCRIPTOR_TYPE_ENDPOINT:
|
|
|
@@ -1171,9 +1179,14 @@ static void __usbd_event_ep0_setup_complete_handler(uint8_t busid, struct usb_se
|
|
|
{
|
|
|
uint8_t *buf;
|
|
|
|
|
|
-#ifdef CONFIG_USBDEV_SETUP_LOG_PRINT
|
|
|
- usbd_print_setup(setup);
|
|
|
-#endif
|
|
|
+ USB_LOG_DBG("[%s] 0x%02x 0x%02x 0x%04x 0x%04x 0x%04x\r\n",
|
|
|
+ usb_ep0_state_string[usbd_get_ep0_next_state(busid)],
|
|
|
+ setup->bmRequestType,
|
|
|
+ setup->bRequest,
|
|
|
+ setup->wValue,
|
|
|
+ setup->wIndex,
|
|
|
+ setup->wLength);
|
|
|
+
|
|
|
if (setup->wLength > CONFIG_USBDEV_REQUEST_BUFFER_LEN) {
|
|
|
if ((setup->bmRequestType & USB_REQUEST_DIR_MASK) == USB_REQUEST_DIR_OUT) {
|
|
|
USB_LOG_ERR("Request buffer too small\r\n");
|
|
|
@@ -1240,7 +1253,6 @@ static void __usbd_event_ep0_setup_complete_handler(uint8_t busid, struct usb_se
|
|
|
*/
|
|
|
if ((setup->wLength > g_usbd_core[busid].ep0_data_buf_len) && (!(g_usbd_core[busid].ep0_data_buf_len % USB_CTRL_EP_MPS))) {
|
|
|
g_usbd_core[busid].zlp_flag = true;
|
|
|
- USB_LOG_DBG("EP0 Set zlp\r\n");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -1266,7 +1278,10 @@ static void usbd_event_ep0_in_complete_handler(uint8_t busid, uint8_t ep, uint32
|
|
|
g_usbd_core[busid].ep0_data_buf += nbytes;
|
|
|
g_usbd_core[busid].ep0_data_buf_residue -= nbytes;
|
|
|
|
|
|
- USB_LOG_DBG("EP0 send %d bytes, %d remained\r\n", (unsigned int)nbytes, (unsigned int)g_usbd_core[busid].ep0_data_buf_residue);
|
|
|
+ USB_LOG_DBG("[%s] in %d bytes, %d remained\r\n",
|
|
|
+ usb_ep0_state_string[usbd_get_ep0_next_state(busid)],
|
|
|
+ (unsigned int)nbytes,
|
|
|
+ (unsigned int)g_usbd_core[busid].ep0_data_buf_residue);
|
|
|
|
|
|
if (g_usbd_core[busid].ep0_data_buf_residue != 0) {
|
|
|
/* Start sending the remain data */
|
|
|
@@ -1311,12 +1326,15 @@ static void usbd_event_ep0_out_complete_handler(uint8_t busid, uint8_t ep, uint3
|
|
|
(void)ep;
|
|
|
(void)setup;
|
|
|
|
|
|
+ USB_LOG_DBG("[%s] out %d bytes, %d remained\r\n",
|
|
|
+ usb_ep0_state_string[usbd_get_ep0_next_state(busid)],
|
|
|
+ (unsigned int)nbytes,
|
|
|
+ (unsigned int)g_usbd_core[busid].ep0_data_buf_residue);
|
|
|
+
|
|
|
if (nbytes > 0) {
|
|
|
g_usbd_core[busid].ep0_data_buf += nbytes;
|
|
|
g_usbd_core[busid].ep0_data_buf_residue -= nbytes;
|
|
|
|
|
|
- USB_LOG_DBG("EP0 recv %d bytes, %d remained\r\n", (unsigned int)nbytes, (unsigned int)g_usbd_core[busid].ep0_data_buf_residue);
|
|
|
-
|
|
|
if (g_usbd_core[busid].ep0_data_buf_residue == 0) {
|
|
|
#ifdef CONFIG_USBDEV_EP0_THREAD
|
|
|
usb_osal_mq_send(g_usbd_core[busid].usbd_ep0_mq, USB_EP0_STATE_OUT);
|
|
|
@@ -1338,9 +1356,8 @@ static void usbd_event_ep0_out_complete_handler(uint8_t busid, uint8_t ep, uint3
|
|
|
usbd_ep_start_read(busid, USB_CONTROL_OUT_EP0, g_usbd_core[busid].ep0_data_buf, g_usbd_core[busid].ep0_data_buf_residue);
|
|
|
}
|
|
|
} else {
|
|
|
- g_usbd_core[busid].ep0_next_state = USBD_EP0_STATE_SETUP;
|
|
|
/* Read out status completely, do nothing */
|
|
|
- USB_LOG_DBG("EP0 recv out status\r\n");
|
|
|
+ g_usbd_core[busid].ep0_next_state = USBD_EP0_STATE_SETUP;
|
|
|
}
|
|
|
}
|
|
|
|