@@ -69,8 +69,18 @@ const u8 STRING_MANUFACTURER[] PROGMEM = USB_MANUFACTURER;
6969#define DEVICE_CLASS 0x02
7070
7171// DEVICE DESCRIPTOR
72+
73+ #ifdef CDC_ENABLED
7274const DeviceDescriptor USB_DeviceDescriptorIAD =
7375 D_DEVICE (0xEF ,0x02 ,0x01 ,64 ,USB_VID,USB_PID,0x100 ,IMANUFACTURER,IPRODUCT,ISERIAL,1 );
76+ #else // CDC_DISABLED
77+ // The default descriptor uses USB class OxEF, subclass 0x02 with protocol 1
78+ // which means "Interface Association Descriptor" - that's needed for the CDC,
79+ // but doesn't make much sense as a default for custom devices when CDC is disabled.
80+ // (0x00 means "Use class information in the Interface Descriptors" which should be generally ok)
81+ const DeviceDescriptor USB_DeviceDescriptorIAD =
82+ D_DEVICE (0x00 ,0x00 ,0x00 ,64 ,USB_VID,USB_PID,0x100 ,IMANUFACTURER,IPRODUCT,ISERIAL,1 );
83+ #endif
7484
7585// ==================================================================
7686// ==================================================================
@@ -328,10 +338,12 @@ int USB_Send(u8 ep, const void* d, int len)
328338u8 _initEndpoints[USB_ENDPOINTS] =
329339{
330340 0 , // Control Endpoint
331-
341+
342+ #ifdef CDC_ENABLED
332343 EP_TYPE_INTERRUPT_IN, // CDC_ENDPOINT_ACM
333344 EP_TYPE_BULK_OUT, // CDC_ENDPOINT_OUT
334345 EP_TYPE_BULK_IN, // CDC_ENDPOINT_IN
346+ #endif
335347
336348 // Following endpoints are automatically initialized to 0
337349};
@@ -373,10 +385,12 @@ void InitEndpoints()
373385static
374386bool ClassInterfaceRequest (USBSetup& setup)
375387{
388+ #ifdef CDC_ENABLED
376389 u8 i = setup.wIndex ;
377390
378391 if (CDC_ACM_INTERFACE == i)
379392 return CDC_Setup (setup);
393+ #endif
380394
381395#ifdef PLUGGABLE_USB_ENABLED
382396 return PluggableUSB ().setup (setup);
@@ -466,7 +480,9 @@ static u8 SendInterfaces()
466480{
467481 u8 interfaces = 0 ;
468482
483+ #ifdef CDC_ENABLED
469484 CDC_GetInterface (&interfaces);
485+ #endif
470486
471487#ifdef PLUGGABLE_USB_ENABLED
472488 PluggableUSB ().getInterface (&interfaces);
0 commit comments