summaryrefslogtreecommitdiffhomepage
path: root/digital/zigbit/bitcloud/stack/Components/HAL/drivers/USBClasses/common
diff options
context:
space:
mode:
Diffstat (limited to 'digital/zigbit/bitcloud/stack/Components/HAL/drivers/USBClasses/common')
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/drivers/USBClasses/common/include/usbDescriptors.h184
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/drivers/USBClasses/common/include/usbEnumeration.h53
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/drivers/USBClasses/common/include/usbSetupProcess.h51
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/drivers/USBClasses/common/src/usbDescriptors.c424
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/drivers/USBClasses/common/src/usbEnumeration.c231
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/drivers/USBClasses/common/src/usbSetupProcess.c90
6 files changed, 1033 insertions, 0 deletions
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/drivers/USBClasses/common/include/usbDescriptors.h b/digital/zigbit/bitcloud/stack/Components/HAL/drivers/USBClasses/common/include/usbDescriptors.h
new file mode 100644
index 00000000..6c07c4cb
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/drivers/USBClasses/common/include/usbDescriptors.h
@@ -0,0 +1,184 @@
+/****************************************************************************//**
+ \file usbDescriptors.h
+
+ \brief Declaration of descriptors structures.
+
+ \author
+ Atmel Corporation: http://www.atmel.com \n
+ Support email: avr@atmel.com
+
+ Copyright (c) 2008-2011, Atmel Corporation. All rights reserved.
+ Licensed under Atmel's Limited License Agreement (BitCloudTM).
+
+ \internal
+ History:
+ 05/09/08 A. Khromykh - Created
+ 26/08/11 N. Fomin - Modified (MSD support)
+*******************************************************************************/
+#ifndef _USBDESCRIPTORS_H
+#define _USBDESCRIPTORS_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <types.h>
+#include <usb.h>
+
+/******************************************************************************
+ Define(s) section
+******************************************************************************/
+#define VCP_INTERFACE_ENDPOINTS_NUMBER 2
+#define MSD_INTERFACE_ENDPOINTS_NUMBER 2
+
+#define NUMBER_OF_FIRST_INTERFACE 0x00
+#define NUMBER_OF_SECOND_INTERFACE 0x01
+#define NUMBER_OF_THIRD_INTERFACE 0x02
+#define NUMBER_OF_FOURTH_INTERFACE 0x03
+
+#define BULK_SIZE 0x0040
+
+#define ADDRESS_MSC_BULKIN_PIPE 0x85
+#define ADDRESS_MSC_BULKOUT_PIPE 0x06
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+// USB standard device descriptor structure.
+BEGIN_PACK
+typedef struct PACK
+{
+ uint8_t bLength; // Size of this descriptor in bytes
+ uint8_t bDescriptorType; // Descriptor type
+ uint16_t bcdUSB; // USB specification release number in BCD format
+ uint8_t bDeviceClass; // Device class code
+ uint8_t bDeviceSubClass; // Device subclass code
+ uint8_t bDeviceProtocol; // Device protocol code
+ uint8_t bMaxPacketSize0; // Maximum packet size of endpoint 0 (in bytes)
+ uint16_t idVendor; // Vendor ID
+ uint16_t idProduct; // Product ID
+ uint16_t bcdDevice; // Device release number in BCD format
+ uint8_t iManufacturer; // Index of the manufacturer string descriptor
+ uint8_t iProduct; // Index of the product string descriptor
+ uint8_t iSerialNumber; // Index of the serial number string descriptor
+ uint8_t bNumConfigurations; // Number of possible configurations for the device
+} DeviceDescriptor_t;
+
+// USB standard configuration descriptor structure.
+typedef struct PACK
+{
+ uint8_t bLength; // Size of the descriptor in bytes
+ uint8_t bDescriptorType; // Descriptor type
+ uint16_t wTotalLength; // Length of all descriptors returned along with this configuration descriptor
+ uint8_t bNumInterfaces; // Number of interfaces in this configuration
+ uint8_t bConfigurationValue; // Value for selecting this configuration
+ uint8_t iConfiguration; // Index of the configuration string descriptor
+ uint8_t bmAttributes; // Configuration characteristics
+ uint8_t bMaxPower; // Maximum power consumption of the device when in this configuration
+} ConfigurationDescriptor_t;
+
+// USB standard interface descriptor structure.
+typedef struct PACK
+{
+ uint8_t bLength; // Size of the descriptor in bytes
+ uint8_t bDescriptorType; // Descriptor type
+ uint8_t bInterfaceNumber; // Number of the interface in its configuration
+ uint8_t bAlternateSetting; // Value to select this alternate interface setting
+ uint8_t bNumEndpoints; // Number of endpoints used by the interface (excluding endpoint 0)
+ uint8_t bInterfaceClass; // Interface class code
+ uint8_t bInterfaceSubClass; // Interface subclass code
+ uint8_t bInterfaceProtocol; // Interface protocol code
+ uint8_t iInterface; // Index of the interface string descriptor
+} InterfaceDescriptor_t;
+
+// USB header functional descriptor.
+typedef struct PACK
+{
+ uint8_t bFunctionalLength; // Size of the descriptor in bytes
+ uint8_t bDescriptorType; // Descriptor type
+ uint8_t bDescriptorSubtype; // Header functional descriptor subtype
+ uint16_t bcdCDC; // USB Class Definitions for Communication
+ // Devices Specification release number in binary-coded decimal.
+} HeaderFunctionalDescriptor_t;
+
+// USB Abstract Control Management Functional Descriptor.
+typedef struct PACK
+{
+ uint8_t bFunctionalLength; // Size of the descriptor in bytes
+ uint8_t bDescriptorType; // Descriptor type
+ uint8_t bDescriptorSubtype; // ACM descriptor subtype
+ uint8_t bmCapabilities; // The capabilities that this configuration supports
+} AbstractControlManagmentDescriptor_t;
+
+// USB Union Functional Descriptor.
+typedef struct PACK
+{
+ uint8_t bFunctionalLength; // Size of the descriptor in bytes
+ uint8_t bDescriptorType; // Descriptor type
+ uint8_t bDescriptorSubtype; // Union functional descriptor subtype
+ uint8_t bMasterInterface; // The interface number of the Communication or Data Class interface, designated as the master or controlling interface for the union
+ uint8_t bSlaveInterface0; // Interface number of first slave or associated interface in the union
+} UnionFunctionalDescriptor_t;
+
+// USB Call Management Functional Descriptor.
+typedef struct PACK
+{
+ uint8_t bFunctionalLength; // Size of the descriptor in bytes
+ uint8_t bDescriptorType; // Descriptor type
+ uint8_t bDescriptorSubtype; // Union functional descriptor subtype
+ uint8_t bmCapabilities; // The capabilities that this configuration supports
+ uint8_t bDataInterface; // Interface number of Data Class interface optionally used for call management
+} CallManagmentFunctionalDescriptor_t;
+
+// USB Interface Association Descriptor.
+typedef struct PACK
+{
+ uint8_t bLength; // Size of the descriptor in bytes
+ uint8_t bDescriptorType; // Descriptor type
+ uint8_t bFirstInterface; // Interface number of the first interface that is associated with this function
+ uint8_t bInterfaceCount; // Number of contiguous interfaces that are associated with this function
+ uint8_t bFunctionClass; // Class code
+ uint8_t bFunctionSubClass; // Subclass code
+ uint8_t bFunctionProtocol; // Protocol code
+ uint8_t iFunction; // Index of string descriptor describing this function
+} InterfaceAssociationDescriptor_t;
+
+typedef struct PACK
+{
+ uint8_t bLength; // Size of the descriptor in bytes
+ uint8_t bDescriptorType; // Descriptor type
+ uint8_t bmAttributes; // Descriptor attributes
+ uint16_t wDetachTimeOut; // Wait timeout of USB reset after DFU_DETACH request recieption
+ uint16_t wTransferSize; // Maximum number of bytes that the device can accept per control-write transaction
+ uint16_t bcdDFUVersion; // DFU Version
+} DfuFunctionalDescriptor_t;
+
+// USB frame for interface request.
+typedef struct PACK
+{
+ ConfigurationDescriptor_t config;
+#if (APP_INTERFACE == APP_INTERFACE_VCP)
+#if (MSD_SUPPORT == 1) || (DFU_SUPPORT == 1)
+ InterfaceAssociationDescriptor_t cdcIAD;
+#endif // (MSD_SUPPORT == 1) || (DFU_SUPPORT == 1)
+ InterfaceDescriptor_t interface1;
+ HeaderFunctionalDescriptor_t headerFunctional;
+ CallManagmentFunctionalDescriptor_t cmFunctionak;
+ AbstractControlManagmentDescriptor_t acmFunctional;
+ UnionFunctionalDescriptor_t unionFunctional;
+ HAL_UsbEndPointDescptr_t endpointIfc1;
+ InterfaceDescriptor_t interface2;
+ HAL_UsbEndPointDescptr_t endpointIfc2[VCP_INTERFACE_ENDPOINTS_NUMBER];
+#endif // (APP_INTERFACE == APP_INTERFACE_VCP)
+#if (MSD_SUPPORT == 1)
+ InterfaceDescriptor_t interface3;
+ HAL_UsbEndPointDescptr_t endpointIfc3[MSD_INTERFACE_ENDPOINTS_NUMBER];
+#endif // (MSD_SUPPORT == 1)
+#if (DFU_SUPPORT == 1)
+ InterfaceDescriptor_t interface4;
+ DfuFunctionalDescriptor_t dfuFuncional;
+#endif // (MSD_SUPPORT == 1)
+} ConfigurationFrameResponse_t;
+END_PACK
+
+#endif /* _VCPDESCRIPTORS_H */
+// eof usbDescriptors.h \ No newline at end of file
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/drivers/USBClasses/common/include/usbEnumeration.h b/digital/zigbit/bitcloud/stack/Components/HAL/drivers/USBClasses/common/include/usbEnumeration.h
new file mode 100644
index 00000000..8c04756b
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/drivers/USBClasses/common/include/usbEnumeration.h
@@ -0,0 +1,53 @@
+/****************************************************************************//**
+ \file usbEnumeration.h
+
+ \brief Declaration of enumeration process command.
+
+ \author
+ Atmel Corporation: http://www.atmel.com \n
+ Support email: avr@atmel.com
+
+ Copyright (c) 2008-2011, Atmel Corporation. All rights reserved.
+ Licensed under Atmel's Limited License Agreement (BitCloudTM).
+
+ \internal
+ History:
+ 12/09/08 A. Khromykh - Created
+ 26/08/11 N. Fomin - Modified (MSD support)
+*******************************************************************************/
+#ifndef _USBENUMERATION_H
+#define _USBENUMERATION_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <types.h>
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+/******************************************************************************
+Standard usb request handler
+
+Parameters:
+ data - pointer to host's request
+******************************************************************************/
+void runtimeRequestHandler(uint8_t *data);
+
+/******************************************************************************
+Standard usb request handler
+
+Parameters:
+ data - pointer to host's request
+******************************************************************************/
+void usbBusResetAction(void);
+
+#if defined(AT91SAM7X256) || defined(AT91SAM3S4C)
+/******************************************************************************
+send zero-length packet through control pipe
+******************************************************************************/
+void sendZLP(void);
+#endif
+
+#endif /* _USBENUMERATION_H */
+// eof usbEnumeration.h \ No newline at end of file
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/drivers/USBClasses/common/include/usbSetupProcess.h b/digital/zigbit/bitcloud/stack/Components/HAL/drivers/USBClasses/common/include/usbSetupProcess.h
new file mode 100644
index 00000000..f499a80e
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/drivers/USBClasses/common/include/usbSetupProcess.h
@@ -0,0 +1,51 @@
+/****************************************************************************//**
+ \file usbSetupProcess.h
+
+ \brief Declaration of setup (after numeration) process command.
+
+ \author
+ Atmel Corporation: http://www.atmel.com \n
+ Support email: avr@atmel.com
+
+ Copyright (c) 2008-2011, Atmel Corporation. All rights reserved.
+ Licensed under Atmel's Limited License Agreement (BitCloudTM).
+
+ \internal
+ History:
+ 26/08/11 N. Fomin - Created
+*******************************************************************************/
+#ifndef _USBESETUPPROCESS_H
+#define _USBESETUPPROCESS_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <types.h>
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+BEGIN_PACK
+// Usb host request
+typedef struct PACK
+{
+ uint8_t bmRequestType;
+ uint8_t bRequest;
+ uint16_t wValue;
+ uint16_t wIndex;
+ uint16_t wLength;
+} UsbRequest_t;
+END_PACK
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+/******************************************************************************
+Usb setup process request handler
+
+Parameters:
+ data - pointer to host's request
+******************************************************************************/
+void setupProcessRequestHandler(uint8_t *data);
+
+#endif /* _USBESETUPPROCESS_H */
+// eof usbSetupProcess.h \ No newline at end of file
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/drivers/USBClasses/common/src/usbDescriptors.c b/digital/zigbit/bitcloud/stack/Components/HAL/drivers/USBClasses/common/src/usbDescriptors.c
new file mode 100644
index 00000000..663beeee
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/drivers/USBClasses/common/src/usbDescriptors.c
@@ -0,0 +1,424 @@
+/****************************************************************************//**
+ \file usbDescriptors.c
+
+ \brief Virtual communication port descriptors.
+
+ \author
+ Atmel Corporation: http://www.atmel.com \n
+ Support email: avr@atmel.com
+
+ Copyright (c) 2008-2011, Atmel Corporation. All rights reserved.
+ Licensed under Atmel's Limited License Agreement (BitCloudTM).
+
+ \internal
+ History:
+ 11/09/08 A. Khromykh - Created
+ 26/08/11 N. Fomin - Modified (MSD support)
+*******************************************************************************/
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <usbDescriptors.h>
+
+/******************************************************************************
+ Define(s) section
+******************************************************************************/
+// Descriptor's type definitions.
+#define DESCRIPTOR_TYPE_DEVICE 0x01
+#define DESCRIPTOR_TYPE_CONFIGURATION 0x02
+#define DESCRIPTOR_TYPE_STRING 0x03
+#define DESCRIPTOR_TYPE_INTERFACE 0x04
+#define DESCRIPTOR_TYPE_CS_INTERFACE 0x24
+#define DESCRIPTOR_TYPE_ENDPOINT 0x05
+#define DESCRIPTOR_TYPE_DEVICE_QUALIFIER 0x06
+#define DESCRIPTOR_TYPE_OTHER_SPEED_CFG 0x07
+#define DESCRIPTOR_TYPE_INTERFACE_POWER 0x08
+#define DESCRIPTOR_TYPE_INTERFACE_ASSOCIATION 0x0B
+#define DESCRIPTOR_TYPE_DFU_FUNCTIONAL 0x21
+
+// String definitions' indexes.
+#define MANUFACTURER_STRING_INDEX 0
+#define PRODUCT_STRING_INDEX 0
+#define SERIAL_NUMBER_STRING_INDEX 0
+#define CONFIGURATION_STRING_INDEX 0
+#define FIRST_INTERFACE_STRING_INDEX 0
+#define SECOND_INTERFACE_STRING_INDEX 0
+#define THIRD_INTERFACE_STRING_INDEX 0
+#define FOURTH_INTERFACE_STRING_INDEX 0
+
+#define VENDOR_ID 0x03EB // Atmel
+#if (APP_INTERFACE == APP_INTERFACE_VCP)
+ #if (MSD_SUPPORT == 1)
+ #if (DFU_SUPPORT == 1)
+ #define PRODUCT_ID 0x6122
+ #else
+ #define PRODUCT_ID 0x6121
+ #endif // (DFU_SUPPORT == 1)
+ #else // (MSD_SUPPORT == 1)
+ #if (DFU_SUPPORT == 1)
+ #define PRODUCT_ID 0x6120
+ #else
+ #define PRODUCT_ID 0x6119
+ #endif // (DFU_SUPPORT == 1)
+ #endif // (MSD_SUPPORT == 1)
+#else // (APP_INTERFACE == APP_INTERFACE_VCP)
+ #if (MSD_SUPPORT == 1)
+ #if (DFU_SUPPORT == 1)
+ #define PRODUCT_ID 0x6124
+ #else
+ #define PRODUCT_ID 0x6123
+ #endif // (DFU_SUPPORT == 1)
+ #else // (MSD_SUPPORT == 1)
+ #define PRODUCT_ID 0x6119
+ #endif // (MSD_SUPPORT == 1)
+#endif // (APP_INTERFACE == APP_INTERFACE_VCP)
+
+#define DEVICE_RELEASE 0x0001
+#define USB_BUS_RELEASE 0x0200
+
+// Number of possible configurations for the device.
+#define NUMBER_OF_CONFIGURATIONS 0x01
+
+// Class specification parameters of communication device.
+#define CDC_DEVICE_CLASS 0x02
+#define CDC_DEVICE_SUBCLASS 0x00
+#define CDC_DEVICE_PROTOCOL 0x00
+
+// Class specification parameters of mass storage device.
+#define MSC_DEVICE_CLASS 0x00
+#define MSC_DEVICE_SUBCLASS 0x00
+#define MSC_DEVICE_PROTOCOL 0x00
+
+// Class specification parameters of composite device with CDC.
+#define COMB_DEVICE_CLASS 0xef
+#define COMB_DEVICE_SUBCLASS 0x02
+#define COMB_DEVICE_PROTOCOL 0x01
+
+// Endpoint definitions' sizes.
+#if defined(AT91SAM7X256)
+ #define SZ_CONTROL_ENDPOINT 0x08 // endpoint 0 is control pipe
+#elif defined(AT90USB1287) || defined(AT91SAM3S4C)
+ #define SZ_CONTROL_ENDPOINT 0x40 // endpoint 0 is control pipe
+#endif
+#define SZ_ACM_INT_ENDPOINT 0x0008 // endpoint 3 is interrupt pipe for abstraction control model
+#define SZ_CDC_BULKIN_ENDPOINT BULK_SIZE // endpoint 2 is bulk pipe for input communication data
+#define SZ_CDC_BULKOUT_ENDPOINT BULK_SIZE // endpoint 1 is bulk pipe for output communication data
+#define SZ_MSC_BULKIN_ENDPOINT BULK_SIZE // endpoint 2 is bulk pipe for input communication data
+#define SZ_MSC_BULKOUT_ENDPOINT BULK_SIZE // endpoint 1 is bulk pipe for output communication data
+
+// Configuration descriptor parameters.
+// Common size of all descriptors in the vcp configuration besides configuration descriptor
+#define COMMON_VCP_CFG_SIZE (sizeof(InterfaceDescriptor_t) + \
+ sizeof(HeaderFunctionalDescriptor_t) + \
+ sizeof(CallManagmentFunctionalDescriptor_t) + \
+ sizeof(AbstractControlManagmentDescriptor_t) + \
+ sizeof(UnionFunctionalDescriptor_t) + \
+ sizeof(HAL_UsbEndPointDescptr_t) + \
+ sizeof(InterfaceDescriptor_t) + \
+ sizeof(HAL_UsbEndPointDescptr_t) + \
+ sizeof(HAL_UsbEndPointDescptr_t))
+// Common size of all descriptors in the msd configuration besides configuration descriptor
+#define COMMON_MSD_CFG_SIZE (sizeof(InterfaceDescriptor_t) + \
+ sizeof(HAL_UsbEndPointDescptr_t) + \
+ sizeof(HAL_UsbEndPointDescptr_t))
+// Commom size of all descriptors for DFU besides configuration descriptor
+#define COMMON_DFU_CFG_SIZE (sizeof(InterfaceDescriptor_t) + \
+ sizeof(DfuFunctionalDescriptor_t))
+
+#if (APP_INTERFACE == APP_INTERFACE_VCP)
+ #if (MSD_SUPPORT == 1)
+ #if (DFU_SUPPORT == 1)
+ #define CFG_SIZE (COMMON_DFU_CFG_SIZE + COMMON_MSD_CFG_SIZE + COMMON_VCP_CFG_SIZE + sizeof(ConfigurationDescriptor_t) + \
+ sizeof(InterfaceAssociationDescriptor_t))
+ #else // (DFU_SUPPORT == 1)
+ #define CFG_SIZE (COMMON_MSD_CFG_SIZE + COMMON_VCP_CFG_SIZE + sizeof(ConfigurationDescriptor_t) + \
+ sizeof(InterfaceAssociationDescriptor_t))
+ #endif // (DFU_SUPPORT == 1)
+ #else // (MSD_SUPPORT == 1)
+ #if (DFU_SUPPORT == 1)
+ #define CFG_SIZE (COMMON_DFU_CFG_SIZE + COMMON_VCP_CFG_SIZE + sizeof(ConfigurationDescriptor_t) + \
+ sizeof(InterfaceAssociationDescriptor_t))
+ #else // (DFU_SUPPORT == 1)
+ #define CFG_SIZE (COMMON_VCP_CFG_SIZE + sizeof(ConfigurationDescriptor_t))
+ #endif // (DFU_SUPPORT == 1)
+ #endif
+#else // (APP_INTERFACE == APP_INTERFACE_VCP)
+ #if (DFU_SUPPORT == 1)
+ #define CFG_SIZE (COMMON_DFU_CFG_SIZE + COMMON_MSD_CFG_SIZE + sizeof(ConfigurationDescriptor_t))
+ #else // (DFU_SUPPORT == 1)
+ #define CFG_SIZE (COMMON_MSD_CFG_SIZE + sizeof(ConfigurationDescriptor_t))
+ #endif // (DFU_SUPPORT == 1)
+#endif
+
+#if (APP_INTERFACE == APP_INTERFACE_VCP)
+ #if (MSD_SUPPORT == 1)
+ #if (DFU_SUPPORT == 1)
+ #define NUMBER_OF_INTERFACES 0x04
+ #else
+ #define NUMBER_OF_INTERFACES 0x03
+ #endif
+ #else
+ #define NUMBER_OF_INTERFACES 0x02
+ #endif
+#else
+ #if (DFU_SUPPORT == 1)
+ #define NUMBER_OF_INTERFACES 0x02
+ #else
+ #define NUMBER_OF_INTERFACES 0x01
+ #endif
+#endif
+
+#define CFG_SELECTING_VALUE 0x01
+#define CFG_CHARACTERISTICS 0x80 // D7 is reserved and must be set to one for historical reasons.
+#define MAXIMUM_POWER_CONSUMPTION 0x32 // Step is 2 mA.
+
+// Parameters for interfaces descriptors
+#define ALTERNATIVE_SETTING 0x00
+#define NUMBER_USING_ENDPOINTS_FIRST_IFC 0x01
+#define NUMBER_USING_ENDPOINTS_SECOND_IFC 0x02
+#define NUMBER_USING_ENDPOINTS_THIRD_IFC 0x02
+#define NUMBER_USING_ENDPOINTS_FOURTH_IFC 0x00
+#define FIRST_IFC_CLASS 0x02
+#define FIRST_IFC_SUBCLASS 0x02
+#define FIRST_IFC_PROTOCOL 0x00
+#define SECOND_IFC_CLASS 0x0A
+#define SECOND_IFC_SUBCLASS 0x00
+#define SECOND_IFC_PROTOCOL 0x00
+#define THIRD_IFC_CLASS 0x08
+#define THIRD_IFC_SUBCLASS 0x06
+#define THIRD_IFC_PROTOCOL 0x50
+#define FOURTH_IFC_CLASS 0xFE
+#define FOURTH_IFC_SUBCLASS 0x01
+#define FOURTH_IFC_PROTOCOL 0x01
+
+// Header descriptor parameters.
+#define HEADER_SUBTYPE 0x00
+#define CDC_CLASS_DEFINITION 0x0110
+
+// call management functional descriptor parameters.
+#define CALL_MNGMT_SUBTYPE 0x01
+#define CALL_MNGMT_CAPABILITIES 0x01 // See cdc specification.
+#define NUMBER_OF_CALL_MNGMT 0x00
+
+// abstract control management functional descriptor parameters.
+#define ACM_SUBTYPE 0x02
+#define ACM_CAPABILITIES 0x02 // see cdc specification
+
+// Union functional descriptor parameters.
+#define UNION_SUBTYPE 0x06
+#define MASTER_IFC_TYPE 0x00
+#define SLAVE0_IFC_TYPE 0x01
+
+// Endpoints descriptor parameters.
+#define ADDRESS_CDC_INTERRUPT_PIPE 0x83
+#define ADDRESS_CDC_BULKIN_PIPE 0x82
+#define ADDRESS_CDC_BULKOUT_PIPE 0x01
+#define INTERRUPT_TYPE_PIPE 0x03
+#define BULK_TYPE_PIPE 0x02
+#define INTERRUPT_PIPE_POLLING 0x0A // step is 1 ms
+#define BULK_MAX_SPEED 0x00
+
+// dfu functional descriptor parameters
+#define DFU_ATTRIBUTES 0x01
+#define DFU_DETACH_TIMEOUT 0xFFFF
+#define DFU_TRANSFER_SIZE SZ_CONTROL_ENDPOINT
+#define DFU_VERSION 0x0101
+
+/******************************************************************************
+ Constants section
+******************************************************************************/
+const DeviceDescriptor_t deviceDescr = {
+ sizeof(DeviceDescriptor_t), // Size of this descriptor in bytes
+ DESCRIPTOR_TYPE_DEVICE, // Descriptor type
+ USB_BUS_RELEASE, // USB specification release number in BCD format
+#if (APP_INTERFACE == APP_INTERFACE_VCP)
+ #if (MSD_SUPPORT != 1) && (DFU_SUPPORT != 1)
+ CDC_DEVICE_CLASS, // Device class code
+ CDC_DEVICE_SUBCLASS, // Device subclass code
+ CDC_DEVICE_PROTOCOL, // Device protocol code
+ #else // (MSD_SUPPORT != 1) && (DFU_SUPPORT != 1)
+ COMB_DEVICE_CLASS, // Device class code
+ COMB_DEVICE_SUBCLASS, // Device subclass code
+ COMB_DEVICE_PROTOCOL, // Device protocol code
+ #endif // (MSD_SUPPORT != 1) && (DFU_SUPPORT != 1)
+#else // (APP_INTERFACE == APP_INTERFACE_VCP)
+ MSC_DEVICE_CLASS, // Device class code
+ MSC_DEVICE_SUBCLASS, // Device subclass code
+ MSC_DEVICE_PROTOCOL, // Device protocol code
+#endif // (APP_INTERFACE == APP_INTERFACE_VCP)
+ SZ_CONTROL_ENDPOINT, // Maximum packet size of endpoint 0 (in bytes)
+ VENDOR_ID, // Vendor ID
+ PRODUCT_ID, // Product ID
+ DEVICE_RELEASE, // Device release number in BCD format
+ MANUFACTURER_STRING_INDEX, // Index of the manufacturer string descriptor
+ PRODUCT_STRING_INDEX, // Index of the product string descriptor
+ SERIAL_NUMBER_STRING_INDEX, // Index of the serial number string descriptor
+ NUMBER_OF_CONFIGURATIONS // Number of possible configurations for the device
+};
+
+const ConfigurationFrameResponse_t usbConfigDescr = {
+ { // configuration
+ sizeof(ConfigurationDescriptor_t), // Size of the descriptor in bytes
+ DESCRIPTOR_TYPE_CONFIGURATION, // Descriptor type
+ CFG_SIZE, // Length of all descriptors returned along with this configuration descriptor
+ NUMBER_OF_INTERFACES, // Number of interfaces in this configuration
+ CFG_SELECTING_VALUE, // Value for selecting this configuration
+ CONFIGURATION_STRING_INDEX, // Index of the configuration string descriptor
+ CFG_CHARACTERISTICS, // Configuration characteristics
+ MAXIMUM_POWER_CONSUMPTION // Maximum power consumption of the device when in this configuration
+ },
+#if (APP_INTERFACE == APP_INTERFACE_VCP)
+ #if (MSD_SUPPORT == 1) || (DFU_SUPPORT == 1)
+ { // cdcIAD
+ sizeof(InterfaceAssociationDescriptor_t), // Size of this descriptor in bytes
+ DESCRIPTOR_TYPE_INTERFACE_ASSOCIATION, // Descriptor type
+ NUMBER_OF_FIRST_INTERFACE, // Interface number of the first interface that is associated with this function
+ 2, // Number of contiguous interfaces that are associated with this function
+ CDC_DEVICE_CLASS, // Class code
+ CDC_DEVICE_SUBCLASS, // Subclass code
+ CDC_DEVICE_PROTOCOL, // Protocol code
+ FIRST_INTERFACE_STRING_INDEX //Index of string descriptor describing this function
+ },
+ #endif // (MSD_SUPPORT == 1) || (DFU_SUPPORT == 1)
+ { // interface 1
+ sizeof(InterfaceDescriptor_t), // Size of the descriptor in bytes
+ DESCRIPTOR_TYPE_INTERFACE, // Descriptor type
+ NUMBER_OF_FIRST_INTERFACE, // Number of the interface in its configuration
+ ALTERNATIVE_SETTING, // Value to select this alternate interface setting
+ NUMBER_USING_ENDPOINTS_FIRST_IFC, // Number of endpoints used by the interface (excluding endpoint 0)
+ FIRST_IFC_CLASS, // Interface class code
+ FIRST_IFC_SUBCLASS, // Interface subclass code
+ FIRST_IFC_PROTOCOL, // Interface protocol code
+ FIRST_INTERFACE_STRING_INDEX // Index of the interface string descriptor
+ },
+ { // header functional descriptor
+ sizeof(HeaderFunctionalDescriptor_t), // Size of the descriptor in bytes
+ DESCRIPTOR_TYPE_CS_INTERFACE, // Descriptor type
+ HEADER_SUBTYPE, // Header functional descriptor subtype
+ CDC_CLASS_DEFINITION // USB Class Definitions for Communication
+ },
+ { // Call Management Functional Descriptor
+ sizeof(CallManagmentFunctionalDescriptor_t), // Size of the descriptor in bytes
+ DESCRIPTOR_TYPE_CS_INTERFACE, // Descriptor type
+ CALL_MNGMT_SUBTYPE, // bDescriptor subtype: Call Management Func
+ CALL_MNGMT_CAPABILITIES, // bmCapabilities: D1 + D0
+ NUMBER_OF_CALL_MNGMT // bDataInterface: Data Class Interface 1
+ },
+ { // Abstract Control Management Functional Descriptor
+ sizeof(AbstractControlManagmentDescriptor_t), // Size of the descriptor in bytes
+ DESCRIPTOR_TYPE_CS_INTERFACE, // Descriptor type
+ ACM_SUBTYPE, // Abstract Control Management Functional descriptor subtype
+ ACM_CAPABILITIES // bmCapabilities: see cdc specification (support command type)
+ },
+ { // Union Functional Descriptor
+ sizeof(UnionFunctionalDescriptor_t), // Size of the descriptor in bytes
+ DESCRIPTOR_TYPE_CS_INTERFACE, // Descriptor type
+ UNION_SUBTYPE, // Union Functional descriptor subtype
+ MASTER_IFC_TYPE, // bMasterInterface: CDC Interface
+ SLAVE0_IFC_TYPE // bSlaveInterface0: Data Class Interface
+ },
+ { // endpoint 3
+ sizeof(HAL_UsbEndPointDescptr_t), // Size of the descriptor in bytes
+ DESCRIPTOR_TYPE_ENDPOINT, // Descriptor type
+ ADDRESS_CDC_INTERRUPT_PIPE, // Address and direction of the endpoint
+ INTERRUPT_TYPE_PIPE, // Endpoint type and additional characteristics (for isochronous endpoints)
+ SZ_ACM_INT_ENDPOINT, // Maximum packet size (in bytes) of the endpoint
+ INTERRUPT_PIPE_POLLING // Polling rate of the endpoint
+ },
+ { // interface 2
+ sizeof(InterfaceDescriptor_t), // Size of the descriptor in bytes
+ DESCRIPTOR_TYPE_INTERFACE, // Descriptor type
+ NUMBER_OF_SECOND_INTERFACE, // Number of the interface in its configuration
+ ALTERNATIVE_SETTING, // Value to select this alternate interface setting
+ NUMBER_USING_ENDPOINTS_SECOND_IFC, // Number of endpoints used by the interface (excluding endpoint 0)
+ SECOND_IFC_CLASS, // Interface class code
+ SECOND_IFC_SUBCLASS, // Interface subclass code
+ SECOND_IFC_PROTOCOL, // Interface protocol code
+ SECOND_INTERFACE_STRING_INDEX // Index of the interface string descriptor
+ },
+ {{ // endpoint 1
+ sizeof(HAL_UsbEndPointDescptr_t), // Size of the descriptor in bytes
+ DESCRIPTOR_TYPE_ENDPOINT, // Descriptor type
+ ADDRESS_CDC_BULKOUT_PIPE, // Address and direction of the endpoint
+ BULK_TYPE_PIPE, // Endpoint type and additional characteristics (for isochronous endpoints)
+ SZ_CDC_BULKOUT_ENDPOINT, // Maximum packet size (in bytes) of the endpoint
+ BULK_MAX_SPEED // Polling rate of the endpoint
+ },
+ { // endpoint 2
+ sizeof(HAL_UsbEndPointDescptr_t), // Size of the descriptor in bytes
+ DESCRIPTOR_TYPE_ENDPOINT, // Descriptor type
+ ADDRESS_CDC_BULKIN_PIPE, // Address and direction of the endpoint
+ BULK_TYPE_PIPE, // Endpoint type and additional characteristics (for isochronous endpoints)
+ SZ_CDC_BULKIN_ENDPOINT, // Maximum packet size (in bytes) of the endpoint
+ BULK_MAX_SPEED // Polling rate of the endpoint
+ }},
+#endif // (APP_INTERFACE == APP_INTERFACE_VCP)
+#if (MSD_SUPPORT == 1)
+ { // interface 3
+ sizeof(InterfaceDescriptor_t), // Size of the descriptor in bytes
+ DESCRIPTOR_TYPE_INTERFACE, // Descriptor type
+#if (APP_INTERFACE == APP_INTERFACE_VCP)
+ NUMBER_OF_THIRD_INTERFACE, // Number of the interface in its configuration
+#else
+ NUMBER_OF_FIRST_INTERFACE, // Number of the interface in its configuration
+#endif
+ ALTERNATIVE_SETTING, // Value to select this alternate interface setting
+ NUMBER_USING_ENDPOINTS_THIRD_IFC, // Number of endpoints used by the interface (excluding endpoint 0)
+ THIRD_IFC_CLASS, // Interface class code
+ THIRD_IFC_SUBCLASS, // Interface subclass code
+ THIRD_IFC_PROTOCOL, // Interface protocol code
+ THIRD_INTERFACE_STRING_INDEX // Index of the interface string descriptor
+ },
+ {{ // endpoint 6
+ sizeof(HAL_UsbEndPointDescptr_t), // Size of the descriptor in bytes
+ DESCRIPTOR_TYPE_ENDPOINT, // Descriptor type
+ ADDRESS_MSC_BULKOUT_PIPE, // Address and direction of the endpoint
+ BULK_TYPE_PIPE, // Endpoint type and additional characteristics (for isochronous endpoints)
+ SZ_MSC_BULKOUT_ENDPOINT, // Maximum packet size (in bytes) of the endpoint
+ BULK_MAX_SPEED // Polling rate of the endpoint
+ },
+ { // endpoint 5
+ sizeof(HAL_UsbEndPointDescptr_t), // Size of the descriptor in bytes
+ DESCRIPTOR_TYPE_ENDPOINT, // Descriptor type
+ ADDRESS_MSC_BULKIN_PIPE, // Address and direction of the endpoint
+ BULK_TYPE_PIPE, // Endpoint type and additional characteristics (for isochronous endpoints)
+ SZ_MSC_BULKIN_ENDPOINT, // Maximum packet size (in bytes) of the endpoint
+ BULK_MAX_SPEED // Polling rate of the endpoint
+ }},
+#endif // (MSD_SUPPORT == 1)
+#if (DFU_SUPPORT == 1)
+ { // interface 4
+ sizeof(InterfaceDescriptor_t), // Size of the descriptor in bytes
+ DESCRIPTOR_TYPE_INTERFACE, // Descriptor type
+#if (APP_INTERFACE == APP_INTERFACE_VCP)
+ #if (MSD_SUPPORT == 1)
+ NUMBER_OF_FOURTH_INTERFACE, // Number of the interface in its configuration
+ #else
+ NUMBER_OF_THIRD_INTERFACE, // Number of the interface in its configuration
+ #endif // (MSD_SUPPORT == 1)
+#else
+ #if (MSD_SUPPORT == 1)
+ NUMBER_OF_SECOND_INTERFACE, // Number of the interface in its configuration
+ #else
+ #error
+ #endif // (MSD_SUPPORT == 1)
+#endif // (APP_INTERFACE == APP_INTERFACE_VCP)
+ ALTERNATIVE_SETTING, // Value to select this alternate interface setting
+ NUMBER_USING_ENDPOINTS_FOURTH_IFC, // Number of endpoints used by the interface (excluding endpoint 0)
+ FOURTH_IFC_CLASS, // Interface class code
+ FOURTH_IFC_SUBCLASS, // Interface subclass code
+ FOURTH_IFC_PROTOCOL, // Interface protocol code
+ FOURTH_INTERFACE_STRING_INDEX // Index of the interface string descriptor
+ },
+ { // Functional descriptor
+ sizeof(DfuFunctionalDescriptor_t), // Size of the descriptor in bytes
+ DESCRIPTOR_TYPE_DFU_FUNCTIONAL, // Descriptor type
+ DFU_ATTRIBUTES, // Descriptor attributes
+ DFU_DETACH_TIMEOUT, // Wait timeout of USB reset after DFU_DETACH request recieption
+ DFU_TRANSFER_SIZE, // Maximum number of bytes that the device can accept per control-write transaction
+ DFU_VERSION // DFU Version
+ }
+#endif // (DFU_SUPPORT == 1)
+};
+
+// eof usbDescriptors.c
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/drivers/USBClasses/common/src/usbEnumeration.c b/digital/zigbit/bitcloud/stack/Components/HAL/drivers/USBClasses/common/src/usbEnumeration.c
new file mode 100644
index 00000000..f430b08d
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/drivers/USBClasses/common/src/usbEnumeration.c
@@ -0,0 +1,231 @@
+/****************************************************************************//**
+ \file usbEnumeration.c
+
+ \brief Implementation of enumeration proccess.
+
+ \author
+ Atmel Corporation: http://www.atmel.com \n
+ Support email: avr@atmel.com
+
+ Copyright (c) 2008-2011, Atmel Corporation. All rights reserved.
+ Licensed under Atmel's Limited License Agreement (BitCloudTM).
+
+ \internal
+ History:
+ 11/09/08 A. Khromykh - Created
+ 26/08/11 N. Fomin - Modified (MSD support)
+*******************************************************************************/
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <usbDescriptors.h>
+#if (APP_INTERFACE == APP_INTERFACE_VCP)
+ #include <vcpVirtualUsart.h>
+#endif // (APP_INTERFACE == APP_INTERFACE_VCP)
+#if (MSD_SUPPORT == 1)
+ #include <hsmci.h>
+#endif // (MSD_SUPPORT == 1)
+#include <usbSetupProcess.h>
+#include <massStorageDevice.h>
+#include <usbEnumeration.h>
+
+/******************************************************************************
+ Define(s) section
+******************************************************************************/
+// request codes for runtime work
+#define USB_GET_STATUS 0
+#define USB_CLEAR_FEATURE 1
+#define USB_SET_FEATURE 3
+#define USB_SET_ADDRESS 5
+#define USB_GET_DESCRIPTOR 6
+#define USB_SET_DESCRIPTOR 7
+#define USB_GET_CONFIGURATION 8
+#define USB_SET_CONFIGURATION 9
+#define USB_GET_INTERFACE 10
+#define USB_SET_INTERFACE 11
+#define USB_SYNCH_FRAME 12
+
+// Descriptor type definitions.
+#define DESCRIPTOR_TYPE_DEVICE 0x01
+#define DESCRIPTOR_TYPE_CONFIGURATION 0x02
+#define DESCRIPTOR_TYPE_STRING 0x03
+#define DESCRIPTOR_TYPE_INTERFACE 0x04
+#define DESCRIPTOR_TYPE_CS_INTERFACE 0x24
+#define DESCRIPTOR_TYPE_ENDPOINT 0x05
+#define DESCRIPTOR_TYPE_DEVICE_QUALIFIER 0x06
+#define DESCRIPTOR_TYPE_OTHER_SPEED_CFG 0x07
+#define DESCRIPTOR_TYPE_INTERFACE_POWER 0x08
+
+/******************************************************************************
+ External global variables section
+******************************************************************************/
+extern const ConfigurationFrameResponse_t usbConfigDescr;
+extern const DeviceDescriptor_t deviceDescr;
+#if (APP_INTERFACE == APP_INTERFACE_VCP)
+ extern HAL_UsartDescriptor_t *vcpPointDescrip;
+#endif // (APP_INTERFACE == APP_INTERFACE_VCP)
+#if (MSD_SUPPORT == 1)
+ extern HAL_HsmciDescriptor_t *msdPointDescr;
+#endif // (MSD_SUPPORT == 1)
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+/******************************************************************************
+usb bulk out receiving callbacks
+
+Parameters:
+ pArg - argument
+ status - index of the requested descriptor
+ length - maximum number of bytes to return
+******************************************************************************/
+void vcpRcvCallback(void *pArg, uint8_t status, uint16_t transferred, uint16_t remaining);
+void msdRcvCallback(void *pArg, uint8_t status, uint16_t transferred, uint16_t remaining);
+
+/******************************************************************************
+ Global variables section
+******************************************************************************/
+// virtual communication port address on usb
+static uint16_t usbAddress = 0;
+
+/******************************************************************************
+ Implementations section
+******************************************************************************/
+#if defined(AT91SAM7X256) || defined(AT91SAM3S4C)
+/******************************************************************************
+send zero-length packet through control pipe
+******************************************************************************/
+void sendZLP(void)
+{
+ // Acknowledge the request
+ HAL_UsbWrite(0, NULL, 0, NULL, NULL);
+}
+#endif
+
+/******************************************************************************
+Configures the device by setting it into the Configured state.
+
+Parameters:
+ cfgnum - configuration number to set
+******************************************************************************/
+void runtimeSetConfiguration(uint8_t cfgnum)
+{
+ // Set & save the desired configuration
+ HAL_SetConfiguration(cfgnum);
+
+ #if defined(AT91SAM7X256) || defined(AT91SAM3S4C)
+ // Acknowledge the request
+ sendZLP();
+ #endif
+}
+
+/******************************************************************************
+runtime get descriptor command handler
+
+Parameters:
+ type - type of the requested descriptor
+ index - index of the requested descriptor
+ length - maximum number of bytes to return
+******************************************************************************/
+void runtimeGetDescriptorHandler(uint8_t type, uint8_t index, uint16_t length)
+{
+ (void)index;
+
+ // Check the descriptor type
+ switch (type)
+ {
+ case DESCRIPTOR_TYPE_DEVICE:
+ // Adjust length and send descriptor
+ if (length > deviceDescr.bLength)
+ length = deviceDescr.bLength;
+ HAL_UsbWrite(0, (void *)&deviceDescr, length, 0, 0);
+ break;
+ case DESCRIPTOR_TYPE_CONFIGURATION:
+ // Adjust length and send descriptor
+ if (length > usbConfigDescr.config.wTotalLength)
+ length = usbConfigDescr.config.wTotalLength;
+ HAL_UsbWrite(0, (void *)&usbConfigDescr, length, 0, 0);
+ break;
+ case DESCRIPTOR_TYPE_INTERFACE:
+ HAL_Stall(0);
+ break;
+ case DESCRIPTOR_TYPE_DEVICE_QUALIFIER:
+ HAL_Stall(0);
+ break;
+ case DESCRIPTOR_TYPE_OTHER_SPEED_CFG:
+ HAL_Stall(0);
+ break;
+ case DESCRIPTOR_TYPE_ENDPOINT:
+ HAL_Stall(0);
+ break;
+ case DESCRIPTOR_TYPE_STRING:
+ HAL_Stall(0);
+ break;
+ default:
+ HAL_Stall(0);
+ break;
+ }
+}
+
+/******************************************************************************
+Standard usb request handler
+
+Parameters:
+ data - pointer to host's request
+******************************************************************************/
+void runtimeRequestHandler(uint8_t *data)
+{
+ UsbRequest_t *pRequest = NULL;
+
+ pRequest = (UsbRequest_t *)data;
+ if (NULL == pRequest)
+ return;
+
+ // Check request code
+ switch (pRequest->bRequest)
+ {
+ case USB_GET_DESCRIPTOR:
+ // Send the requested descriptor
+ runtimeGetDescriptorHandler((uint8_t)(pRequest->wValue >> 8), (uint8_t)(pRequest->wValue), pRequest->wLength);
+ break;
+ case USB_SET_ADDRESS:
+ usbAddress = pRequest->wValue & 0x7F;
+ #if defined(AT91SAM7X256) || defined(AT91SAM3S4C)
+ HAL_UsbWrite(0, 0, 0, (TransferCallback_t) HAL_SetAddress, (void *)&usbAddress);
+ #elif defined(AT90USB1287)
+ HAL_SetAddress((uint8_t *)&usbAddress);
+ #endif
+ break;
+ case USB_SET_CONFIGURATION:
+ // Set the requested configuration
+ runtimeSetConfiguration((uint8_t)pRequest->wValue);
+ #if (APP_INTERFACE == APP_INTERFACE_VCP)
+ HAL_ConfigureEndpoint((void *)&(usbConfigDescr.endpointIfc1));
+ HAL_ConfigureEndpoint((void *)&(usbConfigDescr.endpointIfc2[0]));
+ HAL_ConfigureEndpoint((void *)&(usbConfigDescr.endpointIfc2[1]));
+ HAL_UsbRead(VCP_RECEIVE_PIPE, vcpPointDescrip->rxBuffer, BULK_SIZE, vcpRcvCallback, NULL);
+ #endif // (APP_INTERFACE == APP_INTERFACE_VCP)
+ #if (MSD_SUPPORT == 1)
+ HAL_ConfigureEndpoint((void *)&(usbConfigDescr.endpointIfc3[0]));
+ HAL_ConfigureEndpoint((void *)&(usbConfigDescr.endpointIfc3[1]));
+ HAL_UsbRead(MSD_RECEIVE_PIPE, msdPointDescr->dataTransferDescriptor->buffer, BULK_SIZE, msdRcvCallback, NULL);
+ #endif // (MSD_SUPPORT == 1)
+ break;
+ default:
+ setupProcessRequestHandler(data);
+ break;
+ }
+}
+
+/******************************************************************************
+Standard usb request handler
+
+Parameters:
+ data - pointer to host's request
+******************************************************************************/
+void usbBusResetAction(void)
+{
+ HAL_RegisterRequestHandler(runtimeRequestHandler);
+}
+
+// eof usbEnumeration.c
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/drivers/USBClasses/common/src/usbSetupProcess.c b/digital/zigbit/bitcloud/stack/Components/HAL/drivers/USBClasses/common/src/usbSetupProcess.c
new file mode 100644
index 00000000..2a3b305e
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/drivers/USBClasses/common/src/usbSetupProcess.c
@@ -0,0 +1,90 @@
+/****************************************************************************//**
+ \file usbSetupProcess.c
+
+ \brief Implementation of setup (after numeration) proccess.
+
+ \author
+ Atmel Corporation: http://www.atmel.com \n
+ Support email: avr@atmel.com
+
+ Copyright (c) 2008-2011, Atmel Corporation. All rights reserved.
+ Licensed under Atmel's Limited License Agreement (BitCloudTM).
+
+ \internal
+ History:
+ 26/08/11 N. Fomin - Created
+*******************************************************************************/
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <usbDescriptors.h>
+#if (APP_INTERFACE == APP_INTERFACE_VCP)
+ #include <vcpCdcProtocol.h>
+ #if (MSD_SUPPORT == 1)
+ #include <mscProtocol.h>
+ #endif // (MSD_SUPPORT == 1)
+#else
+ #if (MSD_SUPPORT == 1)
+ #include <mscProtocol.h>
+ #else
+ #include <usbSetupProcess.h>
+ #endif // (MSD_SUPPORT == 1)
+#endif // (APP_INTERFACE == APP_INTERFACE_VCP)
+#if (DFU_SUPPORT == 1)
+ #include <dfuProtocol.h>
+ #if (APP_INTERFACE != APP_INTERFACE_VCP) && (MSD_SUPPORT != 1)
+ #error
+ #endif // (APP_INTERFACE != APP_INTERFACE_VCP) || (MSD_SUPPORT != 1)
+#endif // (DFU_SUPPORT == 1)
+
+/******************************************************************************
+Usb setup process request handler
+
+Parameters:
+ data - pointer to host's request
+******************************************************************************/
+void setupProcessRequestHandler(uint8_t *data)
+{
+ UsbRequest_t *pRequest = NULL;
+
+ pRequest = (UsbRequest_t *)data;
+ if (NULL == pRequest)
+ return;
+
+ switch (pRequest->wIndex)
+ {
+ #if (APP_INTERFACE == APP_INTERFACE_VCP)
+ case NUMBER_OF_FIRST_INTERFACE:
+ vcpRequestHandler(data);
+ break;
+ #endif // (APP_INTERFACE == APP_INTERFACE_VCP)
+ /* MSC commands */
+ #if (MSD_SUPPORT == 1)
+ #if (APP_INTERFACE == APP_INTERFACE_VCP)
+ case NUMBER_OF_THIRD_INTERFACE:
+ #else
+ case NUMBER_OF_FIRST_INTERFACE:
+ #endif
+ msdRequestHandler(data);
+ break;
+ #endif // (MSD_SUPPORT == 1)
+ #if (DFU_SUPPORT == 1)
+ #if (APP_INTERFACE == APP_INTERFACE_VCP)
+ #if (MSD_SUPPORT == 1)
+ case NUMBER_OF_FOURTH_INTERFACE:
+ #else
+ case NUMBER_OF_THIRD_INTERFACE:
+ #endif
+ #else
+ case NUMBER_OF_SECOND_INTERFACE:
+ #endif // (APP_INTERFACE == APP_INTERFACE_VCP)
+ dfuRequestHandler(data);
+ break;
+ #endif // (DFU_SUPPORT == 1)
+ default:
+ HAL_Stall(0);
+ break;
+ }
+}
+
+// eof usbSetupProcess.c