From 1348663a4ff1a4696db39e72bcb751608714de8e Mon Sep 17 00:00:00 2001 From: tmk Date: Sat, 13 Apr 2013 11:55:08 +0900 Subject: [PATCH] Fix USB Descriptors --- protocol/lufa.mk | 2 -- protocol/lufa/descriptor.c | 11 +++++++---- protocol/pjrc/usb.c | 12 ++++++++++++ 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/protocol/lufa.mk b/protocol/lufa.mk index 8ea071af..3489f19c 100644 --- a/protocol/lufa.mk +++ b/protocol/lufa.mk @@ -31,8 +31,6 @@ VPATH += $(TOP_DIR)/$(LUFA_PATH) # LUFA library compile-time options and predefined tokens LUFA_OPTS = -D USB_DEVICE_ONLY -LUFA_OPTS += -D FIXED_CONTROL_ENDPOINT_SIZE=8 -LUFA_OPTS += -D FIXED_NUM_CONFIGURATIONS=1 LUFA_OPTS += -D USE_FLASH_DESCRIPTORS LUFA_OPTS += -D USE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)" diff --git a/protocol/lufa/descriptor.c b/protocol/lufa/descriptor.c index ff98d887..d34ab1c5 100644 --- a/protocol/lufa/descriptor.c +++ b/protocol/lufa/descriptor.c @@ -230,8 +230,9 @@ const USB_Descriptor_Device_t PROGMEM DeviceDescriptor = .SubClass = USB_CSCP_NoDeviceSubclass, .Protocol = USB_CSCP_NoDeviceProtocol, - .Endpoint0Size = FIXED_CONTROL_ENDPOINT_SIZE, + .Endpoint0Size = 8, + /* specified in config.h */ .VendorID = VENDOR_ID, .ProductID = PRODUCT_ID, .ReleaseNumber = DEVICE_VER, @@ -240,7 +241,7 @@ const USB_Descriptor_Device_t PROGMEM DeviceDescriptor = .ProductStrIndex = 0x02, .SerialNumStrIndex = NO_DESCRIPTOR, - .NumberOfConfigurations = FIXED_NUM_CONFIGURATIONS + .NumberOfConfigurations = 1 }; /******************************************************************************* @@ -453,14 +454,16 @@ const USB_Descriptor_String_t PROGMEM LanguageString = const USB_Descriptor_String_t PROGMEM ManufacturerString = { - .Header = {.Size = USB_STRING_LEN(11), .Type = DTYPE_String}, + /* subtract 1 for null terminator */ + .Header = {.Size = USB_STRING_LEN(sizeof(STR(MANUFACTURER))-1), .Type = DTYPE_String}, .UnicodeString = LSTR(MANUFACTURER) }; const USB_Descriptor_String_t PROGMEM ProductString = { - .Header = {.Size = USB_STRING_LEN(28), .Type = DTYPE_String}, + /* subtract 1 for null terminator */ + .Header = {.Size = USB_STRING_LEN(sizeof(STR(PRODUCT))-1), .Type = DTYPE_String}, .UnicodeString = LSTR(PRODUCT) }; diff --git a/protocol/pjrc/usb.c b/protocol/pjrc/usb.c index 14df9efd..0a5436de 100644 --- a/protocol/pjrc/usb.c +++ b/protocol/pjrc/usb.c @@ -103,7 +103,11 @@ static const uint8_t PROGMEM endpoint_config_table[] = { #else 0, // 2 #endif +#ifdef CONSOLE_ENABLE 1, EP_TYPE_INTERRUPT_IN, EP_SIZE(DEBUG_TX_SIZE) | DEBUG_TX_BUFFER, // 3 +#else + 0, +#endif #ifdef EXTRAKEY_ENABLE 1, EP_TYPE_INTERRUPT_IN, EP_SIZE(EXTRA_SIZE) | EXTRA_BUFFER, // 4 #else @@ -332,8 +336,12 @@ static const uint8_t PROGMEM extra_hid_report_desc[] = { # define MOUSE_HID_DESC_NUM (KBD_HID_DESC_NUM + 0) #endif +#ifdef CONSOLE_ENABLE #define DEBUG_HID_DESC_NUM (MOUSE_HID_DESC_NUM + 1) #define DEBUG_HID_DESC_OFFSET (9+(9+9+7)*DEBUG_HID_DESC_NUM+9) +#else +# define DEBUG_HID_DESC_NUM (MOUSE_HID_DESC_NUM + 0) +#endif #ifdef EXTRAKEY_ENABLE # define EXTRA_HID_DESC_NUM (DEBUG_HID_DESC_NUM + 1) @@ -424,6 +432,7 @@ static const uint8_t PROGMEM config1_descriptor[CONFIG1_DESC_SIZE] = { 1, // bInterval #endif +#ifdef CONSOLE_ENABLE // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12 9, // bLength 4, // bDescriptorType @@ -450,6 +459,7 @@ static const uint8_t PROGMEM config1_descriptor[CONFIG1_DESC_SIZE] = { 0x03, // bmAttributes (0x03=intr) DEBUG_TX_SIZE, 0, // wMaxPacketSize 1, // bInterval +#endif #ifdef EXTRAKEY_ENABLE // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12 @@ -553,8 +563,10 @@ static const struct descriptor_list_struct { {0x2100, MOUSE_INTERFACE, config1_descriptor+MOUSE_HID_DESC_OFFSET, 9}, {0x2200, MOUSE_INTERFACE, mouse_hid_report_desc, sizeof(mouse_hid_report_desc)}, #endif +#ifdef CONSOLE_ENABLE {0x2100, DEBUG_INTERFACE, config1_descriptor+DEBUG_HID_DESC_OFFSET, 9}, {0x2200, DEBUG_INTERFACE, debug_hid_report_desc, sizeof(debug_hid_report_desc)}, +#endif #ifdef EXTRAKEY_ENABLE {0x2100, EXTRA_INTERFACE, config1_descriptor+EXTRA_HID_DESC_OFFSET, 9}, {0x2200, EXTRA_INTERFACE, extra_hid_report_desc, sizeof(extra_hid_report_desc)}, -- 2.39.3