}
}
+/* USB setup packet: class/vendor request handler */
+static void usb_event_handler(struct usb_device *dev)
+{
+ /*
+ * TODO: get the appropriate usb_dev in function of the endpoint
+ * address.
+ */
+ if (dev->event_cb)
+ dev->event_cb(&setup_packet);
+}
+
/* USB setup packet: GET_DESCRIPTOR handler */
static void UBS_GetDescriptorHandler(void)
{
if ((setup_packet.mRequestType & USB_RECIP_MASK) ==
USB_RECIP_DEVICE)
UsbGetDescriptor();
+ /* Getting descriptor for a device is a standard request */
+ else if ((setup_packet.mRequestType & USB_DIR_MASK) == USB_DIR_IN)
+ usb_event_handler(usb_dev);
else
ep_cnfg[CTRL_ENP_OUT].status = STALLED;
}
}
}
-/* USB setup packet: class/vendor request handler */
-static void USB_EventHandler(void)
-{
- /*
- * TODO: get the appropriate usb_dev in function of the endpoint
- * address.
- */
- if (usb_dev->event_cb)
- usb_dev->event_cb(&setup_packet);
-}
-
/* USB setup packet handler */
static void USB_SetupHandler(void)
{
case USB_TYPE_CLASS:
LOG_INFO("%s: bmRequestType=%02x (Class)\n",
__func__, setup_packet.mRequestType);
- USB_EventHandler();
+ usb_event_handler(usb_dev);
break;
/* Vendor */
case USB_TYPE_VENDOR:
LOG_INFO("%s: bmRequestType=%02x (Vendor)\n",
__func__, setup_packet.mRequestType);
- USB_EventHandler();
+ usb_event_handler(usb_dev);
break;
case USB_TYPE_RESERVED:
LOG_INFO("%s: bmRequestType=%02x (Reserved)\n",
*/
#define USB_DIR_OUT 0 /* to device */
#define USB_DIR_IN 0x80 /* to host */
+#define USB_DIR_MASK 0x80
/*
* USB types, the second of three bRequestType fields
* Endpoints
*/
#define USB_ENDPOINT_NUMBER_MASK 0x0f /* in bEndpointAddress */
-#define USB_ENDPOINT_DIR_MASK 0x80
+#define USB_ENDPOINT_DIR_MASK USB_DIR_MASK
#define USB_ENDPOINT_SYNCTYPE 0x0c
#define USB_ENDPOINT_SYNC_NONE (0 << 2)