diff --git a/drivers/usbhost/usbhost_enumerate.c b/drivers/usbhost/usbhost_enumerate.c index 0fe5105e3c2..65f09dfcb1d 100644 --- a/drivers/usbhost/usbhost_enumerate.c +++ b/drivers/usbhost/usbhost_enumerate.c @@ -335,7 +335,7 @@ int usbhost_enumerate(FAR struct usbhost_class_s *devclass) /* Get information about the connected device */ - ret = DRVR_GETDEVINFO(drvr, &devinfo); + ret = DRVR_GETDEVINFO(devclass->drvr, &devinfo); if (ret != OK) { udbg("DRVR_GETDEVINFO failed: %d\n", ret); @@ -370,16 +370,16 @@ int usbhost_enumerate(FAR struct usbhost_class_s *devclass) descsize = 8; } - /* Set the initial maximum packet size */ + /* Configure EP0 with the initial maximum packet size */ - DRVR_EP0CONFIGURE(drvr, 0, maxpacketsize); + DRVR_EP0CONFIGURE(devclass->drvr, devclass->ep0, 0, maxpacketsize); /* Read first bytes of the device descriptor */ ret = usbhost_ctrlxfer(devclass, (USB_REQ_DIR_IN | USB_REQ_RECIPIENT_DEVICE), USB_REQ_GETDESCRIPTOR, (USB_DESC_TYPE_DEVICE << 8), - 0, descsizedescsize, buffer); + 0, descsize, buffer); if (ret != OK) { udbg("ERROR: Failed to get device descriptor, length=%d: %d\n", @@ -392,9 +392,9 @@ int usbhost_enumerate(FAR struct usbhost_class_s *devclass) maxpacketsize = ((struct usb_devdesc_s *)buffer)->mxpacketsize; uvdbg("maxpacksetsize: %d\n", maxpacketsize); - /* And reconfigure EP0 */ + /* And reconfigure EP0 with the correct maximum packet size */ - DRVR_EP0CONFIGURE(drvr, 0, maxpacketsize); + DRVR_EP0CONFIGURE(devclass->drvr, devclass->ep0, 0, maxpacketsize); /* Set the USB device address */ @@ -410,9 +410,9 @@ int usbhost_enumerate(FAR struct usbhost_class_s *devclass) usleep(2*1000); - /* And reconfigure EP0 */ + /* And reconfigure EP0 with the correct address */ - DRVR_EP0CONFIGURE(devclass->drvr, devclass->ep0, devclass->addr + DRVR_EP0CONFIGURE(devclass->drvr, devclass->ep0, devclass->addr, maxpacketsize); /* Now read the full device descriptor (if we have not already done so) */ diff --git a/include/nuttx/usb/usbhost.h b/include/nuttx/usb/usbhost.h index 5f838a3c59d..80628002b80 100644 --- a/include/nuttx/usb/usbhost.h +++ b/include/nuttx/usb/usbhost.h @@ -557,7 +557,7 @@ * ************************************************************************************/ -#ifdef CONFIG_UBHOST_HUB +#ifdef CONFIG_USBHOST_HUB # define DRVR_RHCTRL(drvr,xfer,cmd) ((drvr)->rhctrl(drvr,xfer,cmd)) # define DRVR_RHSTATUS(drvr,xfer) ((drvr)->rhstatus(drvr,xfer)) #endif @@ -614,13 +614,22 @@ struct usbhost_registry_s FAR const struct usbhost_id_s *id; /* An array of ID info. Actual dimension is nids */ }; + +/* This type represents one endpoint configured by the epalloc() method. + * The actual form is known only internally to the USB host controller + * (for example, for an OHCI driver, this would probably be a pointer + * to an endpoint descriptor). + */ + +typedef FAR void *usbhost_ep_t; + /* struct usbhost_class_s provides access from the USB host driver to the USB host * class implementation. */ struct usbhost_class_s { -#ifdef CONFIG_UBHOST_HUB +#ifdef CONFIG_USBHOST_HUB /* Host driver */ struct usbhost_driver_s *drvr; @@ -672,7 +681,7 @@ struct usbhost_class_s struct usbhost_epdesc_s { -#ifdef CONFIG_UBHOST_HUB +#ifdef CONFIG_USBHOST_HUB FAR struct usbhost_class_s *devclass; /* Class */ #endif uint8_t addr; /* Endpoint address */ @@ -689,15 +698,6 @@ struct usbhost_devinfo_s { uint8_t speed:2; /* Device speed: 0=low, 1=full, 2=high */ }; - -/* This type represents one endpoint configured by the epalloc() method. - * The actual form is known only internally to the USB host controller - * (for example, for an OHCI driver, this would probably be a pointer - * to an endpoint descriptor). - */ - -typedef FAR void *usbhost_ep_t; - /* Generic transfer structure */ struct usbhost_transfer_s @@ -758,7 +758,7 @@ struct usbhost_connection_s struct usbhost_driver_s { -#ifdef CONFIG_UBHOST_HUB +#ifdef CONFIG_USBHOST_HUB /* Root hub */ FAR struct usbhost_class_s *roothub; @@ -852,7 +852,7 @@ struct usbhost_driver_s void (*disconnect)(FAR struct usbhost_driver_s *drvr); -#ifdef CONFIG_UBHOST_HUB +#ifdef CONFIG_USBHOST_HUB /* Called by hub class to control root hub. */ int (*rhctrl)(FAR struct usbhost_driver_s *drvr,