1
0

Fix USB Descriptors

This commit is contained in:
tmk 2013-04-13 11:55:08 +09:00
parent 540d0700dc
commit 1348663a4f
3 changed files with 19 additions and 6 deletions

View File

@ -31,8 +31,6 @@ VPATH += $(TOP_DIR)/$(LUFA_PATH)
# LUFA library compile-time options and predefined tokens # LUFA library compile-time options and predefined tokens
LUFA_OPTS = -D USB_DEVICE_ONLY 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_FLASH_DESCRIPTORS
LUFA_OPTS += -D USE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)" LUFA_OPTS += -D USE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)"

View File

@ -230,8 +230,9 @@ const USB_Descriptor_Device_t PROGMEM DeviceDescriptor =
.SubClass = USB_CSCP_NoDeviceSubclass, .SubClass = USB_CSCP_NoDeviceSubclass,
.Protocol = USB_CSCP_NoDeviceProtocol, .Protocol = USB_CSCP_NoDeviceProtocol,
.Endpoint0Size = FIXED_CONTROL_ENDPOINT_SIZE, .Endpoint0Size = 8,
/* specified in config.h */
.VendorID = VENDOR_ID, .VendorID = VENDOR_ID,
.ProductID = PRODUCT_ID, .ProductID = PRODUCT_ID,
.ReleaseNumber = DEVICE_VER, .ReleaseNumber = DEVICE_VER,
@ -240,7 +241,7 @@ const USB_Descriptor_Device_t PROGMEM DeviceDescriptor =
.ProductStrIndex = 0x02, .ProductStrIndex = 0x02,
.SerialNumStrIndex = NO_DESCRIPTOR, .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 = 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) .UnicodeString = LSTR(MANUFACTURER)
}; };
const USB_Descriptor_String_t PROGMEM ProductString = 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) .UnicodeString = LSTR(PRODUCT)
}; };

View File

@ -103,7 +103,11 @@ static const uint8_t PROGMEM endpoint_config_table[] = {
#else #else
0, // 2 0, // 2
#endif #endif
#ifdef CONSOLE_ENABLE
1, EP_TYPE_INTERRUPT_IN, EP_SIZE(DEBUG_TX_SIZE) | DEBUG_TX_BUFFER, // 3 1, EP_TYPE_INTERRUPT_IN, EP_SIZE(DEBUG_TX_SIZE) | DEBUG_TX_BUFFER, // 3
#else
0,
#endif
#ifdef EXTRAKEY_ENABLE #ifdef EXTRAKEY_ENABLE
1, EP_TYPE_INTERRUPT_IN, EP_SIZE(EXTRA_SIZE) | EXTRA_BUFFER, // 4 1, EP_TYPE_INTERRUPT_IN, EP_SIZE(EXTRA_SIZE) | EXTRA_BUFFER, // 4
#else #else
@ -332,8 +336,12 @@ static const uint8_t PROGMEM extra_hid_report_desc[] = {
# define MOUSE_HID_DESC_NUM (KBD_HID_DESC_NUM + 0) # define MOUSE_HID_DESC_NUM (KBD_HID_DESC_NUM + 0)
#endif #endif
#ifdef CONSOLE_ENABLE
#define DEBUG_HID_DESC_NUM (MOUSE_HID_DESC_NUM + 1) #define DEBUG_HID_DESC_NUM (MOUSE_HID_DESC_NUM + 1)
#define DEBUG_HID_DESC_OFFSET (9+(9+9+7)*DEBUG_HID_DESC_NUM+9) #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 #ifdef EXTRAKEY_ENABLE
# define EXTRA_HID_DESC_NUM (DEBUG_HID_DESC_NUM + 1) # 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 1, // bInterval
#endif #endif
#ifdef CONSOLE_ENABLE
// interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12 // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
9, // bLength 9, // bLength
4, // bDescriptorType 4, // bDescriptorType
@ -450,6 +459,7 @@ static const uint8_t PROGMEM config1_descriptor[CONFIG1_DESC_SIZE] = {
0x03, // bmAttributes (0x03=intr) 0x03, // bmAttributes (0x03=intr)
DEBUG_TX_SIZE, 0, // wMaxPacketSize DEBUG_TX_SIZE, 0, // wMaxPacketSize
1, // bInterval 1, // bInterval
#endif
#ifdef EXTRAKEY_ENABLE #ifdef EXTRAKEY_ENABLE
// interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12 // 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}, {0x2100, MOUSE_INTERFACE, config1_descriptor+MOUSE_HID_DESC_OFFSET, 9},
{0x2200, MOUSE_INTERFACE, mouse_hid_report_desc, sizeof(mouse_hid_report_desc)}, {0x2200, MOUSE_INTERFACE, mouse_hid_report_desc, sizeof(mouse_hid_report_desc)},
#endif #endif
#ifdef CONSOLE_ENABLE
{0x2100, DEBUG_INTERFACE, config1_descriptor+DEBUG_HID_DESC_OFFSET, 9}, {0x2100, DEBUG_INTERFACE, config1_descriptor+DEBUG_HID_DESC_OFFSET, 9},
{0x2200, DEBUG_INTERFACE, debug_hid_report_desc, sizeof(debug_hid_report_desc)}, {0x2200, DEBUG_INTERFACE, debug_hid_report_desc, sizeof(debug_hid_report_desc)},
#endif
#ifdef EXTRAKEY_ENABLE #ifdef EXTRAKEY_ENABLE
{0x2100, EXTRA_INTERFACE, config1_descriptor+EXTRA_HID_DESC_OFFSET, 9}, {0x2100, EXTRA_INTERFACE, config1_descriptor+EXTRA_HID_DESC_OFFSET, 9},
{0x2200, EXTRA_INTERFACE, extra_hid_report_desc, sizeof(extra_hid_report_desc)}, {0x2200, EXTRA_INTERFACE, extra_hid_report_desc, sizeof(extra_hid_report_desc)},