summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2011-07-31 16:32:33 +0200
committerHarald Welte <laforge@gnumonks.org>2011-07-31 16:33:00 +0200
commita341a060020ee1b5d7375ab4e40ad61314d43be4 (patch)
tree7d6df0d6f243862c1c20a9b0008d684a50afcb49
parenta774bcc3fd40ec5914196a21150c9879e33951e1 (diff)
Add DFU interface descriptor support to CDC-serial driver
-rw-r--r--at91lib/boards/sam7-p/board.h4
-rw-r--r--at91lib/usb/device/cdc-serial/CDCDSerialDriverDescriptors.c20
-rw-r--r--usb-device-cdc-serial-project/Makefile3
3 files changed, 18 insertions, 9 deletions
diff --git a/at91lib/boards/sam7-p/board.h b/at91lib/boards/sam7-p/board.h
index 1fcf43e..2e5046a 100644
--- a/at91lib/boards/sam7-p/board.h
+++ b/at91lib/boards/sam7-p/board.h
@@ -256,6 +256,8 @@
/// This page lists the definitions related to external on-board components
/// located in the board.h file for the SAM7S-EK.
///
-//
+
+#define BOARD_USB_DFU
+
#endif //#ifndef BOARD_H
diff --git a/at91lib/usb/device/cdc-serial/CDCDSerialDriverDescriptors.c b/at91lib/usb/device/cdc-serial/CDCDSerialDriverDescriptors.c
index 0c900e1..349380c 100644
--- a/at91lib/usb/device/cdc-serial/CDCDSerialDriverDescriptors.c
+++ b/at91lib/usb/device/cdc-serial/CDCDSerialDriverDescriptors.c
@@ -38,6 +38,7 @@
#include <usb/common/core/USBEndpointDescriptor.h>
#include <usb/common/core/USBStringDescriptor.h>
#include <usb/common/core/USBGenericRequest.h>
+#include <usb/device/dfu/dfu.h>
#include <usb/common/cdc/CDCGenericDescriptor.h>
#include <usb/common/cdc/CDCDeviceDescriptor.h>
#include <usb/common/cdc/CDCCommunicationInterfaceDescriptor.h>
@@ -104,7 +105,7 @@ typedef struct {
USBEndpointDescriptor dataOut;
/// Data IN endpoint descriptor.
USBEndpointDescriptor dataIn;
-
+ DFU_IF_DESCRIPTORS_STRUCT
} __attribute__ ((packed)) CDCDSerialDriverConfigurationDescriptors;
//------------------------------------------------------------------------------
@@ -156,7 +157,7 @@ const CDCDSerialDriverConfigurationDescriptors configurationDescriptors = {
sizeof(USBConfigurationDescriptor),
USBGenericDescriptor_CONFIGURATION,
sizeof(CDCDSerialDriverConfigurationDescriptors),
- 2, // There are two interfaces in this configuration
+ 2+DFU_NUM_IF, // There are two interfaces in this configuration
1, // This is configuration #1
0, // No string descriptor for this configuration
BOARD_USB_BMATTRIBUTES,
@@ -221,7 +222,7 @@ const CDCDSerialDriverConfigurationDescriptors configurationDescriptors = {
USBGenericDescriptor_INTERFACE,
1, // This is interface #1
0, // This is alternate setting #0 for this interface
- 2, // This interface uses 2 endpoints
+ 2+DFU_NUM_IF, // This interface uses 2 endpoints
CDCDataInterfaceDescriptor_CLASS,
CDCDataInterfaceDescriptor_SUBCLASS,
CDCDataInterfaceDescriptor_NOPROTOCOL,
@@ -249,6 +250,7 @@ const CDCDSerialDriverConfigurationDescriptors configurationDescriptors = {
USBEndpointDescriptor_MAXBULKSIZE_FS),
0 // Must be 0 for full-speed bulk endpoints
},
+ DFU_IF_DESCRIPTORS
};
/// Language ID string descriptor
@@ -268,7 +270,7 @@ const CDCDSerialDriverConfigurationDescriptors otherSpeedDescriptorsFS = {
sizeof(USBConfigurationDescriptor),
USBGenericDescriptor_OTHERSPEEDCONFIGURATION,
sizeof(CDCDSerialDriverConfigurationDescriptors),
- 2, // There are two interfaces in this configuration
+ 2+DFU_NUM_IF, // There are two interfaces in this configuration
1, // This is configuration #1
0, // No string descriptor for this configuration
BOARD_USB_BMATTRIBUTES,
@@ -361,6 +363,7 @@ const CDCDSerialDriverConfigurationDescriptors otherSpeedDescriptorsFS = {
USBEndpointDescriptor_MAXBULKSIZE_HS),
0 // Must be 0 for full-speed bulk endpoints
},
+ DFU_IF_DESCRIPTORS
};
@@ -372,7 +375,7 @@ const CDCDSerialDriverConfigurationDescriptors configurationDescriptorsHS = {
sizeof(USBConfigurationDescriptor),
USBGenericDescriptor_CONFIGURATION,
sizeof(CDCDSerialDriverConfigurationDescriptors),
- 2, // There are two interfaces in this configuration
+ 2+DFU_NUM_IF, // There are two interfaces in this configuration
1, // This is configuration #1
0, // No string descriptor for this configuration
BOARD_USB_BMATTRIBUTES,
@@ -465,6 +468,7 @@ const CDCDSerialDriverConfigurationDescriptors configurationDescriptorsHS = {
USBEndpointDescriptor_MAXBULKSIZE_HS),
0 // Must be 0 for full-speed bulk endpoints
},
+ DFU_IF_DESCRIPTORS
};
/// Other-speed configuration descriptor (when in high-speed).
@@ -475,7 +479,7 @@ const CDCDSerialDriverConfigurationDescriptors otherSpeedDescriptorsHS = {
sizeof(USBConfigurationDescriptor),
USBGenericDescriptor_OTHERSPEEDCONFIGURATION,
sizeof(CDCDSerialDriverConfigurationDescriptors),
- 2, // There are two interfaces in this configuration
+ 2+DFU_NUM_IF, // There are two interfaces in this configuration
1, // This is configuration #1
0, // No string descriptor for this configuration
BOARD_USB_BMATTRIBUTES,
@@ -568,6 +572,7 @@ const CDCDSerialDriverConfigurationDescriptors otherSpeedDescriptorsHS = {
USBEndpointDescriptor_MAXBULKSIZE_FS),
0 // Must be 0 for full-speed bulk endpoints
},
+ DFU_IF_DESCRIPTORS
};
#endif
@@ -596,6 +601,7 @@ const unsigned char *stringDescriptors[] = {
languageIdStringDescriptor,
productStringDescriptor,
+ DFU_STRING_DESCRIPTORS
};
/// List of standard descriptors for the serial driver.
@@ -620,6 +626,6 @@ USBDDriverDescriptors cdcdSerialDriverDescriptors = {
#endif
stringDescriptors,
- 2 // 2 string descriptors in list
+ 2+DFU_NUM_STRINGS // 2 string descriptors in list
};
diff --git a/usb-device-cdc-serial-project/Makefile b/usb-device-cdc-serial-project/Makefile
index 64123a2..a591302 100644
--- a/usb-device-cdc-serial-project/Makefile
+++ b/usb-device-cdc-serial-project/Makefile
@@ -96,6 +96,7 @@ BOARDS = $(AT91LIB)/boards
VPATH += $(USB)/device/cdc-serial $(USB)/device/core $(USB)/common/core
VPATH += $(USB)/common/cdc
+VPATH += $(USB)/device/dfu
VPATH += $(UTILITY)
VPATH += $(PERIPH)/dbgu $(PERIPH)/aic $(PERIPH)/usart $(PERIPH)/pio $(PERIPH)/pmc
VPATH += $(PERIPH)/cp15
@@ -106,7 +107,7 @@ C_OBJECTS = main.o
C_OBJECTS += CDCDSerialDriver.o CDCDSerialDriverDescriptors.o
C_OBJECTS += CDCSetControlLineStateRequest.o CDCLineCoding.o
C_OBJECTS += USBD_OTGHS.o USBD_UDP.o USBD_UDPHS.o USBDDriver.o
-C_OBJECTS += USBDCallbacks_Initialized.o
+C_OBJECTS += USBDCallbacks_Initialized.o dfu.o
C_OBJECTS += USBDCallbacks_Reset.o
#C_OBJECTS += USBDCallbacks_Resumed.o
#C_OBJECTS += USBDCallbacks_Suspended.o
personal git repositories of Harald Welte. Your mileage may vary