QlightRead Project
|
00001 00037 #include "Descriptors.h" 00038 00044 USB_Descriptor_Device_t PROGMEM DeviceDescriptor = 00045 { 00046 .Header = {.Size = sizeof(USB_Descriptor_Device_t), .Type = DTYPE_Device}, 00047 00048 .USBSpecification = VERSION_BCD(02.00), 00049 .Class = CDC_CSCP_CDCClass, 00050 .SubClass = CDC_CSCP_NoSpecificSubclass, 00051 .Protocol = CDC_CSCP_NoSpecificProtocol, 00052 00053 .Endpoint0Size = FIXED_CONTROL_ENDPOINT_SIZE, 00054 00055 .VendorID = 0x03EB, 00056 .ProductID = 0x0666, 00057 .ReleaseNumber = VERSION_BCD(01.00), 00058 00059 .ManufacturerStrIndex = 0x01, 00060 .ProductStrIndex = 0x02, 00061 .SerialNumStrIndex = USE_INTERNAL_SERIAL, 00062 00063 .NumberOfConfigurations = FIXED_NUM_CONFIGURATIONS 00064 }; 00065 00071 USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor = 00072 { 00073 .Config = 00074 { 00075 .Header = {.Size = sizeof(USB_Descriptor_Configuration_Header_t), .Type = DTYPE_Configuration}, 00076 00077 .TotalConfigurationSize = sizeof(USB_Descriptor_Configuration_t), 00078 .TotalInterfaces = 1, //pamo war vorher 2 00079 00080 .ConfigurationNumber = 1, 00081 .ConfigurationStrIndex = NO_DESCRIPTOR, 00082 00083 .ConfigAttributes = (USB_CONFIG_ATTR_BUSPOWERED | USB_CONFIG_ATTR_SELFPOWERED), 00084 00085 .MaxPowerConsumption = USB_CONFIG_POWER_MA(100) 00086 }, 00087 00088 .CDC_DCI_Interface = 00089 { 00090 .Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface}, 00091 00092 .InterfaceNumber = 0, 00093 .AlternateSetting = 0, 00094 00095 .TotalEndpoints = 2, 00096 00097 .Class = CDC_CSCP_CDCDataClass, 00098 .SubClass = CDC_CSCP_NoDataSubclass, 00099 .Protocol = CDC_CSCP_NoDataProtocol, 00100 00101 .InterfaceStrIndex = NO_DESCRIPTOR 00102 }, 00103 00104 .CDC_DataOutEndpoint = 00105 { 00106 .Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint}, 00107 00108 .EndpointAddress = (ENDPOINT_DESCRIPTOR_DIR_OUT | DATAOUTEP), 00109 .Attributes = (EP_TYPE_BULK | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA), 00110 .EndpointSize = DATAOUTSIZE, 00111 .PollingIntervalMS = 0x01 00112 }, 00113 00114 .CDC_DataInEndpoint = 00115 { 00116 .Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint}, 00117 00118 .EndpointAddress = (ENDPOINT_DESCRIPTOR_DIR_IN | DATAINEP), 00119 .Attributes = (EP_TYPE_BULK | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA), 00120 .EndpointSize = DATAINSIZE, 00121 .PollingIntervalMS = 0x01 00122 } 00123 }; 00124 00129 USB_Descriptor_String_t PROGMEM LanguageString = 00130 { 00131 .Header = {.Size = USB_STRING_LEN(1), .Type = DTYPE_String}, 00132 00133 .UnicodeString = {LANGUAGE_ID_ENG} 00134 }; 00135 00140 USB_Descriptor_String_t PROGMEM ManufacturerString = 00141 { 00142 .Header = {.Size = USB_STRING_LEN(61), .Type = DTYPE_String}, 00143 00144 .UnicodeString = L"Ron Ablinger <trilog_studios@nerdshack.com> QlightRead Harware extension powered by AtmelĀ®" 00145 }; 00146 00151 USB_Descriptor_String_t PROGMEM ProductString = 00152 { 00153 .Header = {.Size = USB_STRING_LEN(17), .Type = DTYPE_String}, 00154 00155 .UnicodeString = L"QlightRead Hardware" 00156 }; 00157 00158 00159 00171 uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, 00172 const uint8_t wIndex, 00173 const void** const DescriptorAddress) 00174 { 00175 const uint8_t DescriptorType = (wValue >> 8); 00176 const uint8_t DescriptorNumber = (wValue & 0xFF); 00177 00178 const void* Address = NULL; 00179 uint16_t Size = NO_DESCRIPTOR; 00180 00181 switch (DescriptorType) 00182 { 00183 case DTYPE_Device: 00184 Address = &DeviceDescriptor; 00185 Size = sizeof(USB_Descriptor_Device_t); 00186 break; 00187 case DTYPE_Configuration: 00188 Address = &ConfigurationDescriptor; 00189 Size = sizeof(USB_Descriptor_Configuration_t); 00190 break; 00191 case DTYPE_String: 00192 switch (DescriptorNumber) 00193 { 00194 case 0x00: 00195 Address = &LanguageString; 00196 Size = pgm_read_byte(&LanguageString.Header.Size); 00197 break; 00198 case 0x01: 00199 Address = &ManufacturerString; 00200 Size = pgm_read_byte(&ManufacturerString.Header.Size); 00201 break; 00202 case 0x02: 00203 Address = &ProductString; 00204 Size = pgm_read_byte(&ProductString.Header.Size); 00205 break; 00206 } 00207 00208 break; 00209 } 00210 00211 *DescriptorAddress = Address; 00212 return Size; 00213 } 00214