summaryrefslogtreecommitdiffstats
path: root/app/dfu.c
diff options
context:
space:
mode:
Diffstat (limited to 'app/dfu.c')
-rw-r--r--app/dfu.c19
1 files changed, 16 insertions, 3 deletions
diff --git a/app/dfu.c b/app/dfu.c
index c505585..5aebe34 100644
--- a/app/dfu.c
+++ b/app/dfu.c
@@ -3,7 +3,7 @@
const struct usb_dfu_descriptor dfu_function = {
.bLength = sizeof (struct usb_dfu_descriptor),
.bDescriptorType = DFU_FUNCTIONAL,
- .bmAttributes = USB_DFU_CAN_DOWNLOAD,
+ .bmAttributes = USB_DFU_CAN_DOWNLOAD | USB_DFU_WILL_DETACH,
.wDetachTimeout = 255,
.wTransferSize = 1024,
.bcdDFUVersion = 0x011A,
@@ -12,19 +12,30 @@ const struct usb_dfu_descriptor dfu_function = {
const struct usb_interface_descriptor dfu_iface = {
.bLength = USB_DT_INTERFACE_SIZE,
.bDescriptorType = USB_DT_INTERFACE,
- .bInterfaceNumber = 2,
+ .bInterfaceNumber = 1,
.bAlternateSetting = 0,
.bNumEndpoints = 0,
.bInterfaceClass = 0xFE,
.bInterfaceSubClass = 1,
.bInterfaceProtocol = 1,
.iInterface = 4,
-
.extra = &dfu_function,
.extralen = sizeof (dfu_function),
};
+const struct usb_iface_assoc_descriptor dfu_iface_assoc = {
+ .bLength = USB_DT_INTERFACE_ASSOCIATION_SIZE,
+ .bDescriptorType = USB_DT_INTERFACE_ASSOCIATION,
+ .bFirstInterface = 1,
+ .bInterfaceCount = 1,
+ .bFunctionClass = 0xfe,
+ .bFunctionSubClass = 1,
+ .bFunctionProtocol = 1,
+ .iFunction = 5,
+};
+
+
static int
dfu_detach_complete (usbd_device *usbd_dev, struct usb_setup_data *req)
{
@@ -49,6 +60,8 @@ dfu_control_request (usbd_device *usbd_dev, struct usb_setup_data *req,
(void) len;
(void) usbd_dev;
+ printf ("dfu_control_request %02x %02x\n", req->bmRequestType, req->bRequest);
+
if ((req->bmRequestType & 0x7F) != 0x21) {
return 0; /* Only accept class request. */
}