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 #include <USBD_Config.h>
00038
00039 #include <CDCMSDDriver.h>
00040 #include <CDCDSerial.h>
00041 #include <MSDFunction.h>
00042
00043
00044
00045
00046
00047
00048
00049
00050 #define CDCMSDDDriverDescriptors_PRODUCTID USBD_PID_CDCMSD
00051
00052 #define CDCMSDDDriverDescriptors_VENDORID USBD_VID_ATMEL
00053
00054 #define CDCMSDDDriverDescriptors_RELEASE USBD_RELEASE_1_00
00055
00056
00057
00058
00059
00060
00061 #define MIN(a, b) ((a < b) ? a : b)
00062
00063
00064
00065
00066
00067
00068 static const USBDeviceDescriptor deviceDescriptor = {
00069
00070 sizeof(USBDeviceDescriptor),
00071 USBGenericDescriptor_DEVICE,
00072 USBDeviceDescriptor_USB2_00,
00073 0xEF,
00074 0x02,
00075 0x01,
00076 CHIP_USB_ENDPOINTS_MAXPACKETSIZE(0),
00077 CDCMSDDDriverDescriptors_VENDORID,
00078 CDCMSDDDriverDescriptors_PRODUCTID,
00079 CDCMSDDDriverDescriptors_RELEASE,
00080 1,
00081 2,
00082 3,
00083 1
00084 };
00085
00086
00087 static const USBDeviceQualifierDescriptor qualifierDescriptor = {
00088
00089 sizeof(USBDeviceQualifierDescriptor),
00090 USBGenericDescriptor_DEVICEQUALIFIER,
00091 USBDeviceDescriptor_USB2_00,
00092 0xEF,
00093 0x02,
00094 0x01,
00095 CHIP_USB_ENDPOINTS_MAXPACKETSIZE(0),
00096 0,
00097 0x00
00098 };
00099
00100
00101
00102 static const CDCMSDDriverConfigurationDescriptors configurationDescriptorsFS =
00103 {
00104
00105
00106 {
00107 sizeof(USBConfigurationDescriptor),
00108 USBGenericDescriptor_CONFIGURATION,
00109 sizeof(CDCMSDDriverConfigurationDescriptors),
00110 CDCMSDDriverDescriptors_NUMINTERFACE,
00111 1,
00112 0,
00113 USBD_BMATTRIBUTES,
00114 USBConfigurationDescriptor_POWER(100)
00115 },
00116
00117
00118
00119 {
00120 sizeof(USBInterfaceAssociationDescriptor),
00121 USBGenericDescriptor_INTERFACEASSOCIATION,
00122 CDCMSDDriverDescriptors_CDC_INTERFACE,
00123 2,
00124 CDCCommunicationInterfaceDescriptor_CLASS,
00125 CDCCommunicationInterfaceDescriptor_ABSTRACTCONTROLMODEL,
00126 CDCCommunicationInterfaceDescriptor_NOPROTOCOL,
00127 0
00128 },
00129
00130 {
00131 sizeof(USBInterfaceDescriptor),
00132 USBGenericDescriptor_INTERFACE,
00133 CDCMSDDriverDescriptors_CDC_INTERFACE,
00134 0,
00135 1,
00136 CDCCommunicationInterfaceDescriptor_CLASS,
00137 CDCCommunicationInterfaceDescriptor_ABSTRACTCONTROLMODEL,
00138 CDCCommunicationInterfaceDescriptor_NOPROTOCOL,
00139 0
00140 },
00141
00142 {
00143 sizeof(CDCHeaderDescriptor),
00144 CDCGenericDescriptor_INTERFACE,
00145 CDCGenericDescriptor_HEADER,
00146 CDCGenericDescriptor_CDC1_10
00147 },
00148
00149 {
00150 sizeof(CDCCallManagementDescriptor),
00151 CDCGenericDescriptor_INTERFACE,
00152 CDCGenericDescriptor_CALLMANAGEMENT,
00153 CDCCallManagementDescriptor_SELFCALLMANAGEMENT,
00154 CDCMSDDriverDescriptors_CDC_INTERFACE + 1
00155 },
00156
00157 {
00158 sizeof(CDCAbstractControlManagementDescriptor),
00159 CDCGenericDescriptor_INTERFACE,
00160 CDCGenericDescriptor_ABSTRACTCONTROLMANAGEMENT,
00161 CDCAbstractControlManagementDescriptor_LINE
00162 },
00163
00164 {
00165 sizeof(CDCUnionDescriptor),
00166 CDCGenericDescriptor_INTERFACE,
00167 CDCGenericDescriptor_UNION,
00168 CDCMSDDriverDescriptors_CDC_INTERFACE,
00169 CDCMSDDriverDescriptors_CDC_INTERFACE + 1
00170 },
00171
00172 {
00173 sizeof(USBEndpointDescriptor),
00174 USBGenericDescriptor_ENDPOINT,
00175 USBEndpointDescriptor_ADDRESS(USBEndpointDescriptor_IN,
00176 CDCD_Descriptors_NOTIFICATION0),
00177 USBEndpointDescriptor_INTERRUPT,
00178 MIN(CHIP_USB_ENDPOINTS_MAXPACKETSIZE(CDCD_Descriptors_NOTIFICATION0),
00179 CDCDSerialPort_INTERRUPT_MAXPACKETSIZE),
00180 CDCDSerialPort_INTERRUPT_INTERVAL_FS
00181 },
00182
00183 {
00184 sizeof(USBInterfaceDescriptor),
00185 USBGenericDescriptor_INTERFACE,
00186 CDCMSDDriverDescriptors_CDC_INTERFACE + 1,
00187 0,
00188 2,
00189 CDCDataInterfaceDescriptor_CLASS,
00190 CDCDataInterfaceDescriptor_SUBCLASS,
00191 CDCDataInterfaceDescriptor_NOPROTOCOL,
00192 0
00193 },
00194
00195 {
00196 sizeof(USBEndpointDescriptor),
00197 USBGenericDescriptor_ENDPOINT,
00198 USBEndpointDescriptor_ADDRESS(USBEndpointDescriptor_OUT,
00199 CDCD_Descriptors_DATAOUT0),
00200 USBEndpointDescriptor_BULK,
00201 MIN(CHIP_USB_ENDPOINTS_MAXPACKETSIZE(CDCD_Descriptors_DATAOUT0),
00202 USBEndpointDescriptor_MAXBULKSIZE_FS),
00203 0
00204 },
00205
00206 {
00207 sizeof(USBEndpointDescriptor),
00208 USBGenericDescriptor_ENDPOINT,
00209 USBEndpointDescriptor_ADDRESS(USBEndpointDescriptor_IN,
00210 CDCD_Descriptors_DATAIN0),
00211 USBEndpointDescriptor_BULK,
00212 MIN(CHIP_USB_ENDPOINTS_MAXPACKETSIZE(CDCD_Descriptors_DATAIN0),
00213 USBEndpointDescriptor_MAXBULKSIZE_FS),
00214 0
00215 },
00216
00217
00218 {
00219 sizeof(USBInterfaceDescriptor),
00220 USBGenericDescriptor_INTERFACE,
00221 CDCMSDDriverDescriptors_MSD_INTERFACE,
00222 0,
00223 2,
00224 MSInterfaceDescriptor_CLASS,
00225 MSInterfaceDescriptor_SCSI,
00226 MSInterfaceDescriptor_BULKONLY,
00227 0
00228 },
00229
00230 {
00231 sizeof(USBEndpointDescriptor),
00232 USBGenericDescriptor_ENDPOINT,
00233 USBEndpointDescriptor_ADDRESS(
00234 USBEndpointDescriptor_OUT,
00235 MSDD_Descriptors_BULKOUT),
00236 USBEndpointDescriptor_BULK,
00237 MIN(CHIP_USB_ENDPOINTS_MAXPACKETSIZE(MSDD_Descriptors_BULKOUT),
00238 USBEndpointDescriptor_MAXBULKSIZE_FS),
00239 0
00240 },
00241
00242 {
00243 sizeof(USBEndpointDescriptor),
00244 USBGenericDescriptor_ENDPOINT,
00245 USBEndpointDescriptor_ADDRESS(
00246 USBEndpointDescriptor_IN,
00247 MSDD_Descriptors_BULKIN),
00248 USBEndpointDescriptor_BULK,
00249 MIN(CHIP_USB_ENDPOINTS_MAXPACKETSIZE(MSDD_Descriptors_BULKIN),
00250 USBEndpointDescriptor_MAXBULKSIZE_FS),
00251 0
00252 }
00253
00254 };
00255
00256
00257
00258 static const CDCMSDDriverConfigurationDescriptors configurationDescriptorsHS =
00259 {
00260
00261
00262 {
00263 sizeof(USBConfigurationDescriptor),
00264 USBGenericDescriptor_CONFIGURATION,
00265 sizeof(CDCMSDDriverConfigurationDescriptors),
00266 CDCMSDDriverDescriptors_NUMINTERFACE,
00267 1,
00268 0,
00269 USBD_BMATTRIBUTES,
00270 USBConfigurationDescriptor_POWER(100)
00271 },
00272
00273
00274
00275 {
00276 sizeof(USBInterfaceAssociationDescriptor),
00277 USBGenericDescriptor_INTERFACEASSOCIATION,
00278 CDCMSDDriverDescriptors_CDC_INTERFACE,
00279 2,
00280 CDCCommunicationInterfaceDescriptor_CLASS,
00281 CDCCommunicationInterfaceDescriptor_ABSTRACTCONTROLMODEL,
00282 CDCCommunicationInterfaceDescriptor_NOPROTOCOL,
00283 0
00284 },
00285
00286 {
00287 sizeof(USBInterfaceDescriptor),
00288 USBGenericDescriptor_INTERFACE,
00289 CDCMSDDriverDescriptors_CDC_INTERFACE,
00290 0,
00291 1,
00292 CDCCommunicationInterfaceDescriptor_CLASS,
00293 CDCCommunicationInterfaceDescriptor_ABSTRACTCONTROLMODEL,
00294 CDCCommunicationInterfaceDescriptor_NOPROTOCOL,
00295 0
00296 },
00297
00298 {
00299 sizeof(CDCHeaderDescriptor),
00300 CDCGenericDescriptor_INTERFACE,
00301 CDCGenericDescriptor_HEADER,
00302 CDCGenericDescriptor_CDC1_10
00303 },
00304
00305 {
00306 sizeof(CDCCallManagementDescriptor),
00307 CDCGenericDescriptor_INTERFACE,
00308 CDCGenericDescriptor_CALLMANAGEMENT,
00309 CDCCallManagementDescriptor_SELFCALLMANAGEMENT,
00310 CDCMSDDriverDescriptors_CDC_INTERFACE + 1
00311 },
00312
00313 {
00314 sizeof(CDCAbstractControlManagementDescriptor),
00315 CDCGenericDescriptor_INTERFACE,
00316 CDCGenericDescriptor_ABSTRACTCONTROLMANAGEMENT,
00317 CDCAbstractControlManagementDescriptor_LINE
00318 },
00319
00320 {
00321 sizeof(CDCUnionDescriptor),
00322 CDCGenericDescriptor_INTERFACE,
00323 CDCGenericDescriptor_UNION,
00324 CDCMSDDriverDescriptors_CDC_INTERFACE,
00325 CDCMSDDriverDescriptors_CDC_INTERFACE + 1
00326 },
00327
00328 {
00329 sizeof(USBEndpointDescriptor),
00330 USBGenericDescriptor_ENDPOINT,
00331 USBEndpointDescriptor_ADDRESS(USBEndpointDescriptor_IN,
00332 CDCD_Descriptors_NOTIFICATION0),
00333 USBEndpointDescriptor_INTERRUPT,
00334 MIN(CHIP_USB_ENDPOINTS_MAXPACKETSIZE(CDCD_Descriptors_NOTIFICATION0),
00335 CDCDSerialPort_INTERRUPT_MAXPACKETSIZE),
00336 CDCDSerialPort_INTERRUPT_INTERVAL_FS
00337 },
00338
00339 {
00340 sizeof(USBInterfaceDescriptor),
00341 USBGenericDescriptor_INTERFACE,
00342 CDCMSDDriverDescriptors_CDC_INTERFACE + 1,
00343 0,
00344 2,
00345 CDCDataInterfaceDescriptor_CLASS,
00346 CDCDataInterfaceDescriptor_SUBCLASS,
00347 CDCDataInterfaceDescriptor_NOPROTOCOL,
00348 0
00349 },
00350
00351 {
00352 sizeof(USBEndpointDescriptor),
00353 USBGenericDescriptor_ENDPOINT,
00354 USBEndpointDescriptor_ADDRESS(USBEndpointDescriptor_OUT,
00355 CDCD_Descriptors_DATAOUT0),
00356 USBEndpointDescriptor_BULK,
00357 MIN(CHIP_USB_ENDPOINTS_MAXPACKETSIZE(CDCD_Descriptors_DATAOUT0),
00358 USBEndpointDescriptor_MAXBULKSIZE_FS),
00359 0
00360 },
00361
00362 {
00363 sizeof(USBEndpointDescriptor),
00364 USBGenericDescriptor_ENDPOINT,
00365 USBEndpointDescriptor_ADDRESS(USBEndpointDescriptor_IN,
00366 CDCD_Descriptors_DATAIN0),
00367 USBEndpointDescriptor_BULK,
00368 MIN(CHIP_USB_ENDPOINTS_MAXPACKETSIZE(CDCD_Descriptors_DATAIN0),
00369 USBEndpointDescriptor_MAXBULKSIZE_FS),
00370 0
00371 },
00372
00373
00374 {
00375 sizeof(USBInterfaceDescriptor),
00376 USBGenericDescriptor_INTERFACE,
00377 CDCMSDDriverDescriptors_MSD_INTERFACE,
00378 0,
00379 2,
00380 MSInterfaceDescriptor_CLASS,
00381 MSInterfaceDescriptor_SCSI,
00382 MSInterfaceDescriptor_BULKONLY,
00383 0
00384 },
00385
00386 {
00387 sizeof(USBEndpointDescriptor),
00388 USBGenericDescriptor_ENDPOINT,
00389 USBEndpointDescriptor_ADDRESS(
00390 USBEndpointDescriptor_OUT,
00391 MSDD_Descriptors_BULKOUT),
00392 USBEndpointDescriptor_BULK,
00393 MIN(CHIP_USB_ENDPOINTS_MAXPACKETSIZE(MSDD_Descriptors_BULKOUT),
00394 USBEndpointDescriptor_MAXBULKSIZE_HS),
00395 0
00396 },
00397
00398 {
00399 sizeof(USBEndpointDescriptor),
00400 USBGenericDescriptor_ENDPOINT,
00401 USBEndpointDescriptor_ADDRESS(
00402 USBEndpointDescriptor_IN,
00403 MSDD_Descriptors_BULKIN),
00404 USBEndpointDescriptor_BULK,
00405 MIN(CHIP_USB_ENDPOINTS_MAXPACKETSIZE(MSDD_Descriptors_BULKIN),
00406 USBEndpointDescriptor_MAXBULKSIZE_HS),
00407 0
00408 }
00409
00410 };
00411
00412 static const unsigned char languageIdDescriptor[] = {
00413
00414 USBStringDescriptor_LENGTH(1),
00415 USBGenericDescriptor_STRING,
00416 USBStringDescriptor_ENGLISH_US
00417 };
00418
00419
00420 static const unsigned char manufacturerDescriptor[] = {
00421
00422 USBStringDescriptor_LENGTH(5),
00423 USBGenericDescriptor_STRING,
00424 USBStringDescriptor_UNICODE('A'),
00425 USBStringDescriptor_UNICODE('t'),
00426 USBStringDescriptor_UNICODE('m'),
00427 USBStringDescriptor_UNICODE('e'),
00428 USBStringDescriptor_UNICODE('l')
00429 };
00430
00431
00432 static const unsigned char productDescriptor[] = {
00433
00434 USBStringDescriptor_LENGTH(14),
00435 USBGenericDescriptor_STRING,
00436 USBStringDescriptor_UNICODE('C'),
00437 USBStringDescriptor_UNICODE('o'),
00438 USBStringDescriptor_UNICODE('m'),
00439 USBStringDescriptor_UNICODE('p'),
00440 USBStringDescriptor_UNICODE('o'),
00441 USBStringDescriptor_UNICODE('s'),
00442 USBStringDescriptor_UNICODE('i'),
00443 USBStringDescriptor_UNICODE('t'),
00444 USBStringDescriptor_UNICODE('e'),
00445 USBStringDescriptor_UNICODE(' '),
00446 USBStringDescriptor_UNICODE('D'),
00447 USBStringDescriptor_UNICODE('e'),
00448 USBStringDescriptor_UNICODE('m'),
00449 USBStringDescriptor_UNICODE('o')
00450 };
00451
00452
00453 static const unsigned char serialNumberDescriptor[] = {
00454
00455 USBStringDescriptor_LENGTH(12),
00456 USBGenericDescriptor_STRING,
00457 USBStringDescriptor_UNICODE('0'),
00458 USBStringDescriptor_UNICODE('1'),
00459 USBStringDescriptor_UNICODE('2'),
00460 USBStringDescriptor_UNICODE('3'),
00461 USBStringDescriptor_UNICODE('4'),
00462 USBStringDescriptor_UNICODE('5'),
00463 USBStringDescriptor_UNICODE('6'),
00464 USBStringDescriptor_UNICODE('7'),
00465 USBStringDescriptor_UNICODE('8'),
00466 USBStringDescriptor_UNICODE('9'),
00467 USBStringDescriptor_UNICODE('A'),
00468 USBStringDescriptor_UNICODE('B')
00469 };
00470
00471
00472 static const unsigned char *stringDescriptors[] = {
00473
00474 languageIdDescriptor,
00475 manufacturerDescriptor,
00476 productDescriptor,
00477 serialNumberDescriptor,
00478 };
00479
00480
00481
00482
00483
00484
00485 const USBDDriverDescriptors cdcmsddDriverDescriptors = {
00486
00487 &deviceDescriptor,
00488 (const USBConfigurationDescriptor *) &configurationDescriptorsFS,
00489 &qualifierDescriptor, 0, 0,
00490 (const USBConfigurationDescriptor *) &configurationDescriptorsHS,
00491 &qualifierDescriptor, 0,
00492 stringDescriptors,
00493 4
00494 };
00495
00496