00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038 #include <USBD_Config.h>
00039
00040
00041 #include <CDCHIDDDriver.h>
00042 #include <CDCDSerial.h>
00043 #include <HIDDKeyboard.h>
00044
00045
00046
00047
00048
00049
00050
00051 #define CDCHIDDDriverDescriptors_PRODUCTID USBD_PID_CDCHID
00052
00053 #define CDCHIDDDriverDescriptors_VENDORID USBD_VID_ATMEL
00054
00055 #define CDCHIDDDriverDescriptors_RELEASE 0x0003
00056
00057
00058
00059
00060
00061
00062 #define MIN(a, b) ((a < b) ? a : b)
00063
00064
00065
00066
00067
00068
00069 static const USBDeviceDescriptor deviceDescriptor = {
00070
00071 sizeof(USBDeviceDescriptor),
00072 USBGenericDescriptor_DEVICE,
00073 USBDeviceDescriptor_USB2_00,
00074 0xEF,
00075 0x02,
00076 0x01,
00077 CHIP_USB_ENDPOINTS_MAXPACKETSIZE(0),
00078 CDCHIDDDriverDescriptors_VENDORID,
00079 CDCHIDDDriverDescriptors_PRODUCTID,
00080 CDCHIDDDriverDescriptors_RELEASE,
00081 0,
00082 1,
00083 0,
00084 1
00085 };
00086
00087
00088
00089 static const USBDeviceQualifierDescriptor qualifierDescriptor = {
00090
00091 sizeof(USBDeviceQualifierDescriptor),
00092 USBGenericDescriptor_DEVICEQUALIFIER,
00093 USBDeviceDescriptor_USB2_00,
00094 0xEF,
00095 0x02,
00096 0x01,
00097 CHIP_USB_ENDPOINTS_MAXPACKETSIZE(0),
00098 0,
00099 0x00
00100 };
00101
00102
00103
00104 static const CdcHidDriverConfigurationDescriptors configurationDescriptorsFS =
00105 {
00106
00107
00108 {
00109 sizeof(USBConfigurationDescriptor),
00110 USBGenericDescriptor_CONFIGURATION,
00111 sizeof(CdcHidDriverConfigurationDescriptors),
00112 CDCHIDDDriverDescriptors_NUMINTERFACE,
00113 1,
00114 0,
00115 USBD_BMATTRIBUTES,
00116 USBConfigurationDescriptor_POWER(100)
00117 },
00118
00119
00120
00121 {
00122 sizeof(USBInterfaceAssociationDescriptor),
00123 USBGenericDescriptor_INTERFACEASSOCIATION,
00124 CDCHIDDDriverDescriptors_CDC_INTERFACE,
00125 2,
00126 CDCCommunicationInterfaceDescriptor_CLASS,
00127 CDCCommunicationInterfaceDescriptor_ABSTRACTCONTROLMODEL,
00128 CDCCommunicationInterfaceDescriptor_NOPROTOCOL,
00129 0
00130 },
00131
00132 {
00133 sizeof(USBInterfaceDescriptor),
00134 USBGenericDescriptor_INTERFACE,
00135 CDCHIDDDriverDescriptors_CDC_INTERFACE,
00136 0,
00137 1,
00138 CDCCommunicationInterfaceDescriptor_CLASS,
00139 CDCCommunicationInterfaceDescriptor_ABSTRACTCONTROLMODEL,
00140 CDCCommunicationInterfaceDescriptor_NOPROTOCOL,
00141 0
00142 },
00143
00144 {
00145 sizeof(CDCHeaderDescriptor),
00146 CDCGenericDescriptor_INTERFACE,
00147 CDCGenericDescriptor_HEADER,
00148 CDCGenericDescriptor_CDC1_10
00149 },
00150
00151 {
00152 sizeof(CDCCallManagementDescriptor),
00153 CDCGenericDescriptor_INTERFACE,
00154 CDCGenericDescriptor_CALLMANAGEMENT,
00155 CDCCallManagementDescriptor_SELFCALLMANAGEMENT,
00156 CDCHIDDDriverDescriptors_CDC_INTERFACE + 1
00157 },
00158
00159 {
00160 sizeof(CDCAbstractControlManagementDescriptor),
00161 CDCGenericDescriptor_INTERFACE,
00162 CDCGenericDescriptor_ABSTRACTCONTROLMANAGEMENT,
00163 CDCAbstractControlManagementDescriptor_LINE
00164 },
00165
00166 {
00167 sizeof(CDCUnionDescriptor),
00168 CDCGenericDescriptor_INTERFACE,
00169 CDCGenericDescriptor_UNION,
00170 CDCHIDDDriverDescriptors_CDC_INTERFACE,
00171 CDCHIDDDriverDescriptors_CDC_INTERFACE + 1
00172 },
00173
00174 {
00175 sizeof(USBEndpointDescriptor),
00176 USBGenericDescriptor_ENDPOINT,
00177 USBEndpointDescriptor_ADDRESS(USBEndpointDescriptor_IN,
00178 CDCD_Descriptors_NOTIFICATION0),
00179 USBEndpointDescriptor_INTERRUPT,
00180 MIN(CHIP_USB_ENDPOINTS_MAXPACKETSIZE(CDCD_Descriptors_NOTIFICATION0),
00181 USBEndpointDescriptor_MAXINTERRUPTSIZE_FS),
00182 CDCDSerialPort_INTERRUPT_INTERVAL_FS
00183 },
00184
00185 {
00186 sizeof(USBInterfaceDescriptor),
00187 USBGenericDescriptor_INTERFACE,
00188 CDCHIDDDriverDescriptors_CDC_INTERFACE + 1,
00189 0,
00190 2,
00191 CDCDataInterfaceDescriptor_CLASS,
00192 CDCDataInterfaceDescriptor_SUBCLASS,
00193 CDCDataInterfaceDescriptor_NOPROTOCOL,
00194 0
00195 },
00196
00197 {
00198 sizeof(USBEndpointDescriptor),
00199 USBGenericDescriptor_ENDPOINT,
00200 USBEndpointDescriptor_ADDRESS(USBEndpointDescriptor_OUT,
00201 CDCD_Descriptors_DATAOUT0),
00202 USBEndpointDescriptor_BULK,
00203 MIN(CHIP_USB_ENDPOINTS_MAXPACKETSIZE(CDCD_Descriptors_DATAOUT0),
00204 USBEndpointDescriptor_MAXBULKSIZE_FS),
00205 0
00206 },
00207
00208 {
00209 sizeof(USBEndpointDescriptor),
00210 USBGenericDescriptor_ENDPOINT,
00211 USBEndpointDescriptor_ADDRESS(USBEndpointDescriptor_IN,
00212 CDCD_Descriptors_DATAIN0),
00213 USBEndpointDescriptor_BULK,
00214 MIN(CHIP_USB_ENDPOINTS_MAXPACKETSIZE(CDCD_Descriptors_DATAIN0),
00215 USBEndpointDescriptor_MAXBULKSIZE_FS),
00216 0
00217 },
00218
00219
00220
00221 {
00222 sizeof(USBInterfaceDescriptor),
00223 USBGenericDescriptor_INTERFACE,
00224 CDCHIDDDriverDescriptors_HID_INTERFACE,
00225 0,
00226 2,
00227 HIDInterfaceDescriptor_CLASS,
00228 HIDInterfaceDescriptor_SUBCLASS_NONE,
00229 HIDInterfaceDescriptor_PROTOCOL_NONE,
00230 0
00231 },
00232
00233 {
00234 sizeof(HIDDescriptor1),
00235 HIDGenericDescriptor_HID,
00236 HIDDescriptor_HID1_11,
00237 0,
00238 1,
00239 HIDGenericDescriptor_REPORT,
00240 {HIDDKeyboard_REPORTDESCRIPTORSIZE}
00241
00242
00243
00244
00245
00246 },
00247
00248 {
00249 sizeof(USBEndpointDescriptor),
00250 USBGenericDescriptor_ENDPOINT,
00251 USBEndpointDescriptor_ADDRESS(
00252 USBEndpointDescriptor_IN,
00253 HIDD_Descriptors_INTERRUPTIN),
00254 USBEndpointDescriptor_INTERRUPT,
00255 sizeof(HIDDKeyboardInputReport),
00256 HIDDKeyboardDescriptors_INTERRUPTIN_POLLING_FS
00257 },
00258
00259 {
00260 sizeof(USBEndpointDescriptor),
00261 USBGenericDescriptor_ENDPOINT,
00262 USBEndpointDescriptor_ADDRESS(
00263 USBEndpointDescriptor_OUT,
00264 HIDD_Descriptors_INTERRUPTOUT),
00265 USBEndpointDescriptor_INTERRUPT,
00266 sizeof(HIDDKeyboardOutputReport),
00267 HIDDKeyboardDescriptors_INTERRUPTOUT_POLLING_FS
00268 }
00269 };
00270
00271
00272 static const unsigned char languageIdDescriptor[] = {
00273
00274 USBStringDescriptor_LENGTH(1),
00275 USBGenericDescriptor_STRING,
00276 USBStringDescriptor_ENGLISH_US
00277 };
00278
00279
00280 static const unsigned char manufacturerDescriptor[] = {
00281
00282 USBStringDescriptor_LENGTH(5),
00283 USBGenericDescriptor_STRING,
00284 USBStringDescriptor_UNICODE('A'),
00285 USBStringDescriptor_UNICODE('t'),
00286 USBStringDescriptor_UNICODE('m'),
00287 USBStringDescriptor_UNICODE('e'),
00288 USBStringDescriptor_UNICODE('l')
00289 };
00290
00291
00292 static const unsigned char productDescriptor[] = {
00293
00294 USBStringDescriptor_LENGTH(14),
00295 USBGenericDescriptor_STRING,
00296 USBStringDescriptor_UNICODE('C'),
00297 USBStringDescriptor_UNICODE('o'),
00298 USBStringDescriptor_UNICODE('m'),
00299 USBStringDescriptor_UNICODE('p'),
00300 USBStringDescriptor_UNICODE('o'),
00301 USBStringDescriptor_UNICODE('s'),
00302 USBStringDescriptor_UNICODE('i'),
00303 USBStringDescriptor_UNICODE('t'),
00304 USBStringDescriptor_UNICODE('e'),
00305 USBStringDescriptor_UNICODE(' '),
00306 USBStringDescriptor_UNICODE('D'),
00307 USBStringDescriptor_UNICODE('e'),
00308 USBStringDescriptor_UNICODE('m'),
00309 USBStringDescriptor_UNICODE('o')
00310 };
00311
00312
00313 static const unsigned char serialNumberDescriptor[] = {
00314
00315 USBStringDescriptor_LENGTH(4),
00316 USBGenericDescriptor_STRING,
00317 USBStringDescriptor_UNICODE('0'),
00318 USBStringDescriptor_UNICODE('1'),
00319 USBStringDescriptor_UNICODE('2'),
00320 USBStringDescriptor_UNICODE('3')
00321 };
00322
00323
00324 static const unsigned char *stringDescriptors[] = {
00325
00326 languageIdDescriptor,
00327 manufacturerDescriptor,
00328 productDescriptor,
00329 serialNumberDescriptor,
00330 };
00331
00332
00333
00334
00335
00336
00337 const USBDDriverDescriptors cdchiddDriverDescriptors = {
00338
00339 &deviceDescriptor,
00340 (const USBConfigurationDescriptor *) &configurationDescriptorsFS,
00341 &qualifierDescriptor,
00342 0, 0, 0,
00343 &qualifierDescriptor, 0,
00344 stringDescriptors,
00345 4
00346 };
00347
00348