Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V-USB: Remove some stuff from usbconfig.h that should not be configurable #8656

Merged
merged 4 commits into from
Apr 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 0 additions & 22 deletions tmk_core/protocol/vusb/usbconfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,6 @@ section at the end of this file).
* interrupt, the USB interrupt will also be triggered at Start-Of-Frame
* markers every millisecond.]
*/
#define USB_CFG_CLOCK_KHZ (F_CPU/1000)
/* Clock rate of the AVR in kHz. Legal values are 12000, 12800, 15000, 16000,
* 16500, 18000 and 20000. The 12.8 MHz and 16.5 MHz versions of the code
* require no crystal, they tolerate +/- 1% deviation from the nominal
* frequency. All other rates require a precision of 2000 ppm and thus a
* crystal!
* Since F_CPU should be defined to your actual clock rate anyway, you should
* not need to modify this setting.
*/
#define USB_CFG_CHECK_CRC 0
/* Define this to 1 if you want that the driver checks integrity of incoming
* data packets (CRC checks). CRC checks cost quite a bit of code size and are
Expand Down Expand Up @@ -227,19 +218,6 @@ section at the end of this file).
* with libusb: 0x16c0/0x5dc. Use this VID/PID pair ONLY if you understand
* the implications!
*/
#define USB_CFG_DEVICE_CLASS 0
#define USB_CFG_DEVICE_SUBCLASS 0
/* See USB specification if you want to conform to an existing device class.
* Class 0xff is "vendor specific".
*/
#define USB_CFG_INTERFACE_CLASS 3 /* HID */
#define USB_CFG_INTERFACE_SUBCLASS 1 /* Boot */
#define USB_CFG_INTERFACE_PROTOCOL 1 /* Keyboard */
/* See USB specification if you want to conform to an existing device class or
* protocol. The following classes must be set at interface level:
* HID class is 3, no subclass and protocol required (but may be useful!)
* CDC class is 2, use subclass 2 and protocol 1 for ACM
*/
#define USB_CFG_HID_REPORT_DESCRIPTOR_LENGTH 0
/* Define this to the length of the HID report descriptor, if you implement
* an HID device. Otherwise don't define it or define it to 0.
Expand Down
34 changes: 10 additions & 24 deletions tmk_core/protocol/vusb/vusb.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "vusb.h"
#include <util/delay.h>

#if defined(RAW_ENABLE)
#ifdef RAW_ENABLE
# include "raw_hid.h"
#endif

Expand Down Expand Up @@ -158,7 +158,7 @@ typedef struct {
} __attribute__((packed)) vusb_mouse_report_t;

static void send_mouse(report_mouse_t *report) {
#if defined(MOUSE_ENABLE)
#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));
Expand Down Expand Up @@ -410,7 +410,7 @@ const PROGMEM uchar mouse_extra_hid_report[] = {
};
#endif

#if defined(RAW_ENABLE)
#ifdef RAW_ENABLE
const PROGMEM uchar raw_hid_report[] = {
0x06, 0x60, 0xFF, // Usage Page (Vendor Defined)
0x09, 0x61, // Usage (Vendor Defined)
Expand Down Expand Up @@ -479,7 +479,6 @@ const PROGMEM usbStringDescriptor_t usbStringDescriptorSerial = {
.bString = LSTR(SERIAL_NUMBER)
};

#if USB_CFG_DESCR_PROPS_DEVICE
/*
* Device descriptor
*/
Expand All @@ -489,8 +488,8 @@ const PROGMEM usbDeviceDescriptor_t usbDeviceDescriptor = {
.bDescriptorType = USBDESCR_DEVICE
},
.bcdUSB = 0x0110,
.bDeviceClass = USB_CFG_DEVICE_CLASS,
.bDeviceSubClass = USB_CFG_DEVICE_SUBCLASS,
.bDeviceClass = 0x00,
.bDeviceSubClass = 0x00,
.bDeviceProtocol = 0x00,
.bMaxPacketSize0 = 8,
.idVendor = VENDOR_ID,
Expand All @@ -501,9 +500,7 @@ const PROGMEM usbDeviceDescriptor_t usbDeviceDescriptor = {
.iSerialNumber = 0x03,
.bNumConfigurations = 1
};
#endif

#if USB_CFG_DESCR_PROPS_CONFIGURATION
/*
* Configuration descriptors
*/
Expand Down Expand Up @@ -539,10 +536,10 @@ const PROGMEM usbConfigurationDescriptor_t usbConfigurationDescriptor = {
},
.bInterfaceNumber = 0,
.bAlternateSetting = 0x00,
.bNumEndpoints = USB_CFG_HAVE_INTRIN_ENDPOINT,
.bInterfaceClass = USB_CFG_INTERFACE_CLASS,
.bInterfaceSubClass = USB_CFG_INTERFACE_SUBCLASS,
.bInterfaceProtocol = USB_CFG_INTERFACE_PROTOCOL,
.bNumEndpoints = 1,
.bInterfaceClass = 0x03,
.bInterfaceSubClass = 0x01,
.bInterfaceProtocol = 0x01,
.iInterface = 0x00
},
.keyboardHID = {
Expand All @@ -556,7 +553,6 @@ const PROGMEM usbConfigurationDescriptor_t usbConfigurationDescriptor = {
.bDescriptorType = USBDESCR_HID_REPORT,
.wDescriptorLength = sizeof(keyboard_hid_report)
},
# ifdef USB_CFG_HAVE_INTRIN_ENDPOINT
.keyboardINEndpoint = {
.header = {
.bLength = sizeof(usbEndpointDescriptor_t),
Expand All @@ -567,7 +563,6 @@ const PROGMEM usbConfigurationDescriptor_t usbConfigurationDescriptor = {
.wMaxPacketSize = 8,
.bInterval = USB_POLLING_INTERVAL_MS
},
# endif

# if defined(MOUSE_ENABLE) || defined(EXTRAKEY_ENABLE)
/*
Expand All @@ -580,7 +575,7 @@ const PROGMEM usbConfigurationDescriptor_t usbConfigurationDescriptor = {
},
.bInterfaceNumber = 1,
.bAlternateSetting = 0x00,
.bNumEndpoints = USB_CFG_HAVE_INTRIN_ENDPOINT3,
.bNumEndpoints = 1,
.bInterfaceClass = 0x03,
.bInterfaceSubClass = 0x00,
.bInterfaceProtocol = 0x00,
Expand All @@ -597,7 +592,6 @@ const PROGMEM usbConfigurationDescriptor_t usbConfigurationDescriptor = {
.bDescriptorType = USBDESCR_HID_REPORT,
.wDescriptorLength = sizeof(mouse_extra_hid_report)
},
# if USB_CFG_HAVE_INTRIN_ENDPOINT3
fauxpark marked this conversation as resolved.
Show resolved Hide resolved
.mouseExtraINEndpoint = {
.header = {
.bLength = sizeof(usbEndpointDescriptor_t),
Expand All @@ -608,7 +602,6 @@ const PROGMEM usbConfigurationDescriptor_t usbConfigurationDescriptor = {
.wMaxPacketSize = 8,
.bInterval = USB_POLLING_INTERVAL_MS
}
# endif
# elif defined(RAW_ENABLE)
.rawInterface = {
.header = {
Expand All @@ -634,7 +627,6 @@ const PROGMEM usbConfigurationDescriptor_t usbConfigurationDescriptor = {
.bDescriptorType = USBDESCR_HID_REPORT,
.wDescriptorLength = sizeof(raw_hid_report)
},
# if USB_CFG_HAVE_INTRIN_ENDPOINT3
.rawINEndpoint = {
.header = {
.bLength = sizeof(usbEndpointDescriptor_t),
Expand All @@ -655,10 +647,8 @@ const PROGMEM usbConfigurationDescriptor_t usbConfigurationDescriptor = {
.wMaxPacketSize = RAW_EPSIZE,
.bInterval = USB_POLLING_INTERVAL_MS
}
# endif
# endif
};
#endif

// clang-format on

Expand All @@ -674,18 +664,14 @@ USB_PUBLIC usbMsgLen_t usbFunctionDescriptor(struct usbRequest *rq) {
debug_hex16(rq->wLength.word); debug("\n");
*/
switch (rq->wValue.bytes[1]) {
#if USB_CFG_DESCR_PROPS_DEVICE
case USBDESCR_DEVICE:
usbMsgPtr = (unsigned char *)&usbDeviceDescriptor;
len = sizeof(usbDeviceDescriptor_t);
break;
#endif
#if USB_CFG_DESCR_PROPS_CONFIGURATION
case USBDESCR_CONFIG:
usbMsgPtr = (unsigned char *)&usbConfigurationDescriptor;
len = sizeof(usbConfigurationDescriptor_t);
break;
#endif
case USBDESCR_STRING:
switch (rq->wValue.bytes[0]) {
case 0:
Expand Down
8 changes: 1 addition & 7 deletions tmk_core/protocol/vusb/vusb.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,23 +87,17 @@ typedef struct usbConfigurationDescriptor {
usbConfigurationDescriptorHeader_t header;
usbInterfaceDescriptor_t keyboardInterface;
usbHIDDescriptor_t keyboardHID;
#ifdef USB_CFG_HAVE_INTRIN_ENDPOINT
usbEndpointDescriptor_t keyboardINEndpoint;
#endif

#if defined(MOUSE_ENABLE) || defined(EXTRAKEY_ENABLE)
usbInterfaceDescriptor_t mouseExtraInterface;
usbHIDDescriptor_t mouseExtraHID;
# ifdef USB_CFG_HAVE_INTRIN_ENDPOINT3
usbEndpointDescriptor_t mouseExtraINEndpoint;
# endif
#elif defined(RAW_ENABLE)
usbInterfaceDescriptor_t rawInterface;
usbHIDDescriptor_t rawHID;
# ifdef USB_CFG_HAVE_INTRIN_ENDPOINT3
usbEndpointDescriptor_t rawINEndpoint;
usbEndpointDescriptor_t rawOUTEndpoint;
# endif
#endif
} __attribute__((packed)) usbConfigurationDescriptor_t;

Expand All @@ -112,6 +106,6 @@ typedef struct usbConfigurationDescriptor {
host_driver_t *vusb_driver(void);
void vusb_transfer_keyboard(void);

#if defined(RAW_ENABLE)
#ifdef RAW_ENABLE
void raw_hid_task(void);
#endif