Skip to content

Commit

Permalink
Update vusb to match 3rd endpoint.
Browse files Browse the repository at this point in the history
- With the addition of qmk/v-usb#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.
  • Loading branch information
yiancar committed Aug 18, 2020
1 parent f13d897 commit a5613b0
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 10 deletions.
20 changes: 15 additions & 5 deletions tmk_core/protocol/vusb/usbconfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,19 @@ section at the end of this file).
/* If the so-called endpoint 3 is used, it can now be configured to any other
* endpoint number (except 0) with this macro. Default if undefined is 3.
*/
#define USB_CFG_HAVE_INTRIN_ENDPOINT4 1
/* Define this to 1 if you want to compile a version with three endpoints: The
* default control endpoint 0, an interrupt-in endpoint 4 (or the number
* configured below) and a catch-all default interrupt-in endpoint as above.
* You must also define USB_CFG_HAVE_INTRIN_ENDPOINT to 1 for this feature.
*/
#define USB_CFG_EP4_NUMBER 4
/* If the so-called endpoint 4 is used, it can now be configured to any other
* endpoint number (except 0) with this macro. Default if undefined is 4.
*/
/* #define USB_INITIAL_DATATOKEN USBPID_DATA1 */
/* The above macro defines the startup condition for data toggling on the
* interrupt/bulk endpoints 1 and 3. Defaults to USBPID_DATA1.
* interrupt/bulk endpoints 1, 3 and 4. Defaults to USBPID_DATA1.
* Since the token is toggled BEFORE sending any data, the first packet is
* sent with the oposite value of this configuration!
*/
Expand All @@ -100,10 +110,10 @@ section at the end of this file).
#define USB_CFG_SUPPRESS_INTR_CODE 0
/* Define this to 1 if you want to declare interrupt-in endpoints, but don't
* want to send any data over them. If this macro is defined to 1, functions
* usbSetInterrupt() and usbSetInterrupt3() are omitted. This is useful if
* you need the interrupt-in endpoints in order to comply to an interface
* (e.g. HID), but never want to send any data. This option saves a couple
* of bytes in flash memory and the transmit buffers in RAM.
* usbSetInterrupt(), usbSetInterrupt3() and usbSetInterrupt4() are omitted.
* This is useful if you need the interrupt-in endpoints in order to comply
* to an interface (e.g. HID), but never want to send any data. This option
* saves a couple of bytes in flash memory and the transmit buffers in RAM.
*/
#define USB_CFG_IS_SELF_POWERED 0
/* Define this to 1 if the device has its own power supply. Set it to 0 if the
Expand Down
10 changes: 5 additions & 5 deletions tmk_core/protocol/vusb/vusb.c
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,8 @@ typedef struct {
static void send_mouse(report_mouse_t *report) {
#ifdef MOUSE_ENABLE
vusb_mouse_report_t r = {.report_id = REPORT_ID_MOUSE, .report = *report};
if (usbInterruptIsReady3()) {
usbSetInterrupt3((void *)&r, sizeof(vusb_mouse_report_t));
if (usbInterruptIsReady4()) {
usbSetInterrupt4((void *)&r, sizeof(vusb_mouse_report_t));
}
#endif
}
Expand All @@ -249,8 +249,8 @@ static void send_extra(uint8_t report_id, uint16_t data) {
last_data = data;

report_extra_t report = {.report_id = report_id, .usage = data};
if (usbInterruptIsReady3()) {
usbSetInterrupt3((void *)&report, sizeof(report));
if (usbInterruptIsReady4()) {
usbSetInterrupt4((void *)&report, sizeof(report));
}
}
#endif
Expand Down Expand Up @@ -732,7 +732,7 @@ const PROGMEM usbConfigurationDescriptor_t usbConfigurationDescriptor = {
.bLength = sizeof(usbEndpointDescriptor_t),
.bDescriptorType = USBDESCR_ENDPOINT
},
.bEndpointAddress = (USBRQ_DIR_DEVICE_TO_HOST | USB_CFG_EP3_NUMBER),
.bEndpointAddress = (USBRQ_DIR_DEVICE_TO_HOST | USB_CFG_EP4_NUMBER),
.bmAttributes = 0x03,
.wMaxPacketSize = 8,
.bInterval = USB_POLLING_INTERVAL_MS
Expand Down

0 comments on commit a5613b0

Please sign in to comment.