From 390df0f0b66e53c7ea19770a343e8340ed319b77 Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Sun, 31 Jul 2011 14:09:50 +0200 Subject: AT91LIB: Add DFU interface descriptors to CCID A board can now define BOARD_USB_DFU which will cause the USB DFU interface descriptors for the sam7dfu bootloader to be appended automatically. --- at91lib/usb/device/dfu/dfu.h | 75 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 at91lib/usb/device/dfu/dfu.h (limited to 'at91lib/usb/device/dfu/dfu.h') diff --git a/at91lib/usb/device/dfu/dfu.h b/at91lib/usb/device/dfu/dfu.h new file mode 100644 index 0000000..f1323c1 --- /dev/null +++ b/at91lib/usb/device/dfu/dfu.h @@ -0,0 +1,75 @@ +#ifndef _USB_DFU_DESC_H +#define _USB_DFU_DESC_H + +#include + +#define CONFIG_DFU_NUM_APP_IF 1 +#define CONFIG_DFU_NUM_APP_STR 4 + +struct USBStringDescriptor { + USBGenericDescriptor hdr; + unsigned short wData[]; +} __attribute__((packed)); + + +#ifdef BOARD_USB_DFU + +#define DFU_NUM_IF 3 +#define DFU_IF_DESCRIPTORS { \ + { \ + .bLength = sizeof(USBInterfaceDescriptor), \ + .bDescriptorType = USBGenericDescriptor_INTERFACE, \ + .bInterfaceNumber = CONFIG_DFU_NUM_APP_IF, \ + .bAlternateSetting = 0, \ + .bNumEndpoints = 0, \ + .bInterfaceClass = 0xFE, \ + .bInterfaceSubClass = 0x01, \ + .bInterfaceProtocol = 0x01, \ + .iInterface = CONFIG_DFU_NUM_APP_STR, \ + }, \ + { \ + .bLength = sizeof(USBInterfaceDescriptor), \ + .bDescriptorType = USBGenericDescriptor_INTERFACE, \ + .bInterfaceNumber = CONFIG_DFU_NUM_APP_IF+1, \ + .bAlternateSetting = 0, \ + .bNumEndpoints = 0, \ + .bInterfaceClass = 0xFE, \ + .bInterfaceSubClass = 0x01, \ + .bInterfaceProtocol = 0x01, \ + .iInterface = CONFIG_DFU_NUM_APP_STR+1, \ + }, \ + { \ + .bLength = sizeof(USBInterfaceDescriptor), \ + .bDescriptorType = USBGenericDescriptor_INTERFACE, \ + .bInterfaceNumber = CONFIG_DFU_NUM_APP_IF+2, \ + .bAlternateSetting = 0, \ + .bNumEndpoints = 0, \ + .bInterfaceClass = 0xFE, \ + .bInterfaceSubClass = 0x01, \ + .bInterfaceProtocol = 0x01, \ + .iInterface = CONFIG_DFU_NUM_APP_STR+2, \ + }, \ +} + +extern const struct USBStringDescriptor USBDFU_string1; +extern const struct USBStringDescriptor USBDFU_string2; +extern const struct USBStringDescriptor USBDFU_string3; + +#define DFU_NUM_STRINGS 3 +#define DFU_STRING_DESCRIPTORS \ + &USBDFU_string1, \ + &USBDFU_string2, \ + &USBDFU_string3, + +#else /* BOARD_USB_DFU */ + +/* no DFU bootloader is being used */ +#define DFU_NUM_IF 0 +#define DFU_IF_DESCRIPTORS + +#define DFU_NUM_STRINGS 0 +#define DFU_STRING_DESCRIPTORS + +#endif /* BOARD_USB_DFU */ + +#endif -- cgit v1.2.3