diff options
author | yiancar <yiangosyiangou@cytanet.com.cy> | 2020-08-19 02:16:35 +0100 |
---|---|---|
committer | James Young <18669334+noroadsleft@users.noreply.github.com> | 2020-08-29 14:30:02 -0700 |
commit | 47f8947bf5aa3ff1cbb484a2d6dc3fa818987700 (patch) | |
tree | 3aeba94ac3c304f38a7f943db18450ca0267cd67 | |
parent | 9ef4526a2f6cdd2e708e7cfc37845a04749665dd (diff) | |
download | qmk_firmware-47f8947bf5aa3ff1cbb484a2d6dc3fa818987700.tar.gz qmk_firmware-47f8947bf5aa3ff1cbb484a2d6dc3fa818987700.zip |
Update vusb to match 3rd endpoint. (#9020)
* Update vusb to match 3rd endpoint.
- With the addition of https://github.com/qmk/v-usb/pull/1 a 3rd endpoint (endpoint4) becomes available.
- We can assign mouse/extrakeys to that endpoint as its a desirable feature and leave rawhid and console to compete for the 2nd endpoint.
NOTE: The version of vusb.c in future branch is older than master. Just remember that it will need a #error if both raw_hid and console are enabled at the same time.
* Final Fixes
* Update tmk_core/protocol/vusb/vusb.c
* Update tmk_core/protocol/vusb/vusb.c
* Update tmk_core/protocol/vusb/usbconfig.h
* Update tmk_core/protocol/vusb/usbconfig.h
* Update tmk_core/protocol/vusb/usbconfig.h
* Update tmk_core/protocol/vusb/usbconfig.h
* Updated vusb submodule to latest commit
m--------- | lib/vusb | 0 | ||||
-rw-r--r-- | tmk_core/protocol/vusb/usbconfig.h | 20 | ||||
-rw-r--r-- | tmk_core/protocol/vusb/vusb.c | 18 |
3 files changed, 26 insertions, 12 deletions
diff --git a/lib/vusb b/lib/vusb | |||
Subproject 9a42d205eb60faca494ff4eabce8d59f0ec0fc7 | Subproject bdb53e4c043d089279d9891b68bea77614cb97e | ||
diff --git a/tmk_core/protocol/vusb/usbconfig.h b/tmk_core/protocol/vusb/usbconfig.h index dcef7584c..041f7bd09 100644 --- a/tmk_core/protocol/vusb/usbconfig.h +++ b/tmk_core/protocol/vusb/usbconfig.h | |||
@@ -85,9 +85,19 @@ section at the end of this file). | |||
85 | /* If the so-called endpoint 3 is used, it can now be configured to any other | 85 | /* If the so-called endpoint 3 is used, it can now be configured to any other |
86 | * endpoint number (except 0) with this macro. Default if undefined is 3. | 86 | * endpoint number (except 0) with this macro. Default if undefined is 3. |
87 | */ | 87 | */ |
88 | #define USB_CFG_HAVE_INTRIN_ENDPOINT4 1 | ||
89 | /* Define this to 1 if you want to compile a version with three endpoints: The | ||
90 | * default control endpoint 0, an interrupt-in endpoint 4 (or the number | ||
91 | * configured below) and a catch-all default interrupt-in endpoint as above. | ||
92 | * You must also define USB_CFG_HAVE_INTRIN_ENDPOINT to 1 for this feature. | ||
93 | */ | ||
94 | #define USB_CFG_EP4_NUMBER 4 | ||
95 | /* If the so-called endpoint 4 is used, it can now be configured to any other | ||
96 | * endpoint number (except 0) with this macro. Default if undefined is 4. | ||
97 | */ | ||
88 | /* #define USB_INITIAL_DATATOKEN USBPID_DATA1 */ | 98 | /* #define USB_INITIAL_DATATOKEN USBPID_DATA1 */ |
89 | /* The above macro defines the startup condition for data toggling on the | 99 | /* The above macro defines the startup condition for data toggling on the |
90 | * interrupt/bulk endpoints 1 and 3. Defaults to USBPID_DATA1. | 100 | * interrupt/bulk endpoints 1, 3 and 4. Defaults to USBPID_DATA1. |
91 | * Since the token is toggled BEFORE sending any data, the first packet is | 101 | * Since the token is toggled BEFORE sending any data, the first packet is |
92 | * sent with the oposite value of this configuration! | 102 | * sent with the oposite value of this configuration! |
93 | */ | 103 | */ |
@@ -100,10 +110,10 @@ section at the end of this file). | |||
100 | #define USB_CFG_SUPPRESS_INTR_CODE 0 | 110 | #define USB_CFG_SUPPRESS_INTR_CODE 0 |
101 | /* Define this to 1 if you want to declare interrupt-in endpoints, but don't | 111 | /* Define this to 1 if you want to declare interrupt-in endpoints, but don't |
102 | * want to send any data over them. If this macro is defined to 1, functions | 112 | * want to send any data over them. If this macro is defined to 1, functions |
103 | * usbSetInterrupt() and usbSetInterrupt3() are omitted. This is useful if | 113 | * usbSetInterrupt(), usbSetInterrupt3() and usbSetInterrupt4() are omitted. |
104 | * you need the interrupt-in endpoints in order to comply to an interface | 114 | * This is useful if you need the interrupt-in endpoints in order to comply |
105 | * (e.g. HID), but never want to send any data. This option saves a couple | 115 | * to an interface (e.g. HID), but never want to send any data. This option |
106 | * of bytes in flash memory and the transmit buffers in RAM. | 116 | * saves a couple of bytes in flash memory and the transmit buffers in RAM. |
107 | */ | 117 | */ |
108 | #define USB_CFG_IS_SELF_POWERED 0 | 118 | #define USB_CFG_IS_SELF_POWERED 0 |
109 | /* Define this to 1 if the device has its own power supply. Set it to 0 if the | 119 | /* Define this to 1 if the device has its own power supply. Set it to 0 if the |
diff --git a/tmk_core/protocol/vusb/vusb.c b/tmk_core/protocol/vusb/vusb.c index 735a1c1d3..77bbbd7bd 100644 --- a/tmk_core/protocol/vusb/vusb.c +++ b/tmk_core/protocol/vusb/vusb.c | |||
@@ -62,12 +62,16 @@ enum usb_interfaces { | |||
62 | TOTAL_INTERFACES = NEXT_INTERFACE | 62 | TOTAL_INTERFACES = NEXT_INTERFACE |
63 | }; | 63 | }; |
64 | 64 | ||
65 | #define MAX_INTERFACES 2 | 65 | #define MAX_INTERFACES 3 |
66 | 66 | ||
67 | #if (NEXT_INTERFACE - 1) > MAX_INTERFACES | 67 | #if (NEXT_INTERFACE - 1) > MAX_INTERFACES |
68 | # error There are not enough available interfaces to support all functions. Please disable one or more of the following: Mouse Keys, Extra Keys, Raw HID, Console | 68 | # error There are not enough available interfaces to support all functions. Please disable one or more of the following: Mouse Keys, Extra Keys, Raw HID, Console |
69 | #endif | 69 | #endif |
70 | 70 | ||
71 | #if (defined(MOUSE_ENABLE) || defined(EXTRAKEY_ENABLE)) && CONSOLE_ENABLE | ||
72 | # error Mouse/Extra Keys share an endpoint with Console. Please disable one of the two. | ||
73 | #endif | ||
74 | |||
71 | static uint8_t keyboard_led_state = 0; | 75 | static uint8_t keyboard_led_state = 0; |
72 | static uint8_t vusb_idle_rate = 0; | 76 | static uint8_t vusb_idle_rate = 0; |
73 | 77 | ||
@@ -116,16 +120,16 @@ void raw_hid_send(uint8_t *data, uint8_t length) { | |||
116 | 120 | ||
117 | uint8_t *temp = data; | 121 | uint8_t *temp = data; |
118 | for (uint8_t i = 0; i < 4; i++) { | 122 | for (uint8_t i = 0; i < 4; i++) { |
119 | while (!usbInterruptIsReady3()) { | 123 | while (!usbInterruptIsReady4()) { |
120 | usbPoll(); | 124 | usbPoll(); |
121 | } | 125 | } |
122 | usbSetInterrupt3(temp, 8); | 126 | usbSetInterrupt4(temp, 8); |
123 | temp += 8; | 127 | temp += 8; |
124 | } | 128 | } |
125 | while (!usbInterruptIsReady3()) { | 129 | while (!usbInterruptIsReady4()) { |
126 | usbPoll(); | 130 | usbPoll(); |
127 | } | 131 | } |
128 | usbSetInterrupt3(0, 0); | 132 | usbSetInterrupt4(0, 0); |
129 | } | 133 | } |
130 | 134 | ||
131 | __attribute__((weak)) void raw_hid_receive(uint8_t *data, uint8_t length) { | 135 | __attribute__((weak)) void raw_hid_receive(uint8_t *data, uint8_t length) { |
@@ -683,7 +687,7 @@ const PROGMEM usbConfigurationDescriptor_t usbConfigurationDescriptor = { | |||
683 | .bLength = sizeof(usbEndpointDescriptor_t), | 687 | .bLength = sizeof(usbEndpointDescriptor_t), |
684 | .bDescriptorType = USBDESCR_ENDPOINT | 688 | .bDescriptorType = USBDESCR_ENDPOINT |
685 | }, | 689 | }, |
686 | .bEndpointAddress = (USBRQ_DIR_DEVICE_TO_HOST | USB_CFG_EP3_NUMBER), | 690 | .bEndpointAddress = (USBRQ_DIR_DEVICE_TO_HOST | USB_CFG_EP4_NUMBER), |
687 | .bmAttributes = 0x03, | 691 | .bmAttributes = 0x03, |
688 | .wMaxPacketSize = RAW_EPSIZE, | 692 | .wMaxPacketSize = RAW_EPSIZE, |
689 | .bInterval = USB_POLLING_INTERVAL_MS | 693 | .bInterval = USB_POLLING_INTERVAL_MS |
@@ -693,7 +697,7 @@ const PROGMEM usbConfigurationDescriptor_t usbConfigurationDescriptor = { | |||
693 | .bLength = sizeof(usbEndpointDescriptor_t), | 697 | .bLength = sizeof(usbEndpointDescriptor_t), |
694 | .bDescriptorType = USBDESCR_ENDPOINT | 698 | .bDescriptorType = USBDESCR_ENDPOINT |
695 | }, | 699 | }, |
696 | .bEndpointAddress = (USBRQ_DIR_HOST_TO_DEVICE | USB_CFG_EP3_NUMBER), | 700 | .bEndpointAddress = (USBRQ_DIR_HOST_TO_DEVICE | USB_CFG_EP4_NUMBER), |
697 | .bmAttributes = 0x03, | 701 | .bmAttributes = 0x03, |
698 | .wMaxPacketSize = RAW_EPSIZE, | 702 | .wMaxPacketSize = RAW_EPSIZE, |
699 | .bInterval = USB_POLLING_INTERVAL_MS | 703 | .bInterval = USB_POLLING_INTERVAL_MS |