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
00039
00040 #include "board.h"
00041 #include "USBD_Config.h"
00042 #include "CDCDSerialDriver.h"
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059 #define CDCDSerialDriverDescriptors_PRODUCTID USBD_PID_CDCDSERIAL
00060
00061 #define CDCDSerialDriverDescriptors_VENDORID USBD_VID_ATMEL
00062
00063 #define CDCDSerialDriverDescriptors_RELEASE USBD_RELEASE_1_00
00064
00065
00066
00067
00068
00069
00070
00071 #define MIN(a, b) ((a < b) ? a : b)
00072
00073
00074
00075
00076
00077
00078 const USBDeviceDescriptor deviceDescriptor = {
00079
00080 sizeof(USBDeviceDescriptor),
00081 USBGenericDescriptor_DEVICE,
00082 USBDeviceDescriptor_USB2_00,
00083 CDCDeviceDescriptor_CLASS,
00084 CDCDeviceDescriptor_SUBCLASS,
00085 CDCDeviceDescriptor_PROTOCOL,
00086 CHIP_USB_ENDPOINTS_MAXPACKETSIZE(0),
00087 CDCDSerialDriverDescriptors_VENDORID,
00088 CDCDSerialDriverDescriptors_PRODUCTID,
00089 CDCDSerialDriverDescriptors_RELEASE,
00090 0,
00091 1,
00092 0,
00093 1
00094 };
00095
00096
00097
00098 static const USBDeviceQualifierDescriptor qualifierDescriptor = {
00099
00100 sizeof(USBDeviceQualifierDescriptor),
00101 USBGenericDescriptor_DEVICEQUALIFIER,
00102 USBDeviceDescriptor_USB2_00,
00103 CDCDeviceDescriptor_CLASS,
00104 CDCDeviceDescriptor_SUBCLASS,
00105 CDCDeviceDescriptor_PROTOCOL,
00106 CHIP_USB_ENDPOINTS_MAXPACKETSIZE(0),
00107 1,
00108 0x00
00109 };
00110
00111 const CDCDSerialDriverConfigurationDescriptors configurationDescriptorsFS = {
00112
00113
00114 {
00115 sizeof(USBConfigurationDescriptor),
00116 USBGenericDescriptor_CONFIGURATION,
00117 sizeof(CDCDSerialDriverConfigurationDescriptors),
00118 2,
00119 1,
00120 0,
00121 USBD_BMATTRIBUTES,
00122 USBConfigurationDescriptor_POWER(100)
00123 },
00124
00125 {
00126 sizeof(USBInterfaceDescriptor),
00127 USBGenericDescriptor_INTERFACE,
00128 0,
00129 0,
00130 1,
00131 CDCCommunicationInterfaceDescriptor_CLASS,
00132 CDCCommunicationInterfaceDescriptor_ABSTRACTCONTROLMODEL,
00133 CDCCommunicationInterfaceDescriptor_NOPROTOCOL,
00134 0
00135 },
00136
00137 {
00138 sizeof(CDCHeaderDescriptor),
00139 CDCGenericDescriptor_INTERFACE,
00140 CDCGenericDescriptor_HEADER,
00141 CDCGenericDescriptor_CDC1_10
00142 },
00143
00144 {
00145 sizeof(CDCCallManagementDescriptor),
00146 CDCGenericDescriptor_INTERFACE,
00147 CDCGenericDescriptor_CALLMANAGEMENT,
00148 CDCCallManagementDescriptor_SELFCALLMANAGEMENT,
00149 0
00150 },
00151
00152 {
00153 sizeof(CDCAbstractControlManagementDescriptor),
00154 CDCGenericDescriptor_INTERFACE,
00155 CDCGenericDescriptor_ABSTRACTCONTROLMANAGEMENT,
00156 CDCAbstractControlManagementDescriptor_LINE
00157 },
00158
00159 {
00160 sizeof(CDCUnionDescriptor),
00161 CDCGenericDescriptor_INTERFACE,
00162 CDCGenericDescriptor_UNION,
00163 0,
00164 1
00165 },
00166
00167 {
00168 sizeof(USBEndpointDescriptor),
00169 USBGenericDescriptor_ENDPOINT,
00170 USBEndpointDescriptor_ADDRESS(USBEndpointDescriptor_IN,
00171 CDCDSerialDriverDescriptors_NOTIFICATION),
00172 USBEndpointDescriptor_INTERRUPT,
00173 MIN(CHIP_USB_ENDPOINTS_MAXPACKETSIZE(CDCDSerialDriverDescriptors_NOTIFICATION),
00174 USBEndpointDescriptor_MAXINTERRUPTSIZE_FS),
00175 10
00176 },
00177
00178 {
00179 sizeof(USBInterfaceDescriptor),
00180 USBGenericDescriptor_INTERFACE,
00181 1,
00182 0,
00183 2,
00184 CDCDataInterfaceDescriptor_CLASS,
00185 CDCDataInterfaceDescriptor_SUBCLASS,
00186 CDCDataInterfaceDescriptor_NOPROTOCOL,
00187 0
00188 },
00189
00190 {
00191 sizeof(USBEndpointDescriptor),
00192 USBGenericDescriptor_ENDPOINT,
00193 USBEndpointDescriptor_ADDRESS(USBEndpointDescriptor_OUT,
00194 CDCDSerialDriverDescriptors_DATAOUT),
00195 USBEndpointDescriptor_BULK,
00196 MIN(CHIP_USB_ENDPOINTS_MAXPACKETSIZE(CDCDSerialDriverDescriptors_DATAOUT),
00197 USBEndpointDescriptor_MAXBULKSIZE_FS),
00198 0
00199 },
00200
00201 {
00202 sizeof(USBEndpointDescriptor),
00203 USBGenericDescriptor_ENDPOINT,
00204 USBEndpointDescriptor_ADDRESS(USBEndpointDescriptor_IN,
00205 CDCDSerialDriverDescriptors_DATAIN),
00206 USBEndpointDescriptor_BULK,
00207 MIN(CHIP_USB_ENDPOINTS_MAXPACKETSIZE(CDCDSerialDriverDescriptors_DATAIN),
00208 USBEndpointDescriptor_MAXBULKSIZE_FS),
00209 0
00210 }
00211 };
00212
00213
00214 const CDCDSerialDriverConfigurationDescriptors otherSpeedDescriptorsFS = {
00215
00216
00217 {
00218 sizeof(USBConfigurationDescriptor),
00219 USBGenericDescriptor_OTHERSPEEDCONFIGURATION,
00220 sizeof(CDCDSerialDriverConfigurationDescriptors),
00221 2,
00222 1,
00223 0,
00224 BOARD_USB_BMATTRIBUTES,
00225 USBConfigurationDescriptor_POWER(100)
00226 },
00227
00228 {
00229 sizeof(USBInterfaceDescriptor),
00230 USBGenericDescriptor_INTERFACE,
00231 0,
00232 0,
00233 1,
00234 CDCCommunicationInterfaceDescriptor_CLASS,
00235 CDCCommunicationInterfaceDescriptor_ABSTRACTCONTROLMODEL,
00236 CDCCommunicationInterfaceDescriptor_NOPROTOCOL,
00237 0
00238 },
00239
00240 {
00241 sizeof(CDCHeaderDescriptor),
00242 CDCGenericDescriptor_INTERFACE,
00243 CDCGenericDescriptor_HEADER,
00244 CDCGenericDescriptor_CDC1_10
00245 },
00246
00247 {
00248 sizeof(CDCCallManagementDescriptor),
00249 CDCGenericDescriptor_INTERFACE,
00250 CDCGenericDescriptor_CALLMANAGEMENT,
00251 CDCCallManagementDescriptor_SELFCALLMANAGEMENT,
00252 0
00253 },
00254
00255 {
00256 sizeof(CDCAbstractControlManagementDescriptor),
00257 CDCGenericDescriptor_INTERFACE,
00258 CDCGenericDescriptor_ABSTRACTCONTROLMANAGEMENT,
00259 CDCAbstractControlManagementDescriptor_LINE
00260 },
00261
00262 {
00263 sizeof(CDCUnionDescriptor),
00264 CDCGenericDescriptor_INTERFACE,
00265 CDCGenericDescriptor_UNION,
00266 0,
00267 1
00268 },
00269
00270 {
00271 sizeof(USBEndpointDescriptor),
00272 USBGenericDescriptor_ENDPOINT,
00273 USBEndpointDescriptor_ADDRESS(USBEndpointDescriptor_IN,
00274 CDCDSerialDriverDescriptors_NOTIFICATION),
00275 USBEndpointDescriptor_INTERRUPT,
00276 MIN(CHIP_USB_ENDPOINTS_MAXPACKETSIZE(CDCDSerialDriverDescriptors_NOTIFICATION),
00277 USBEndpointDescriptor_MAXINTERRUPTSIZE_FS),
00278 8
00279 },
00280
00281 {
00282 sizeof(USBInterfaceDescriptor),
00283 USBGenericDescriptor_INTERFACE,
00284 1,
00285 0,
00286 2,
00287 CDCDataInterfaceDescriptor_CLASS,
00288 CDCDataInterfaceDescriptor_SUBCLASS,
00289 CDCDataInterfaceDescriptor_NOPROTOCOL,
00290 0
00291 },
00292
00293 {
00294 sizeof(USBEndpointDescriptor),
00295 USBGenericDescriptor_ENDPOINT,
00296 USBEndpointDescriptor_ADDRESS(USBEndpointDescriptor_OUT,
00297 CDCDSerialDriverDescriptors_DATAOUT),
00298 USBEndpointDescriptor_BULK,
00299 MIN(CHIP_USB_ENDPOINTS_MAXPACKETSIZE(CDCDSerialDriverDescriptors_DATAOUT),
00300 USBEndpointDescriptor_MAXBULKSIZE_HS),
00301 0
00302 },
00303
00304 {
00305 sizeof(USBEndpointDescriptor),
00306 USBGenericDescriptor_ENDPOINT,
00307 USBEndpointDescriptor_ADDRESS(USBEndpointDescriptor_IN,
00308 CDCDSerialDriverDescriptors_DATAIN),
00309 USBEndpointDescriptor_BULK,
00310 MIN(CHIP_USB_ENDPOINTS_MAXPACKETSIZE(CDCDSerialDriverDescriptors_DATAIN),
00311 USBEndpointDescriptor_MAXBULKSIZE_HS),
00312 0
00313 }
00314 };
00315
00316
00317 const CDCDSerialDriverConfigurationDescriptors configurationDescriptorsHS = {
00318
00319
00320 {
00321 sizeof(USBConfigurationDescriptor),
00322 USBGenericDescriptor_CONFIGURATION,
00323 sizeof(CDCDSerialDriverConfigurationDescriptors),
00324 2,
00325 1,
00326 0,
00327 BOARD_USB_BMATTRIBUTES,
00328 USBConfigurationDescriptor_POWER(100)
00329 },
00330
00331 {
00332 sizeof(USBInterfaceDescriptor),
00333 USBGenericDescriptor_INTERFACE,
00334 0,
00335 0,
00336 1,
00337 CDCCommunicationInterfaceDescriptor_CLASS,
00338 CDCCommunicationInterfaceDescriptor_ABSTRACTCONTROLMODEL,
00339 CDCCommunicationInterfaceDescriptor_NOPROTOCOL,
00340 0
00341 },
00342
00343 {
00344 sizeof(CDCHeaderDescriptor),
00345 CDCGenericDescriptor_INTERFACE,
00346 CDCGenericDescriptor_HEADER,
00347 CDCGenericDescriptor_CDC1_10
00348 },
00349
00350 {
00351 sizeof(CDCCallManagementDescriptor),
00352 CDCGenericDescriptor_INTERFACE,
00353 CDCGenericDescriptor_CALLMANAGEMENT,
00354 CDCCallManagementDescriptor_SELFCALLMANAGEMENT,
00355 0
00356 },
00357
00358 {
00359 sizeof(CDCAbstractControlManagementDescriptor),
00360 CDCGenericDescriptor_INTERFACE,
00361 CDCGenericDescriptor_ABSTRACTCONTROLMANAGEMENT,
00362 CDCAbstractControlManagementDescriptor_LINE
00363 },
00364
00365 {
00366 sizeof(CDCUnionDescriptor),
00367 CDCGenericDescriptor_INTERFACE,
00368 CDCGenericDescriptor_UNION,
00369 0,
00370 1
00371 },
00372
00373 {
00374 sizeof(USBEndpointDescriptor),
00375 USBGenericDescriptor_ENDPOINT,
00376 USBEndpointDescriptor_ADDRESS(USBEndpointDescriptor_IN,
00377 CDCDSerialDriverDescriptors_NOTIFICATION),
00378 USBEndpointDescriptor_INTERRUPT,
00379 MIN(CHIP_USB_ENDPOINTS_MAXPACKETSIZE(CDCDSerialDriverDescriptors_NOTIFICATION),
00380 USBEndpointDescriptor_MAXINTERRUPTSIZE_FS),
00381 8
00382 },
00383
00384 {
00385 sizeof(USBInterfaceDescriptor),
00386 USBGenericDescriptor_INTERFACE,
00387 1,
00388 0,
00389 2,
00390 CDCDataInterfaceDescriptor_CLASS,
00391 CDCDataInterfaceDescriptor_SUBCLASS,
00392 CDCDataInterfaceDescriptor_NOPROTOCOL,
00393 0
00394 },
00395
00396 {
00397 sizeof(USBEndpointDescriptor),
00398 USBGenericDescriptor_ENDPOINT,
00399 USBEndpointDescriptor_ADDRESS(USBEndpointDescriptor_OUT,
00400 CDCDSerialDriverDescriptors_DATAOUT),
00401 USBEndpointDescriptor_BULK,
00402 MIN(CHIP_USB_ENDPOINTS_MAXPACKETSIZE(CDCDSerialDriverDescriptors_DATAOUT),
00403 USBEndpointDescriptor_MAXBULKSIZE_HS),
00404 0
00405 },
00406
00407 {
00408 sizeof(USBEndpointDescriptor),
00409 USBGenericDescriptor_ENDPOINT,
00410 USBEndpointDescriptor_ADDRESS(USBEndpointDescriptor_IN,
00411 CDCDSerialDriverDescriptors_DATAIN),
00412 USBEndpointDescriptor_BULK,
00413 MIN(CHIP_USB_ENDPOINTS_MAXPACKETSIZE(CDCDSerialDriverDescriptors_DATAIN),
00414 USBEndpointDescriptor_MAXBULKSIZE_HS),
00415 0
00416 }
00417 };
00418
00419
00420 const CDCDSerialDriverConfigurationDescriptors otherSpeedDescriptorsHS = {
00421
00422
00423 {
00424 sizeof(USBConfigurationDescriptor),
00425 USBGenericDescriptor_OTHERSPEEDCONFIGURATION,
00426 sizeof(CDCDSerialDriverConfigurationDescriptors),
00427 2,
00428 1,
00429 0,
00430 BOARD_USB_BMATTRIBUTES,
00431 USBConfigurationDescriptor_POWER(100)
00432 },
00433
00434 {
00435 sizeof(USBInterfaceDescriptor),
00436 USBGenericDescriptor_INTERFACE,
00437 0,
00438 0,
00439 1,
00440 CDCCommunicationInterfaceDescriptor_CLASS,
00441 CDCCommunicationInterfaceDescriptor_ABSTRACTCONTROLMODEL,
00442 CDCCommunicationInterfaceDescriptor_NOPROTOCOL,
00443 0
00444 },
00445
00446 {
00447 sizeof(CDCHeaderDescriptor),
00448 CDCGenericDescriptor_INTERFACE,
00449 CDCGenericDescriptor_HEADER,
00450 CDCGenericDescriptor_CDC1_10
00451 },
00452
00453 {
00454 sizeof(CDCCallManagementDescriptor),
00455 CDCGenericDescriptor_INTERFACE,
00456 CDCGenericDescriptor_CALLMANAGEMENT,
00457 CDCCallManagementDescriptor_SELFCALLMANAGEMENT,
00458 0
00459 },
00460
00461 {
00462 sizeof(CDCAbstractControlManagementDescriptor),
00463 CDCGenericDescriptor_INTERFACE,
00464 CDCGenericDescriptor_ABSTRACTCONTROLMANAGEMENT,
00465 CDCAbstractControlManagementDescriptor_LINE
00466 },
00467
00468 {
00469 sizeof(CDCUnionDescriptor),
00470 CDCGenericDescriptor_INTERFACE,
00471 CDCGenericDescriptor_UNION,
00472 0,
00473 1
00474 },
00475
00476 {
00477 sizeof(USBEndpointDescriptor),
00478 USBGenericDescriptor_ENDPOINT,
00479 USBEndpointDescriptor_ADDRESS(USBEndpointDescriptor_IN,
00480 CDCDSerialDriverDescriptors_NOTIFICATION),
00481 USBEndpointDescriptor_INTERRUPT,
00482 MIN(CHIP_USB_ENDPOINTS_MAXPACKETSIZE(CDCDSerialDriverDescriptors_NOTIFICATION),
00483 USBEndpointDescriptor_MAXINTERRUPTSIZE_FS),
00484 10
00485 },
00486
00487 {
00488 sizeof(USBInterfaceDescriptor),
00489 USBGenericDescriptor_INTERFACE,
00490 1,
00491 0,
00492 2,
00493 CDCDataInterfaceDescriptor_CLASS,
00494 CDCDataInterfaceDescriptor_SUBCLASS,
00495 CDCDataInterfaceDescriptor_NOPROTOCOL,
00496 0
00497 },
00498
00499 {
00500 sizeof(USBEndpointDescriptor),
00501 USBGenericDescriptor_ENDPOINT,
00502 USBEndpointDescriptor_ADDRESS(USBEndpointDescriptor_OUT,
00503 CDCDSerialDriverDescriptors_DATAOUT),
00504 USBEndpointDescriptor_BULK,
00505 MIN(CHIP_USB_ENDPOINTS_MAXPACKETSIZE(CDCDSerialDriverDescriptors_DATAOUT),
00506 USBEndpointDescriptor_MAXBULKSIZE_FS),
00507 0
00508 },
00509
00510 {
00511 sizeof(USBEndpointDescriptor),
00512 USBGenericDescriptor_ENDPOINT,
00513 USBEndpointDescriptor_ADDRESS(USBEndpointDescriptor_IN,
00514 CDCDSerialDriverDescriptors_DATAIN),
00515 USBEndpointDescriptor_BULK,
00516 MIN(CHIP_USB_ENDPOINTS_MAXPACKETSIZE(CDCDSerialDriverDescriptors_DATAIN),
00517 USBEndpointDescriptor_MAXBULKSIZE_FS),
00518 0
00519 }
00520 };
00521
00522
00523
00524
00525
00526 const unsigned char languageIdStringDescriptor[] = {
00527
00528 USBStringDescriptor_LENGTH(1),
00529 USBGenericDescriptor_STRING,
00530 USBStringDescriptor_ENGLISH_US
00531 };
00532
00533
00534 const unsigned char productStringDescriptor[] = {
00535
00536 USBStringDescriptor_LENGTH(13),
00537 USBGenericDescriptor_STRING,
00538 USBStringDescriptor_UNICODE('A'),
00539 USBStringDescriptor_UNICODE('T'),
00540 USBStringDescriptor_UNICODE('9'),
00541 USBStringDescriptor_UNICODE('1'),
00542 USBStringDescriptor_UNICODE('U'),
00543 USBStringDescriptor_UNICODE('S'),
00544 USBStringDescriptor_UNICODE('B'),
00545 USBStringDescriptor_UNICODE('S'),
00546 USBStringDescriptor_UNICODE('e'),
00547 USBStringDescriptor_UNICODE('r'),
00548 USBStringDescriptor_UNICODE('i'),
00549 USBStringDescriptor_UNICODE('a'),
00550 USBStringDescriptor_UNICODE('l')
00551 };
00552
00553
00554 const unsigned char *stringDescriptors[] = {
00555
00556 languageIdStringDescriptor,
00557 productStringDescriptor,
00558 };
00559
00560
00561 WEAK const USBDDriverDescriptors cdcdSerialDriverDescriptors = {
00562
00563 &deviceDescriptor,
00564 (USBConfigurationDescriptor *) &(configurationDescriptorsFS),
00565 &qualifierDescriptor,
00566 (USBConfigurationDescriptor *) &(otherSpeedDescriptorsFS),
00567 0,
00568 (USBConfigurationDescriptor *) &(configurationDescriptorsHS),
00569 &qualifierDescriptor,
00570 (USBConfigurationDescriptor *) &(otherSpeedDescriptorsHS),
00571 stringDescriptors,
00572 2
00573 };
00574
00575