summaryrefslogtreecommitdiff
path: root/usb.c
diff options
context:
space:
mode:
authortmk <nobody@nowhere>2010-11-26 01:56:21 +0900
committertmk <nobody@nowhere>2010-11-26 01:56:21 +0900
commit37ced39ae2ecfc945c21526faffb2449577bbeb7 (patch)
treeec32b51a56d17f30cabd80e2bec7081a5f49e5b7 /usb.c
parentd6da5546879f9979d043a0b223597af7e8dedbf8 (diff)
add build option USB_12KRO.
Diffstat (limited to 'usb.c')
-rw-r--r--usb.c74
1 files changed, 25 insertions, 49 deletions
diff --git a/usb.c b/usb.c
index 00708340a7..e633b96383 100644
--- a/usb.c
+++ b/usb.c
@@ -53,12 +53,6 @@
# define STR_PRODUCT LSTR(PRODUCT)
#endif
-#define STR_KEYBOARD_INTERFACE L"t.m.k. keyboard I/F"
-#define STR_MOUSE_INTERFACE L"t.m.k. mouse I/F"
-#define STR_DEBUG_INTERFACE L"t.m.k. debug I/F"
-#define STR_EXTRA_INTERFACE L"t.m.k. extrakey I/F"
-#define STR_KEYBOARD2_INTERFACE L"t.m.k. keyboard2 I/F"
-
// Mac OS-X and Linux automatically load the correct drivers. On
// Windows, even though the driver is supplied by Microsoft, an
@@ -100,7 +94,11 @@ static const uint8_t PROGMEM endpoint_config_table[] = {
1, EP_TYPE_INTERRUPT_IN, EP_SIZE(MOUSE_SIZE) | MOUSE_BUFFER, // 2
1, EP_TYPE_INTERRUPT_IN, EP_SIZE(DEBUG_TX_SIZE) | DEBUG_TX_BUFFER, // 3
1, EP_TYPE_INTERRUPT_IN, EP_SIZE(EXTRA_SIZE) | EXTRA_BUFFER, // 4
+#ifdef USB_12KRO
1, EP_TYPE_INTERRUPT_IN, EP_SIZE(KEYBOARD_SIZE) | KEYBOARD_BUFFER, // 5
+#else
+ 0, // 5
+#endif
0, // 6
};
@@ -298,13 +296,17 @@ static uint8_t PROGMEM extra_hid_report_desc[] = {
0xc0 // END_COLLECTION
};
-#define NUM_INTERFACES 5
-#define KEYBOARD_HID_DESC_OFFSET (9+9)
-#define MOUSE_HID_DESC_OFFSET (9+(9+9+7)+9)
-#define DEBUG_HID_DESC_OFFSET (9+(9+9+7)+(9+9+7)+9)
-#define EXTRA_HID_DESC_OFFSET (9+(9+9+7)+(9+9+7)+(9+9+7)+9)
-#define KEYBOARD2_HID_DESC_OFFSET (9+(9+9+7)+(9+9+7)+(9+9+7)+(9+9+7)+9)
-#define CONFIG1_DESC_SIZE (9+(9+9+7)+(9+9+7)+(9+9+7)+(9+9+7)+(9+9+7))
+#define KEYBOARD_HID_DESC_OFFSET (9+(9+9+7)*0+9)
+#define MOUSE_HID_DESC_OFFSET (9+(9+9+7)*1+9)
+#define DEBUG_HID_DESC_OFFSET (9+(9+9+7)*2+9)
+#define EXTRA_HID_DESC_OFFSET (9+(9+9+7)*3+9)
+#ifdef USB_12KRO
+# define NUM_INTERFACES 5
+# define KEYBOARD2_HID_DESC_OFFSET (9+(9+9+7)*4+9)
+#else
+# define NUM_INTERFACES 4
+#endif
+#define CONFIG1_DESC_SIZE (9+(9+9+7)*NUM_INTERFACES)
static uint8_t PROGMEM config1_descriptor[CONFIG1_DESC_SIZE] = {
// configuration descriptor, USB spec 9.6.3, page 264-266, Table 9-10
9, // bLength;
@@ -326,7 +328,7 @@ static uint8_t PROGMEM config1_descriptor[CONFIG1_DESC_SIZE] = {
0x03, // bInterfaceClass (0x03 = HID)
0x01, // bInterfaceSubClass (0x01 = Boot)
0x01, // bInterfaceProtocol (0x01 = Keyboard)
- 3, // iInterface
+ 0, // iInterface
// HID descriptor, HID 1.11 spec, section 6.2.1
9, // bLength
0x21, // bDescriptorType
@@ -353,7 +355,7 @@ static uint8_t PROGMEM config1_descriptor[CONFIG1_DESC_SIZE] = {
0x03, // bInterfaceClass (0x03 = HID)
0x01, // bInterfaceSubClass (0x01 = Boot)
0x02, // bInterfaceProtocol (0x02 = Mouse)
- 4, // iInterface
+ 0, // iInterface
// HID descriptor, HID 1.11 spec, section 6.2.1
9, // bLength
0x21, // bDescriptorType
@@ -380,7 +382,7 @@ static uint8_t PROGMEM config1_descriptor[CONFIG1_DESC_SIZE] = {
0x03, // bInterfaceClass (0x03 = HID)
0x00, // bInterfaceSubClass
0x00, // bInterfaceProtocol
- 5, // iInterface
+ 0, // iInterface
// HID descriptor, HID 1.11 spec, section 6.2.1
9, // bLength
0x21, // bDescriptorType
@@ -407,7 +409,7 @@ static uint8_t PROGMEM config1_descriptor[CONFIG1_DESC_SIZE] = {
0x03, // bInterfaceClass (0x03 = HID)
0x00, // bInterfaceSubClass
0x00, // bInterfaceProtocol
- 6, // iInterface
+ 0, // iInterface
// HID descriptor, HID 1.11 spec, section 6.2.1
9, // bLength
0x21, // bDescriptorType
@@ -425,6 +427,7 @@ static uint8_t PROGMEM config1_descriptor[CONFIG1_DESC_SIZE] = {
EXTRA_SIZE, 0, // wMaxPacketSize
10, // bInterval
+#ifdef USB_12KRO
// interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
9, // bLength
4, // bDescriptorType
@@ -434,7 +437,7 @@ static uint8_t PROGMEM config1_descriptor[CONFIG1_DESC_SIZE] = {
0x03, // bInterfaceClass (0x03 = HID)
0x00, // bInterfaceSubClass (0x01 = Boot)
0x00, // bInterfaceProtocol (0x01 = Keyboard)
- 7, // iInterface
+ 0, // iInterface
// HID descriptor, HID 1.11 spec, section 6.2.1
9, // bLength
0x21, // bDescriptorType
@@ -451,6 +454,7 @@ static uint8_t PROGMEM config1_descriptor[CONFIG1_DESC_SIZE] = {
0x03, // bmAttributes (0x03=intr)
KEYBOARD_SIZE, 0, // wMaxPacketSize
1, // bInterval
+#endif
};
// If you're desperate for a little extra code memory, these strings
@@ -476,31 +480,6 @@ static struct usb_string_descriptor_struct PROGMEM string2 = {
3,
STR_PRODUCT
};
-static struct usb_string_descriptor_struct PROGMEM string3 = {
- sizeof(STR_KEYBOARD_INTERFACE),
- 3,
- STR_KEYBOARD_INTERFACE
-};
-static struct usb_string_descriptor_struct PROGMEM string4 = {
- sizeof(STR_MOUSE_INTERFACE),
- 3,
- STR_MOUSE_INTERFACE
-};
-static struct usb_string_descriptor_struct PROGMEM string5 = {
- sizeof(STR_DEBUG_INTERFACE),
- 3,
- STR_DEBUG_INTERFACE
-};
-static struct usb_string_descriptor_struct PROGMEM string6 = {
- sizeof(STR_EXTRA_INTERFACE),
- 3,
- STR_EXTRA_INTERFACE
-};
-static struct usb_string_descriptor_struct PROGMEM string7 = {
- sizeof(STR_KEYBOARD2_INTERFACE),
- 3,
- STR_KEYBOARD2_INTERFACE
-};
// This table defines which descriptor data is sent for each specific
// request from the host (in wValue and wIndex).
@@ -523,17 +502,14 @@ static struct descriptor_list_struct {
{0x2200, DEBUG_INTERFACE, debug_hid_report_desc, sizeof(debug_hid_report_desc)},
{0x2100, EXTRA_INTERFACE, config1_descriptor+EXTRA_HID_DESC_OFFSET, 9},
{0x2200, EXTRA_INTERFACE, extra_hid_report_desc, sizeof(extra_hid_report_desc)},
+#ifdef USB_12KRO
{0x2100, KEYBOARD_INTERFACE2, config1_descriptor+KEYBOARD2_HID_DESC_OFFSET, 9},
{0x2200, KEYBOARD_INTERFACE2, keyboard_hid_report_desc, sizeof(keyboard_hid_report_desc)},
+#endif
// STRING descriptors
{0x0300, 0x0000, (const uint8_t *)&string0, 4},
{0x0301, 0x0409, (const uint8_t *)&string1, sizeof(STR_MANUFACTURER)},
- {0x0302, 0x0409, (const uint8_t *)&string2, sizeof(STR_PRODUCT)},
- {0x0303, 0x0409, (const uint8_t *)&string3, sizeof(STR_KEYBOARD_INTERFACE)},
- {0x0304, 0x0409, (const uint8_t *)&string4, sizeof(STR_MOUSE_INTERFACE)},
- {0x0305, 0x0409, (const uint8_t *)&string5, sizeof(STR_DEBUG_INTERFACE)},
- {0x0306, 0x0409, (const uint8_t *)&string6, sizeof(STR_EXTRA_INTERFACE)},
- {0x0307, 0x0409, (const uint8_t *)&string7, sizeof(STR_KEYBOARD2_INTERFACE)},
+ {0x0302, 0x0409, (const uint8_t *)&string2, sizeof(STR_PRODUCT)}
};
#define NUM_DESC_LIST (sizeof(descriptor_list)/sizeof(struct descriptor_list_struct))