Update UC3 platform driver support to use the bitmasks defined in the header files...
[pub/USBasp.git] / Demos / Device / LowLevel / AudioOutput / Descriptors.c
index d177c31..0a6ec6d 100644 (file)
@@ -1,13 +1,13 @@
 /*
              LUFA Library
-     Copyright (C) Dean Camera, 2010.
+     Copyright (C) Dean Camera, 2011.
 
   dean [at] fourwalledcubicle [dot] com
-      www.fourwalledcubicle.com
+           www.lufa-lib.org
 */
 
 /*
-  Copyright 2010  Dean Camera (dean [at] fourwalledcubicle [dot] com)
+  Copyright 2011  Dean Camera (dean [at] fourwalledcubicle [dot] com)
 
   Permission to use, copy, modify, distribute, and sell this
   software and its documentation for any purpose is hereby granted
  *  number of device configurations. The descriptor is read out by the USB host when the enumeration
  *  process begins.
  */
-USB_Descriptor_Device_t PROGMEM DeviceDescriptor =
+const USB_Descriptor_Device_t PROGMEM DeviceDescriptor =
 {
        .Header                 = {.Size = sizeof(USB_Descriptor_Device_t), .Type = DTYPE_Device},
 
        .USBSpecification       = VERSION_BCD(01.10),
-       .Class                  = 0x00,
-       .SubClass               = 0x00,
-       .Protocol               = 0x00,
+       .Class                  = USB_CSCP_NoDeviceClass,
+       .SubClass               = USB_CSCP_NoDeviceSubclass,
+       .Protocol               = USB_CSCP_NoDeviceProtocol,
 
        .Endpoint0Size          = FIXED_CONTROL_ENDPOINT_SIZE,
 
        .VendorID               = 0x03EB,
        .ProductID              = 0x2046,
-       .ReleaseNumber          = VERSION_BCD(00.01),
+       .ReleaseNumber          = VERSION_BCD(00.02),
 
        .ManufacturerStrIndex   = 0x01,
        .ProductStrIndex        = 0x02,
@@ -69,7 +69,7 @@ USB_Descriptor_Device_t PROGMEM DeviceDescriptor =
  *  and endpoints. The descriptor is read out by the USB host during the enumeration process when selecting
  *  a configuration so that the host may correctly communicate with the USB device.
  */
-USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
+const USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
 {
        .Config =
                {
@@ -95,9 +95,9 @@ USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
 
                        .TotalEndpoints           = 0,
 
-                       .Class                    = 0x01,
-                       .SubClass                 = 0x01,
-                       .Protocol                 = 0x00,
+                       .Class                    = AUDIO_CSCP_AudioClass,
+                       .SubClass                 = AUDIO_CSCP_ControlSubclass,
+                       .Protocol                 = AUDIO_CSCP_ControlProtocol,
 
                        .InterfaceStrIndex        = NO_DESCRIPTOR
                },
@@ -155,9 +155,9 @@ USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
 
                        .TotalEndpoints           = 0,
 
-                       .Class                    = 0x01,
-                       .SubClass                 = 0x02,
-                       .Protocol                 = 0x00,
+                       .Class                    = AUDIO_CSCP_AudioClass,
+                       .SubClass                 = AUDIO_CSCP_AudioStreamingSubclass,
+                       .Protocol                 = AUDIO_CSCP_StreamingProtocol,
 
                        .InterfaceStrIndex        = NO_DESCRIPTOR
                },
@@ -171,9 +171,9 @@ USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
 
                        .TotalEndpoints           = 1,
 
-                       .Class                    = 0x01,
-                       .SubClass                 = 0x02,
-                       .Protocol                 = 0x00,
+                       .Class                    = AUDIO_CSCP_AudioClass,
+                       .SubClass                 = AUDIO_CSCP_AudioStreamingSubclass,
+                       .Protocol                 = AUDIO_CSCP_StreamingProtocol,
 
                        .InterfaceStrIndex        = NO_DESCRIPTOR
                },
@@ -191,7 +191,9 @@ USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
 
        .Audio_AudioFormat =
                {
-                       .Header                   = {.Size = sizeof(USB_Audio_Descriptor_Format_t), .Type = DTYPE_CSInterface},
+                       .Header                   = {.Size = sizeof(USB_Audio_Descriptor_Format_t) +
+                                                            sizeof(ConfigurationDescriptor.Audio_AudioFormatSampleRates),
+                                                    .Type = DTYPE_CSInterface},
                        .Subtype                  = AUDIO_DSUBTYPE_CSInterface_FormatType,
 
                        .FormatType               = 0x01,
@@ -200,8 +202,16 @@ USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
                        .SubFrameSize             = 0x02,
                        .BitResolution            = 16,
 
-                       .SampleFrequencyType      = AUDIO_TOTAL_SAMPLE_RATES,
-                       .SampleFrequencies        = {AUDIO_SAMPLE_FREQ(AUDIO_SAMPLE_FREQUENCY)}
+                       .TotalDiscreteSampleRates = (sizeof(ConfigurationDescriptor.Audio_AudioFormatSampleRates) / sizeof(USB_Audio_SampleFreq_t)),
+               },
+       
+       .Audio_AudioFormatSampleRates =
+               {
+                       AUDIO_SAMPLE_FREQ(8000),
+                       AUDIO_SAMPLE_FREQ(11025),
+                       AUDIO_SAMPLE_FREQ(22050),
+                       AUDIO_SAMPLE_FREQ(44100),
+                       AUDIO_SAMPLE_FREQ(48000),
                },
 
        .Audio_StreamEndpoint =
@@ -213,7 +223,7 @@ USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
                                        .EndpointAddress     = (ENDPOINT_DESCRIPTOR_DIR_OUT | AUDIO_STREAM_EPNUM),
                                        .Attributes          = (EP_TYPE_ISOCHRONOUS | ENDPOINT_ATTR_SYNC | ENDPOINT_USAGE_DATA),
                                        .EndpointSize        = AUDIO_STREAM_EPSIZE,
-                                       .PollingIntervalMS   = 1
+                                       .PollingIntervalMS   = 0x01
                                },
 
                        .Refresh                  = 0,
@@ -225,7 +235,7 @@ USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
                        .Header                   = {.Size = sizeof(USB_Audio_Descriptor_StreamEndpoint_Spc_t), .Type = DTYPE_CSEndpoint},
                        .Subtype                  = AUDIO_DSUBTYPE_CSEndpoint_General,
 
-                       .Attributes               = AUDIO_EP_ACCEPTS_SMALL_PACKETS,
+                       .Attributes               = (AUDIO_EP_ACCEPTS_SMALL_PACKETS | AUDIO_EP_SAMPLE_FREQ_CONTROL),
 
                        .LockDelayUnits           = 0x00,
                        .LockDelay                = 0x0000
@@ -236,7 +246,7 @@ USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
  *  the string descriptor with index 0 (the first index). It is actually an array of 16-bit integers, which indicate
  *  via the language ID table available at USB.org what languages the device supports for its string descriptors.
  */
-USB_Descriptor_String_t PROGMEM LanguageString =
+const USB_Descriptor_String_t PROGMEM LanguageString =
 {
        .Header                 = {.Size = USB_STRING_LEN(1), .Type = DTYPE_String},
 
@@ -247,7 +257,7 @@ USB_Descriptor_String_t PROGMEM LanguageString =
  *  form, and is read out upon request by the host when the appropriate string ID is requested, listed in the Device
  *  Descriptor.
  */
-USB_Descriptor_String_t PROGMEM ManufacturerString =
+const USB_Descriptor_String_t PROGMEM ManufacturerString =
 {
        .Header                 = {.Size = USB_STRING_LEN(11), .Type = DTYPE_String},
 
@@ -258,7 +268,7 @@ USB_Descriptor_String_t PROGMEM ManufacturerString =
  *  and is read out upon request by the host when the appropriate string ID is requested, listed in the Device
  *  Descriptor.
  */
-USB_Descriptor_String_t PROGMEM ProductString =
+const USB_Descriptor_String_t PROGMEM ProductString =
 {
        .Header                 = {.Size = USB_STRING_LEN(19), .Type = DTYPE_String},