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