diff options
Diffstat (limited to 'tmk_core')
-rw-r--r-- | tmk_core/protocol/vusb/usbconfig.h | 22 | ||||
-rw-r--r-- | tmk_core/protocol/vusb/vusb.c | 34 | ||||
-rw-r--r-- | tmk_core/protocol/vusb/vusb.h | 8 |
3 files changed, 11 insertions, 53 deletions
diff --git a/tmk_core/protocol/vusb/usbconfig.h b/tmk_core/protocol/vusb/usbconfig.h index f15616351..f118dc8ed 100644 --- a/tmk_core/protocol/vusb/usbconfig.h +++ b/tmk_core/protocol/vusb/usbconfig.h | |||
@@ -41,15 +41,6 @@ section at the end of this file). | |||
41 | * interrupt, the USB interrupt will also be triggered at Start-Of-Frame | 41 | * interrupt, the USB interrupt will also be triggered at Start-Of-Frame |
42 | * markers every millisecond.] | 42 | * markers every millisecond.] |
43 | */ | 43 | */ |
44 | #define USB_CFG_CLOCK_KHZ (F_CPU/1000) | ||
45 | /* Clock rate of the AVR in kHz. Legal values are 12000, 12800, 15000, 16000, | ||
46 | * 16500, 18000 and 20000. The 12.8 MHz and 16.5 MHz versions of the code | ||
47 | * require no crystal, they tolerate +/- 1% deviation from the nominal | ||
48 | * frequency. All other rates require a precision of 2000 ppm and thus a | ||
49 | * crystal! | ||
50 | * Since F_CPU should be defined to your actual clock rate anyway, you should | ||
51 | * not need to modify this setting. | ||
52 | */ | ||
53 | #define USB_CFG_CHECK_CRC 0 | 44 | #define USB_CFG_CHECK_CRC 0 |
54 | /* Define this to 1 if you want that the driver checks integrity of incoming | 45 | /* Define this to 1 if you want that the driver checks integrity of incoming |
55 | * data packets (CRC checks). CRC checks cost quite a bit of code size and are | 46 | * data packets (CRC checks). CRC checks cost quite a bit of code size and are |
@@ -227,19 +218,6 @@ section at the end of this file). | |||
227 | * with libusb: 0x16c0/0x5dc. Use this VID/PID pair ONLY if you understand | 218 | * with libusb: 0x16c0/0x5dc. Use this VID/PID pair ONLY if you understand |
228 | * the implications! | 219 | * the implications! |
229 | */ | 220 | */ |
230 | #define USB_CFG_DEVICE_CLASS 0 | ||
231 | #define USB_CFG_DEVICE_SUBCLASS 0 | ||
232 | /* See USB specification if you want to conform to an existing device class. | ||
233 | * Class 0xff is "vendor specific". | ||
234 | */ | ||
235 | #define USB_CFG_INTERFACE_CLASS 3 /* HID */ | ||
236 | #define USB_CFG_INTERFACE_SUBCLASS 1 /* Boot */ | ||
237 | #define USB_CFG_INTERFACE_PROTOCOL 1 /* Keyboard */ | ||
238 | /* See USB specification if you want to conform to an existing device class or | ||
239 | * protocol. The following classes must be set at interface level: | ||
240 | * HID class is 3, no subclass and protocol required (but may be useful!) | ||
241 | * CDC class is 2, use subclass 2 and protocol 1 for ACM | ||
242 | */ | ||
243 | #define USB_CFG_HID_REPORT_DESCRIPTOR_LENGTH 0 | 221 | #define USB_CFG_HID_REPORT_DESCRIPTOR_LENGTH 0 |
244 | /* Define this to the length of the HID report descriptor, if you implement | 222 | /* Define this to the length of the HID report descriptor, if you implement |
245 | * an HID device. Otherwise don't define it or define it to 0. | 223 | * an HID device. Otherwise don't define it or define it to 0. |
diff --git a/tmk_core/protocol/vusb/vusb.c b/tmk_core/protocol/vusb/vusb.c index 470d29ba3..c4baf5ab0 100644 --- a/tmk_core/protocol/vusb/vusb.c +++ b/tmk_core/protocol/vusb/vusb.c | |||
@@ -28,7 +28,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
28 | #include "vusb.h" | 28 | #include "vusb.h" |
29 | #include <util/delay.h> | 29 | #include <util/delay.h> |
30 | 30 | ||
31 | #if defined(RAW_ENABLE) | 31 | #ifdef RAW_ENABLE |
32 | # include "raw_hid.h" | 32 | # include "raw_hid.h" |
33 | #endif | 33 | #endif |
34 | 34 | ||
@@ -158,7 +158,7 @@ typedef struct { | |||
158 | } __attribute__((packed)) vusb_mouse_report_t; | 158 | } __attribute__((packed)) vusb_mouse_report_t; |
159 | 159 | ||
160 | static void send_mouse(report_mouse_t *report) { | 160 | static void send_mouse(report_mouse_t *report) { |
161 | #if defined(MOUSE_ENABLE) | 161 | #ifdef MOUSE_ENABLE |
162 | vusb_mouse_report_t r = {.report_id = REPORT_ID_MOUSE, .report = *report}; | 162 | vusb_mouse_report_t r = {.report_id = REPORT_ID_MOUSE, .report = *report}; |
163 | if (usbInterruptIsReady3()) { | 163 | if (usbInterruptIsReady3()) { |
164 | usbSetInterrupt3((void *)&r, sizeof(vusb_mouse_report_t)); | 164 | usbSetInterrupt3((void *)&r, sizeof(vusb_mouse_report_t)); |
@@ -410,7 +410,7 @@ const PROGMEM uchar mouse_extra_hid_report[] = { | |||
410 | }; | 410 | }; |
411 | #endif | 411 | #endif |
412 | 412 | ||
413 | #if defined(RAW_ENABLE) | 413 | #ifdef RAW_ENABLE |
414 | const PROGMEM uchar raw_hid_report[] = { | 414 | const PROGMEM uchar raw_hid_report[] = { |
415 | 0x06, 0x60, 0xFF, // Usage Page (Vendor Defined) | 415 | 0x06, 0x60, 0xFF, // Usage Page (Vendor Defined) |
416 | 0x09, 0x61, // Usage (Vendor Defined) | 416 | 0x09, 0x61, // Usage (Vendor Defined) |
@@ -479,7 +479,6 @@ const PROGMEM usbStringDescriptor_t usbStringDescriptorSerial = { | |||
479 | .bString = LSTR(SERIAL_NUMBER) | 479 | .bString = LSTR(SERIAL_NUMBER) |
480 | }; | 480 | }; |
481 | 481 | ||
482 | #if USB_CFG_DESCR_PROPS_DEVICE | ||
483 | /* | 482 | /* |
484 | * Device descriptor | 483 | * Device descriptor |
485 | */ | 484 | */ |
@@ -489,8 +488,8 @@ const PROGMEM usbDeviceDescriptor_t usbDeviceDescriptor = { | |||
489 | .bDescriptorType = USBDESCR_DEVICE | 488 | .bDescriptorType = USBDESCR_DEVICE |
490 | }, | 489 | }, |
491 | .bcdUSB = 0x0110, | 490 | .bcdUSB = 0x0110, |
492 | .bDeviceClass = USB_CFG_DEVICE_CLASS, | 491 | .bDeviceClass = 0x00, |
493 | .bDeviceSubClass = USB_CFG_DEVICE_SUBCLASS, | 492 | .bDeviceSubClass = 0x00, |
494 | .bDeviceProtocol = 0x00, | 493 | .bDeviceProtocol = 0x00, |
495 | .bMaxPacketSize0 = 8, | 494 | .bMaxPacketSize0 = 8, |
496 | .idVendor = VENDOR_ID, | 495 | .idVendor = VENDOR_ID, |
@@ -501,9 +500,7 @@ const PROGMEM usbDeviceDescriptor_t usbDeviceDescriptor = { | |||
501 | .iSerialNumber = 0x03, | 500 | .iSerialNumber = 0x03, |
502 | .bNumConfigurations = 1 | 501 | .bNumConfigurations = 1 |
503 | }; | 502 | }; |
504 | #endif | ||
505 | 503 | ||
506 | #if USB_CFG_DESCR_PROPS_CONFIGURATION | ||
507 | /* | 504 | /* |
508 | * Configuration descriptors | 505 | * Configuration descriptors |
509 | */ | 506 | */ |
@@ -535,10 +532,10 @@ const PROGMEM usbConfigurationDescriptor_t usbConfigurationDescriptor = { | |||
535 | }, | 532 | }, |
536 | .bInterfaceNumber = 0, | 533 | .bInterfaceNumber = 0, |
537 | .bAlternateSetting = 0x00, | 534 | .bAlternateSetting = 0x00, |
538 | .bNumEndpoints = USB_CFG_HAVE_INTRIN_ENDPOINT, | 535 | .bNumEndpoints = 1, |
539 | .bInterfaceClass = USB_CFG_INTERFACE_CLASS, | 536 | .bInterfaceClass = 0x03, |
540 | .bInterfaceSubClass = USB_CFG_INTERFACE_SUBCLASS, | 537 | .bInterfaceSubClass = 0x01, |
541 | .bInterfaceProtocol = USB_CFG_INTERFACE_PROTOCOL, | 538 | .bInterfaceProtocol = 0x01, |
542 | .iInterface = 0x00 | 539 | .iInterface = 0x00 |
543 | }, | 540 | }, |
544 | .keyboardHID = { | 541 | .keyboardHID = { |
@@ -552,7 +549,6 @@ const PROGMEM usbConfigurationDescriptor_t usbConfigurationDescriptor = { | |||
552 | .bDescriptorType = USBDESCR_HID_REPORT, | 549 | .bDescriptorType = USBDESCR_HID_REPORT, |
553 | .wDescriptorLength = sizeof(keyboard_hid_report) | 550 | .wDescriptorLength = sizeof(keyboard_hid_report) |
554 | }, | 551 | }, |
555 | # ifdef USB_CFG_HAVE_INTRIN_ENDPOINT | ||
556 | .keyboardINEndpoint = { | 552 | .keyboardINEndpoint = { |
557 | .header = { | 553 | .header = { |
558 | .bLength = sizeof(usbEndpointDescriptor_t), | 554 | .bLength = sizeof(usbEndpointDescriptor_t), |
@@ -563,7 +559,6 @@ const PROGMEM usbConfigurationDescriptor_t usbConfigurationDescriptor = { | |||
563 | .wMaxPacketSize = 8, | 559 | .wMaxPacketSize = 8, |
564 | .bInterval = USB_POLLING_INTERVAL_MS | 560 | .bInterval = USB_POLLING_INTERVAL_MS |
565 | }, | 561 | }, |
566 | # endif | ||
567 | 562 | ||
568 | # if defined(MOUSE_ENABLE) || defined(EXTRAKEY_ENABLE) | 563 | # if defined(MOUSE_ENABLE) || defined(EXTRAKEY_ENABLE) |
569 | /* | 564 | /* |
@@ -576,7 +571,7 @@ const PROGMEM usbConfigurationDescriptor_t usbConfigurationDescriptor = { | |||
576 | }, | 571 | }, |
577 | .bInterfaceNumber = 1, | 572 | .bInterfaceNumber = 1, |
578 | .bAlternateSetting = 0x00, | 573 | .bAlternateSetting = 0x00, |
579 | .bNumEndpoints = USB_CFG_HAVE_INTRIN_ENDPOINT3, | 574 | .bNumEndpoints = 1, |
580 | .bInterfaceClass = 0x03, | 575 | .bInterfaceClass = 0x03, |
581 | .bInterfaceSubClass = 0x00, | 576 | .bInterfaceSubClass = 0x00, |
582 | .bInterfaceProtocol = 0x00, | 577 | .bInterfaceProtocol = 0x00, |
@@ -593,7 +588,6 @@ const PROGMEM usbConfigurationDescriptor_t usbConfigurationDescriptor = { | |||
593 | .bDescriptorType = USBDESCR_HID_REPORT, | 588 | .bDescriptorType = USBDESCR_HID_REPORT, |
594 | .wDescriptorLength = sizeof(mouse_extra_hid_report) | 589 | .wDescriptorLength = sizeof(mouse_extra_hid_report) |
595 | }, | 590 | }, |
596 | # if USB_CFG_HAVE_INTRIN_ENDPOINT3 | ||
597 | .mouseExtraINEndpoint = { | 591 | .mouseExtraINEndpoint = { |
598 | .header = { | 592 | .header = { |
599 | .bLength = sizeof(usbEndpointDescriptor_t), | 593 | .bLength = sizeof(usbEndpointDescriptor_t), |
@@ -604,7 +598,6 @@ const PROGMEM usbConfigurationDescriptor_t usbConfigurationDescriptor = { | |||
604 | .wMaxPacketSize = 8, | 598 | .wMaxPacketSize = 8, |
605 | .bInterval = USB_POLLING_INTERVAL_MS | 599 | .bInterval = USB_POLLING_INTERVAL_MS |
606 | } | 600 | } |
607 | # endif | ||
608 | # elif defined(RAW_ENABLE) | 601 | # elif defined(RAW_ENABLE) |
609 | .rawInterface = { | 602 | .rawInterface = { |
610 | .header = { | 603 | .header = { |
@@ -630,7 +623,6 @@ const PROGMEM usbConfigurationDescriptor_t usbConfigurationDescriptor = { | |||
630 | .bDescriptorType = USBDESCR_HID_REPORT, | 623 | .bDescriptorType = USBDESCR_HID_REPORT, |
631 | .wDescriptorLength = sizeof(raw_hid_report) | 624 | .wDescriptorLength = sizeof(raw_hid_report) |
632 | }, | 625 | }, |
633 | # if USB_CFG_HAVE_INTRIN_ENDPOINT3 | ||
634 | .rawINEndpoint = { | 626 | .rawINEndpoint = { |
635 | .header = { | 627 | .header = { |
636 | .bLength = sizeof(usbEndpointDescriptor_t), | 628 | .bLength = sizeof(usbEndpointDescriptor_t), |
@@ -651,10 +643,8 @@ const PROGMEM usbConfigurationDescriptor_t usbConfigurationDescriptor = { | |||
651 | .wMaxPacketSize = RAW_EPSIZE, | 643 | .wMaxPacketSize = RAW_EPSIZE, |
652 | .bInterval = USB_POLLING_INTERVAL_MS | 644 | .bInterval = USB_POLLING_INTERVAL_MS |
653 | } | 645 | } |
654 | # endif | ||
655 | # endif | 646 | # endif |
656 | }; | 647 | }; |
657 | #endif | ||
658 | 648 | ||
659 | // clang-format on | 649 | // clang-format on |
660 | 650 | ||
@@ -670,18 +660,14 @@ USB_PUBLIC usbMsgLen_t usbFunctionDescriptor(struct usbRequest *rq) { | |||
670 | debug_hex16(rq->wLength.word); debug("\n"); | 660 | debug_hex16(rq->wLength.word); debug("\n"); |
671 | */ | 661 | */ |
672 | switch (rq->wValue.bytes[1]) { | 662 | switch (rq->wValue.bytes[1]) { |
673 | #if USB_CFG_DESCR_PROPS_DEVICE | ||
674 | case USBDESCR_DEVICE: | 663 | case USBDESCR_DEVICE: |
675 | usbMsgPtr = (unsigned char *)&usbDeviceDescriptor; | 664 | usbMsgPtr = (unsigned char *)&usbDeviceDescriptor; |
676 | len = sizeof(usbDeviceDescriptor_t); | 665 | len = sizeof(usbDeviceDescriptor_t); |
677 | break; | 666 | break; |
678 | #endif | ||
679 | #if USB_CFG_DESCR_PROPS_CONFIGURATION | ||
680 | case USBDESCR_CONFIG: | 667 | case USBDESCR_CONFIG: |
681 | usbMsgPtr = (unsigned char *)&usbConfigurationDescriptor; | 668 | usbMsgPtr = (unsigned char *)&usbConfigurationDescriptor; |
682 | len = sizeof(usbConfigurationDescriptor_t); | 669 | len = sizeof(usbConfigurationDescriptor_t); |
683 | break; | 670 | break; |
684 | #endif | ||
685 | case USBDESCR_STRING: | 671 | case USBDESCR_STRING: |
686 | switch (rq->wValue.bytes[0]) { | 672 | switch (rq->wValue.bytes[0]) { |
687 | case 0: | 673 | case 0: |
diff --git a/tmk_core/protocol/vusb/vusb.h b/tmk_core/protocol/vusb/vusb.h index 6d491266d..bb2a1726e 100644 --- a/tmk_core/protocol/vusb/vusb.h +++ b/tmk_core/protocol/vusb/vusb.h | |||
@@ -87,23 +87,17 @@ typedef struct usbConfigurationDescriptor { | |||
87 | usbConfigurationDescriptorHeader_t header; | 87 | usbConfigurationDescriptorHeader_t header; |
88 | usbInterfaceDescriptor_t keyboardInterface; | 88 | usbInterfaceDescriptor_t keyboardInterface; |
89 | usbHIDDescriptor_t keyboardHID; | 89 | usbHIDDescriptor_t keyboardHID; |
90 | #ifdef USB_CFG_HAVE_INTRIN_ENDPOINT | ||
91 | usbEndpointDescriptor_t keyboardINEndpoint; | 90 | usbEndpointDescriptor_t keyboardINEndpoint; |
92 | #endif | ||
93 | 91 | ||
94 | #if defined(MOUSE_ENABLE) || defined(EXTRAKEY_ENABLE) | 92 | #if defined(MOUSE_ENABLE) || defined(EXTRAKEY_ENABLE) |
95 | usbInterfaceDescriptor_t mouseExtraInterface; | 93 | usbInterfaceDescriptor_t mouseExtraInterface; |
96 | usbHIDDescriptor_t mouseExtraHID; | 94 | usbHIDDescriptor_t mouseExtraHID; |
97 | # ifdef USB_CFG_HAVE_INTRIN_ENDPOINT3 | ||
98 | usbEndpointDescriptor_t mouseExtraINEndpoint; | 95 | usbEndpointDescriptor_t mouseExtraINEndpoint; |
99 | # endif | ||
100 | #elif defined(RAW_ENABLE) | 96 | #elif defined(RAW_ENABLE) |
101 | usbInterfaceDescriptor_t rawInterface; | 97 | usbInterfaceDescriptor_t rawInterface; |
102 | usbHIDDescriptor_t rawHID; | 98 | usbHIDDescriptor_t rawHID; |
103 | # ifdef USB_CFG_HAVE_INTRIN_ENDPOINT3 | ||
104 | usbEndpointDescriptor_t rawINEndpoint; | 99 | usbEndpointDescriptor_t rawINEndpoint; |
105 | usbEndpointDescriptor_t rawOUTEndpoint; | 100 | usbEndpointDescriptor_t rawOUTEndpoint; |
106 | # endif | ||
107 | #endif | 101 | #endif |
108 | } __attribute__((packed)) usbConfigurationDescriptor_t; | 102 | } __attribute__((packed)) usbConfigurationDescriptor_t; |
109 | 103 | ||
@@ -112,6 +106,6 @@ typedef struct usbConfigurationDescriptor { | |||
112 | host_driver_t *vusb_driver(void); | 106 | host_driver_t *vusb_driver(void); |
113 | void vusb_transfer_keyboard(void); | 107 | void vusb_transfer_keyboard(void); |
114 | 108 | ||
115 | #if defined(RAW_ENABLE) | 109 | #ifdef RAW_ENABLE |
116 | void raw_hid_task(void); | 110 | void raw_hid_task(void); |
117 | #endif | 111 | #endif |