Added CDC functional descriptor structs to the Low Level CDC demos and CDC class...
[pub/USBasp.git] / Demos / Device / ClassDriver / MIDI / Descriptors.c
index 9ce300a..b842bd2 100644 (file)
@@ -104,14 +104,14 @@ USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
        
        .Audio_ControlInterface_SPC = 
                {
-                       .Header                   = {.Size = sizeof(USB_Audio_Interface_AC_t), .Type = DTYPE_AudioInterface},
-                       .Subtype                  = DSUBTYPE_Header,
+                       .Header                   = {.Size = sizeof(USB_Audio_Descriptor_Interface_AC_t), .Type = DTYPE_CSInterface},
+                       .Subtype                  = AUDIO_DSUBTYPE_CSInterface_Header,
                        
                        .ACSpecification          = VERSION_BCD(01.00),
-                       .TotalLength              = sizeof(USB_Audio_Interface_AC_t),
+                       .TotalLength              = sizeof(USB_Audio_Descriptor_Interface_AC_t),
                        
                        .InCollection             = 1,
-                       .InterfaceNumbers         = {1},
+                       .InterfaceNumber          = 1,
                },
 
        .Audio_StreamInterface = 
@@ -132,8 +132,8 @@ USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
                
        .Audio_StreamInterface_SPC = 
                {
-                       .Header                   = {.Size = sizeof(USB_MIDI_AudioInterface_AS_t), .Type = DTYPE_AudioInterface},
-                       .Subtype                  = DSUBTYPE_General,
+                       .Header                   = {.Size = sizeof(USB_MIDI_Descriptor_AudioInterface_AS_t), .Type = DTYPE_CSInterface},
+                       .Subtype                  = AUDIO_DSUBTYPE_CSInterface_General,
 
                        .AudioSpecification       = VERSION_BCD(01.00),
                        
@@ -143,10 +143,10 @@ USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
 
        .MIDI_In_Jack_Emb = 
                {
-                       .Header                   = {.Size = sizeof(USB_MIDI_In_Jack_t), .Type = DTYPE_AudioInterface},
-                       .Subtype                  = DSUBTYPE_InputJack,
+                       .Header                   = {.Size = sizeof(USB_MIDI_Descriptor_InputJack_t), .Type = DTYPE_CSInterface},
+                       .Subtype                  = AUDIO_DSUBTYPE_CSInterface_InputTerminal,
                        
-                       .JackType                 = MIDI_JACKTYPE_EMBEDDED,
+                       .JackType                 = MIDI_JACKTYPE_Embedded,
                        .JackID                   = 0x01,
                        
                        .JackStrIndex             = NO_DESCRIPTOR
@@ -154,10 +154,10 @@ USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
 
        .MIDI_In_Jack_Ext = 
                {
-                       .Header                   = {.Size = sizeof(USB_MIDI_In_Jack_t), .Type = DTYPE_AudioInterface},
-                       .Subtype                  = DSUBTYPE_InputJack,
+                       .Header                   = {.Size = sizeof(USB_MIDI_Descriptor_InputJack_t), .Type = DTYPE_CSInterface},
+                       .Subtype                  = AUDIO_DSUBTYPE_CSInterface_InputTerminal,
                        
-                       .JackType                 = MIDI_JACKTYPE_EXTERNAL,
+                       .JackType                 = MIDI_JACKTYPE_External,
                        .JackID                   = 0x02,
                        
                        .JackStrIndex             = NO_DESCRIPTOR
@@ -165,10 +165,10 @@ USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
                
        .MIDI_Out_Jack_Emb = 
                {
-                       .Header                   = {.Size = sizeof(USB_MIDI_Out_Jack_t), .Type = DTYPE_AudioInterface},
-                       .Subtype                  = DSUBTYPE_OutputJack,
+                       .Header                   = {.Size = sizeof(USB_MIDI_Descriptor_OutputJack_t), .Type = DTYPE_CSInterface},
+                       .Subtype                  = AUDIO_DSUBTYPE_CSInterface_OutputTerminal,
                        
-                       .JackType                 = MIDI_JACKTYPE_EMBEDDED,
+                       .JackType                 = MIDI_JACKTYPE_Embedded,
                        .JackID                   = 0x03,
 
                        .NumberOfPins             = 1,
@@ -180,10 +180,10 @@ USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
 
        .MIDI_Out_Jack_Ext = 
                {
-                       .Header                   = {.Size = sizeof(USB_MIDI_Out_Jack_t), .Type = DTYPE_AudioInterface},
-                       .Subtype                  = DSUBTYPE_OutputJack,
+                       .Header                   = {.Size = sizeof(USB_MIDI_Descriptor_OutputJack_t), .Type = DTYPE_CSInterface},
+                       .Subtype                  = AUDIO_DSUBTYPE_CSInterface_OutputTerminal,
                        
-                       .JackType                 = MIDI_JACKTYPE_EXTERNAL,
+                       .JackType                 = MIDI_JACKTYPE_External,
                        .JackID                   = 0x04,
 
                        .NumberOfPins             = 1,
@@ -197,7 +197,7 @@ USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
                {
                        .Endpoint = 
                                {
-                                       .Header              = {.Size = sizeof(USB_Audio_StreamEndpoint_Std_t), .Type = DTYPE_Endpoint},
+                                       .Header              = {.Size = sizeof(USB_Audio_Descriptor_StreamEndpoint_Std_t), .Type = DTYPE_Endpoint},
 
                                        .EndpointAddress     = (ENDPOINT_DESCRIPTOR_DIR_OUT | MIDI_STREAM_OUT_EPNUM),
                                        .Attributes          = (EP_TYPE_BULK | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
@@ -211,8 +211,8 @@ USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
                
        .MIDI_In_Jack_Endpoint_SPC = 
                {
-                       .Header                   = {.Size = sizeof(USB_MIDI_Jack_Endpoint_t), .Type = DTYPE_AudioEndpoint},
-                       .Subtype                  = DSUBTYPE_General,
+                       .Header                   = {.Size = sizeof(USB_MIDI_Descriptor_Jack_Endpoint_t), .Type = DTYPE_CSEndpoint},
+                       .Subtype                  = AUDIO_DSUBTYPE_CSEndpoint_General,
 
                        .TotalEmbeddedJacks       = 0x01,
                        .AssociatedJackID         = {0x01}
@@ -222,7 +222,7 @@ USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
                {
                        .Endpoint = 
                                {
-                                       .Header              = {.Size = sizeof(USB_Audio_StreamEndpoint_Std_t), .Type = DTYPE_Endpoint},
+                                       .Header              = {.Size = sizeof(USB_Audio_Descriptor_StreamEndpoint_Std_t), .Type = DTYPE_Endpoint},
 
                                        .EndpointAddress     = (ENDPOINT_DESCRIPTOR_DIR_IN | MIDI_STREAM_IN_EPNUM),
                                        .Attributes          = (EP_TYPE_BULK | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
@@ -236,8 +236,8 @@ USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
                
        .MIDI_Out_Jack_Endpoint_SPC = 
                {
-                       .Header                   = {.Size = sizeof(USB_MIDI_Jack_Endpoint_t), .Type = DTYPE_AudioEndpoint},
-                       .Subtype                  = DSUBTYPE_General,
+                       .Header                   = {.Size = sizeof(USB_MIDI_Descriptor_Jack_Endpoint_t), .Type = DTYPE_CSEndpoint},
+                       .Subtype                  = AUDIO_DSUBTYPE_CSEndpoint_General,
 
                        .TotalEmbeddedJacks       = 0x01,
                        .AssociatedJackID         = {0x03}
@@ -285,37 +285,37 @@ USB_Descriptor_String_t PROGMEM ProductString =
  */
 uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue,
                                     const uint8_t wIndex,
-                                    void** const DescriptorAddress)
+                                    const void** const DescriptorAddress)
 {
        const uint8_t  DescriptorType   = (wValue >> 8);
        const uint8_t  DescriptorNumber = (wValue & 0xFF);
 
-       void*    Address = NULL;
-       uint16_t Size    = NO_DESCRIPTOR;
+       const void* Address = NULL;
+       uint16_t    Size    = NO_DESCRIPTOR;
 
        switch (DescriptorType)
        {
                case DTYPE_Device: 
-                       Address = (void*)&DeviceDescriptor;
+                       Address = &DeviceDescriptor;
                        Size    = sizeof(USB_Descriptor_Device_t);
                        break;
                case DTYPE_Configuration: 
-                       Address = (void*)&ConfigurationDescriptor;
+                       Address = &ConfigurationDescriptor;
                        Size    = sizeof(USB_Descriptor_Configuration_t);
                        break;
                case DTYPE_String: 
                        switch (DescriptorNumber)
                        {
                                case 0x00: 
-                                       Address = (void*)&LanguageString;
+                                       Address = &LanguageString;
                                        Size    = pgm_read_byte(&LanguageString.Header.Size);
                                        break;
                                case 0x01: 
-                                       Address = (void*)&ManufacturerString;
+                                       Address = &ManufacturerString;
                                        Size    = pgm_read_byte(&ManufacturerString.Header.Size);
                                        break;
                                case 0x02: 
-                                       Address = (void*)&ProductString;
+                                       Address = &ProductString;
                                        Size    = pgm_read_byte(&ProductString.Header.Size);
                                        break;
                        }