Make RNDISHost demo validate the set Packet Filter to ensure that it is being sent...
[pub/USBasp.git] / Demos / Device / ClassDriver / CDC / Descriptors.c
index 03e6882..c8e0a9c 100644 (file)
 \r
 #include "Descriptors.h"\r
 \r
+/* On some devices, there is a factory set internal serial number which can be automatically sent to the host as\r
+ * the device's serial number when the Device Descriptor's .SerialNumStrIndex entry is set to USE_INTERNAL_SERIAL.\r
+ * This allows the host to track a device across insertions on different ports, allowing them to retain allocated\r
+ * resources like COM port numbers and drivers. On demos using this feature, give a warning on unsupported devices\r
+ * so that the user can supply their own serial number descriptor instead or remove the USE_INTERNAL_SERIAL value\r
+ * from the Device Descriptor (forcing the host to generate a serial number for each device from the VID, PID and\r
+ * port location).\r
+ */\r
+#if (USE_INTERNAL_SERIAL == NO_DESCRIPTOR)\r
+       #warning USE_INTERNAL_SERIAL is not available on this AVR - please manually construct a device serial descriptor.\r
+#endif\r
+\r
 /** Device descriptor structure. This descriptor, located in FLASH memory, describes the overall\r
  *  device characteristics, including the supported USB version, control endpoint size and the\r
  *  number of device configurations. The descriptor is read out by the USB host when the enumeration\r
 USB_Descriptor_Device_t PROGMEM DeviceDescriptor =\r
 {\r
        .Header                 = {.Size = sizeof(USB_Descriptor_Device_t), .Type = DTYPE_Device},\r
-               \r
+\r
        .USBSpecification       = VERSION_BCD(01.10),\r
        .Class                  = 0x02,\r
        .SubClass               = 0x00,\r
        .Protocol               = 0x00,\r
-                               \r
+\r
        .Endpoint0Size          = FIXED_CONTROL_ENDPOINT_SIZE,\r
-               \r
+\r
        .VendorID               = 0x03EB,\r
        .ProductID              = 0x2044,\r
        .ReleaseNumber          = 0x0000,\r
-               \r
+\r
        .ManufacturerStrIndex   = 0x01,\r
        .ProductStrIndex        = 0x02,\r
-       .SerialNumStrIndex      = NO_DESCRIPTOR,\r
-               \r
-       .NumberOfConfigurations = 1\r
+       .SerialNumStrIndex      = USE_INTERNAL_SERIAL,\r
+\r
+       .NumberOfConfigurations = FIXED_NUM_CONFIGURATIONS\r
 };\r
 \r
 /** Configuration descriptor structure. This descriptor, located in FLASH memory, describes the usage\r
@@ -77,10 +89,10 @@ USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
 \r
                        .TotalConfigurationSize = sizeof(USB_Descriptor_Configuration_t),\r
                        .TotalInterfaces        = 2,\r
-                               \r
+                       \r
                        .ConfigurationNumber    = 1,\r
                        .ConfigurationStrIndex  = NO_DESCRIPTOR,\r
-                               \r
+                       \r
                        .ConfigAttributes       = (USB_CONFIG_ATTR_BUSPOWERED | USB_CONFIG_ATTR_SELFPOWERED),\r
                        \r
                        .MaxPowerConsumption    = USB_CONFIG_POWER_MA(100)\r
@@ -94,11 +106,11 @@ USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
                        .AlternateSetting       = 0,\r
                        \r
                        .TotalEndpoints         = 1,\r
-                               \r
+                       \r
                        .Class                  = 0x02,\r
                        .SubClass               = 0x02,\r
                        .Protocol               = 0x01,\r
-                               \r
+                       \r
                        .InterfaceStrIndex      = NO_DESCRIPTOR\r
                },\r
 \r
@@ -137,9 +149,9 @@ USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
        .ManagementEndpoint = \r
                {\r
                        .Header                 = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},\r
-                                                                                \r
+                       \r
                        .EndpointAddress        = (ENDPOINT_DESCRIPTOR_DIR_IN | CDC_NOTIFICATION_EPNUM),\r
-                       .Attributes             = EP_TYPE_INTERRUPT,\r
+                       .Attributes             = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),\r
                        .EndpointSize           = CDC_NOTIFICATION_EPSIZE,\r
                        .PollingIntervalMS      = 0xFF\r
                },\r
@@ -163,9 +175,9 @@ USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
        .DataOutEndpoint = \r
                {\r
                        .Header                 = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},\r
-                                                                                \r
+                       \r
                        .EndpointAddress        = (ENDPOINT_DESCRIPTOR_DIR_OUT | CDC_RX_EPNUM),\r
-                       .Attributes             = EP_TYPE_BULK,\r
+                       .Attributes             = (EP_TYPE_BULK | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),\r
                        .EndpointSize           = CDC_TXRX_EPSIZE,\r
                        .PollingIntervalMS      = 0x00\r
                },\r
@@ -173,9 +185,9 @@ USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
        .DataInEndpoint = \r
                {\r
                        .Header                 = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},\r
-                                                                                \r
+                       \r
                        .EndpointAddress        = (ENDPOINT_DESCRIPTOR_DIR_IN | CDC_TX_EPNUM),\r
-                       .Attributes             = EP_TYPE_BULK,\r
+                       .Attributes             = (EP_TYPE_BULK | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),\r
                        .EndpointSize           = CDC_TXRX_EPSIZE,\r
                        .PollingIntervalMS      = 0x00\r
                }\r
@@ -188,7 +200,7 @@ USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
 USB_Descriptor_String_t PROGMEM LanguageString =\r
 {\r
        .Header                 = {.Size = USB_STRING_LEN(1), .Type = DTYPE_String},\r
-               \r
+\r
        .UnicodeString          = {LANGUAGE_ID_ENG}\r
 };\r
 \r
@@ -199,7 +211,7 @@ USB_Descriptor_String_t PROGMEM LanguageString =
 USB_Descriptor_String_t PROGMEM ManufacturerString =\r
 {\r
        .Header                 = {.Size = USB_STRING_LEN(11), .Type = DTYPE_String},\r
-               \r
+\r
        .UnicodeString          = L"Dean Camera"\r
 };\r
 \r
@@ -210,7 +222,7 @@ USB_Descriptor_String_t PROGMEM ManufacturerString =
 USB_Descriptor_String_t PROGMEM ProductString =\r
 {\r
        .Header                 = {.Size = USB_STRING_LEN(13), .Type = DTYPE_String},\r
-               \r
+\r
        .UnicodeString          = L"LUFA CDC Demo"\r
 };\r
 \r
@@ -258,6 +270,6 @@ uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, const uint8_t wIndex,
                        break;\r
        }\r
        \r
-       *DescriptorAddress = Address;           \r
+       *DescriptorAddress = Address;\r
        return Size;\r
 }\r