From 7a2c785e290e5d16ee4eda07fc409f8ebbfe144c Mon Sep 17 00:00:00 2001 From: Werner Almesberger Date: Fri, 10 Jun 2011 19:27:19 -0300 Subject: [PATCH] atusb/fw/usb/dfu.h: define DFU interface descriptor, for later sharing - dfu.h (DFU_ITF_DESCR): define DFU interface descriptor - dfu.c (config_descriptor): use DFU_ITF_DESCR instead of open-coding the descriptor --- atusb/fw/usb/dfu.c | 10 +--------- atusb/fw/usb/dfu.h | 12 ++++++++++++ 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/atusb/fw/usb/dfu.c b/atusb/fw/usb/dfu.c index 6efd9fd..a70c52b 100644 --- a/atusb/fw/usb/dfu.c +++ b/atusb/fw/usb/dfu.c @@ -77,15 +77,7 @@ const uint8_t config_descriptor[] = { /* Interface #0 */ - 9, /* bLength */ - USB_DT_INTERFACE, /* bDescriptorType */ - 0, /* bInterfaceNumber */ - 0, /* bAlternateSetting */ - 0, /* bNumEndpoints */ - 0xfe, /* bInterfaceClass (application specific) */ - 0x01, /* bInterfaceSubClass (device fw upgrade) */ - 0x02, /* bInterfaceProtocol (DFU mode protocol) */ - 0, /* iInterface */ + DFU_ITF_DESCR(0) }; diff --git a/atusb/fw/usb/dfu.h b/atusb/fw/usb/dfu.h index 152e297..0f2d262 100644 --- a/atusb/fw/usb/dfu.h +++ b/atusb/fw/usb/dfu.h @@ -78,6 +78,18 @@ struct dfu { }; +#define DFU_ITF_DESCR(itf) \ + 9, /* bLength */ \ + USB_DT_INTERFACE, /* bDescriptorType */ \ + (itf), /* bInterfaceNumber */ \ + 0, /* bAlternateSetting */ \ + 0, /* bNumEndpoints */ \ + 0xfe, /* bInterfaceClass (application specific) */ \ + 0x01, /* bInterfaceSubClass (device fw upgrade) */ \ + 0x02, /* bInterfaceProtocol (DFU mode protocol) */ \ + 0, /* iInterface */ + + extern struct dfu dfu;