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 sizeof(USBConfigurationDescriptor),
00109 USBGenericDescriptor_CONFIGURATION,
00110 sizeof(CdcHidDriverConfigurationDescriptors),
00111 CDCHIDDDriverDescriptors_NUMINTERFACE,
00112 1,
00113 0,
00114 USBD_BMATTRIBUTES,
00115 USBConfigurationDescriptor_POWER(100)
00116 },
00117
00118
00119
00120 {
00121 sizeof(USBInterfaceAssociationDescriptor),
00122 USBGenericDescriptor_INTERFACEASSOCIATION,
00123 CDCHIDDDriverDescriptors_CDC_INTERFACE,
00124 2,
00125 CDCCommunicationInterfaceDescriptor_CLASS,
00126 CDCCommunicationInterfaceDescriptor_ABSTRACTCONTROLMODEL,
00127 CDCCommunicationInterfaceDescriptor_NOPROTOCOL,
00128 0
00129 },
00130
00131 {
00132 sizeof(USBInterfaceDescriptor),
00133 USBGenericDescriptor_INTERFACE,
00134 CDCHIDDDriverDescriptors_CDC_INTERFACE,
00135 0,
00136 1,
00137 CDCCommunicationInterfaceDescriptor_CLASS,
00138 CDCCommunicationInterfaceDescriptor_ABSTRACTCONTROLMODEL,
00139 CDCCommunicationInterfaceDescriptor_NOPROTOCOL,
00140 0
00141 },
00142
00143 {
00144 sizeof(CDCHeaderDescriptor),
00145 CDCGenericDescriptor_INTERFACE,
00146 CDCGenericDescriptor_HEADER,
00147 CDCGenericDescriptor_CDC1_10
00148 },
00149
00150 {
00151 sizeof(CDCCallManagementDescriptor),
00152 CDCGenericDescriptor_INTERFACE,
00153 CDCGenericDescriptor_CALLMANAGEMENT,
00154 CDCCallManagementDescriptor_SELFCALLMANAGEMENT,
00155 CDCHIDDDriverDescriptors_CDC_INTERFACE + 1
00156 },
00157
00158 {
00159 sizeof(CDCAbstractControlManagementDescriptor),
00160 CDCGenericDescriptor_INTERFACE,
00161 CDCGenericDescriptor_ABSTRACTCONTROLMANAGEMENT,
00162 CDCAbstractControlManagementDescriptor_LINE
00163 },
00164
00165 {
00166 sizeof(CDCUnionDescriptor),
00167 CDCGenericDescriptor_INTERFACE,
00168 CDCGenericDescriptor_UNION,
00169 CDCHIDDDriverDescriptors_CDC_INTERFACE,
00170 CDCHIDDDriverDescriptors_CDC_INTERFACE + 1
00171 },
00172
00173 {
00174 sizeof(USBEndpointDescriptor),
00175 USBGenericDescriptor_ENDPOINT,
00176 USBEndpointDescriptor_ADDRESS(USBEndpointDescriptor_IN,
00177 CDCD_Descriptors_NOTIFICATION0),
00178 USBEndpointDescriptor_INTERRUPT,
00179 MIN(CHIP_USB_ENDPOINTS_MAXPACKETSIZE(CDCD_Descriptors_NOTIFICATION0),
00180 USBEndpointDescriptor_MAXINTERRUPTSIZE_FS),
00181 CDCDSerialPort_INTERRUPT_INTERVAL_FS
00182 },
00183
00184 {
00185 sizeof(USBInterfaceDescriptor),
00186 USBGenericDescriptor_INTERFACE,
00187 CDCHIDDDriverDescriptors_CDC_INTERFACE + 1,
00188 0,
00189 2,
00190 CDCDataInterfaceDescriptor_CLASS,
00191 CDCDataInterfaceDescriptor_SUBCLASS,
00192 CDCDataInterfaceDescriptor_NOPROTOCOL,
00193 0
00194 },
00195
00196 {
00197 sizeof(USBEndpointDescriptor),
00198 USBGenericDescriptor_ENDPOINT,
00199 USBEndpointDescriptor_ADDRESS(USBEndpointDescriptor_OUT,
00200 CDCD_Descriptors_DATAOUT0),
00201 USBEndpointDescriptor_BULK,
00202 MIN(CHIP_USB_ENDPOINTS_MAXPACKETSIZE(CDCD_Descriptors_DATAOUT0),
00203 USBEndpointDescriptor_MAXBULKSIZE_FS),
00204 0
00205 },
00206
00207 {
00208 sizeof(USBEndpointDescriptor),
00209 USBGenericDescriptor_ENDPOINT,
00210 USBEndpointDescriptor_ADDRESS(USBEndpointDescriptor_IN,
00211 CDCD_Descriptors_DATAIN0),
00212 USBEndpointDescriptor_BULK,
00213 MIN(CHIP_USB_ENDPOINTS_MAXPACKETSIZE(CDCD_Descriptors_DATAIN0),
00214 USBEndpointDescriptor_MAXBULKSIZE_FS),
00215 0
00216 },
00217
00218
00219
00220 {
00221 sizeof(USBInterfaceDescriptor),
00222 USBGenericDescriptor_INTERFACE,
00223 CDCHIDDDriverDescriptors_HID_INTERFACE,
00224 0,
00225 2,
00226 HIDInterfaceDescriptor_CLASS,
00227 HIDInterfaceDescriptor_SUBCLASS_NONE,
00228 HIDInterfaceDescriptor_PROTOCOL_NONE,
00229 0
00230 },
00231
00232 {
00233 sizeof(HIDDescriptor1),
00234 HIDGenericDescriptor_HID,
00235 HIDDescriptor_HID1_11,
00236 0,
00237 1,
00238 HIDGenericDescriptor_REPORT,
00239 {HIDDKeyboard_REPORTDESCRIPTORSIZE}
00240
00241
00242
00243
00244
00245 },
00246
00247 {
00248 sizeof(USBEndpointDescriptor),
00249 USBGenericDescriptor_ENDPOINT,
00250 USBEndpointDescriptor_ADDRESS(
00251 USBEndpointDescriptor_IN,
00252 HIDD_Descriptors_INTERRUPTIN),
00253 USBEndpointDescriptor_INTERRUPT,
00254 sizeof(HIDDKeyboardInputReport),
00255 HIDDKeyboardDescriptors_INTERRUPTIN_POLLING_FS
00256 },
00257
00258 {
00259 sizeof(USBEndpointDescriptor),
00260 USBGenericDescriptor_ENDPOINT,
00261 USBEndpointDescriptor_ADDRESS(
00262 USBEndpointDescriptor_OUT,
00263 HIDD_Descriptors_INTERRUPTOUT),
00264 USBEndpointDescriptor_INTERRUPT,
00265 sizeof(HIDDKeyboardOutputReport),
00266 HIDDKeyboardDescriptors_INTERRUPTOUT_POLLING_FS
00267 }
00268 };
00269
00270
00271 static const unsigned char languageIdDescriptor[] = {
00272
00273 USBStringDescriptor_LENGTH(1),
00274 USBGenericDescriptor_STRING,
00275 USBStringDescriptor_ENGLISH_US
00276 };
00277
00278
00279 static const unsigned char manufacturerDescriptor[] = {
00280
00281 USBStringDescriptor_LENGTH(5),
00282 USBGenericDescriptor_STRING,
00283 USBStringDescriptor_UNICODE('A'),
00284 USBStringDescriptor_UNICODE('t'),
00285 USBStringDescriptor_UNICODE('m'),
00286 USBStringDescriptor_UNICODE('e'),
00287 USBStringDescriptor_UNICODE('l')
00288 };
00289
00290
00291 static const unsigned char productDescriptor[] = {
00292
00293 USBStringDescriptor_LENGTH(14),
00294 USBGenericDescriptor_STRING,
00295 USBStringDescriptor_UNICODE('C'),
00296 USBStringDescriptor_UNICODE('o'),
00297 USBStringDescriptor_UNICODE('m'),
00298 USBStringDescriptor_UNICODE('p'),
00299 USBStringDescriptor_UNICODE('o'),
00300 USBStringDescriptor_UNICODE('s'),
00301 USBStringDescriptor_UNICODE('i'),
00302 USBStringDescriptor_UNICODE('t'),
00303 USBStringDescriptor_UNICODE('e'),
00304 USBStringDescriptor_UNICODE(' '),
00305 USBStringDescriptor_UNICODE('D'),
00306 USBStringDescriptor_UNICODE('e'),
00307 USBStringDescriptor_UNICODE('m'),
00308 USBStringDescriptor_UNICODE('o')
00309 };
00310
00311
00312 static const unsigned char serialNumberDescriptor[] = {
00313
00314 USBStringDescriptor_LENGTH(4),
00315 USBGenericDescriptor_STRING,
00316 USBStringDescriptor_UNICODE('0'),
00317 USBStringDescriptor_UNICODE('1'),
00318 USBStringDescriptor_UNICODE('2'),
00319 USBStringDescriptor_UNICODE('3')
00320 };
00321
00322
00323 static const unsigned char *stringDescriptors[] = {
00324
00325 languageIdDescriptor,
00326 manufacturerDescriptor,
00327 productDescriptor,
00328 serialNumberDescriptor,
00329 };
00330
00331
00332
00333
00334
00335
00336 const USBDDriverDescriptors cdchiddDriverDescriptors = {
00337
00338 &deviceDescriptor,
00339 (const USBConfigurationDescriptor *) &configurationDescriptorsFS,
00340 &qualifierDescriptor,
00341 0, 0, 0,
00342 &qualifierDescriptor, 0,
00343 stringDescriptors,
00344 4
00345 };
00346
00347