diff options
author | Ryan <fauxpark@gmail.com> | 2020-03-28 13:02:25 +1100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-28 13:02:25 +1100 |
commit | 14079ce6984b359e080c85d9e9b8f7b8eb01437c (patch) | |
tree | 7da8f69e8611836197a926946204f04df0fc5140 /tmk_core/protocol/vusb/vusb.h | |
parent | 05d9a0ff036d91b7dc4e6198f4074161c1c7b633 (diff) | |
download | qmk_firmware-14079ce6984b359e080c85d9e9b8f7b8eb01437c.tar.gz qmk_firmware-14079ce6984b359e080c85d9e9b8f7b8eb01437c.zip |
V-USB: Use structs for USB descriptors (#8572)
* V-USB: Use structs for USB descriptors
* Update usbconfigs
* cformat pass
Diffstat (limited to 'tmk_core/protocol/vusb/vusb.h')
-rw-r--r-- | tmk_core/protocol/vusb/vusb.h | 76 |
1 files changed, 72 insertions, 4 deletions
diff --git a/tmk_core/protocol/vusb/vusb.h b/tmk_core/protocol/vusb/vusb.h index cee07207a..debac67d2 100644 --- a/tmk_core/protocol/vusb/vusb.h +++ b/tmk_core/protocol/vusb/vusb.h | |||
@@ -15,8 +15,7 @@ You should have received a copy of the GNU General Public License | |||
15 | along with this program. If not, see <http://www.gnu.org/licenses/>. | 15 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
16 | */ | 16 | */ |
17 | 17 | ||
18 | #ifndef VUSB_H | 18 | #pragma once |
19 | #define VUSB_H | ||
20 | 19 | ||
21 | #include "host_driver.h" | 20 | #include "host_driver.h" |
22 | 21 | ||
@@ -25,14 +24,83 @@ typedef struct usbDescriptorHeader { | |||
25 | uchar bDescriptorType; | 24 | uchar bDescriptorType; |
26 | } __attribute__((packed)) usbDescriptorHeader_t; | 25 | } __attribute__((packed)) usbDescriptorHeader_t; |
27 | 26 | ||
27 | typedef struct usbDeviceDescriptor { | ||
28 | usbDescriptorHeader_t header; | ||
29 | unsigned bcdUSB; | ||
30 | uchar bDeviceClass; | ||
31 | uchar bDeviceSubClass; | ||
32 | uchar bDeviceProtocol; | ||
33 | uchar bMaxPacketSize0; | ||
34 | unsigned idVendor; | ||
35 | unsigned idProduct; | ||
36 | unsigned bcdDevice; | ||
37 | uchar iManufacturer; | ||
38 | uchar iProduct; | ||
39 | uchar iSerialNumber; | ||
40 | uchar bNumConfigurations; | ||
41 | } __attribute__((packed)) usbDeviceDescriptor_t; | ||
42 | |||
43 | typedef struct usbConfigurationDescriptorHeader { | ||
44 | usbDescriptorHeader_t header; | ||
45 | unsigned wTotalLength; | ||
46 | uchar bNumInterfaces; | ||
47 | uchar bConfigurationValue; | ||
48 | uchar iConfiguration; | ||
49 | uchar bmAttributes; | ||
50 | uchar bMaxPower; | ||
51 | } __attribute__((packed)) usbConfigurationDescriptorHeader_t; | ||
52 | |||
28 | typedef struct usbStringDescriptor { | 53 | typedef struct usbStringDescriptor { |
29 | usbDescriptorHeader_t header; | 54 | usbDescriptorHeader_t header; |
30 | int bString[]; | 55 | int bString[]; |
31 | } __attribute__((packed)) usbStringDescriptor_t; | 56 | } __attribute__((packed)) usbStringDescriptor_t; |
32 | 57 | ||
58 | typedef struct usbInterfaceDescriptor { | ||
59 | usbDescriptorHeader_t header; | ||
60 | uchar bInterfaceNumber; | ||
61 | uchar bAlternateSetting; | ||
62 | uchar bNumEndpoints; | ||
63 | uchar bInterfaceClass; | ||
64 | uchar bInterfaceSubClass; | ||
65 | uchar bInterfaceProtocol; | ||
66 | uchar iInterface; | ||
67 | } __attribute__((packed)) usbInterfaceDescriptor_t; | ||
68 | |||
69 | typedef struct usbEndpointDescriptor { | ||
70 | usbDescriptorHeader_t header; | ||
71 | uchar bEndpointAddress; | ||
72 | uchar bmAttributes; | ||
73 | unsigned wMaxPacketSize; | ||
74 | uchar bInterval; | ||
75 | } __attribute__((packed)) usbEndpointDescriptor_t; | ||
76 | |||
77 | typedef struct usbHIDDescriptor { | ||
78 | usbDescriptorHeader_t header; | ||
79 | unsigned bcdHID; | ||
80 | uchar bCountryCode; | ||
81 | uchar bNumDescriptors; | ||
82 | uchar bDescriptorType; | ||
83 | unsigned wDescriptorLength; | ||
84 | } __attribute__((packed)) usbHIDDescriptor_t; | ||
85 | |||
86 | typedef struct usbConfigurationDescriptor { | ||
87 | usbConfigurationDescriptorHeader_t header; | ||
88 | usbInterfaceDescriptor_t keyboardInterface; | ||
89 | usbHIDDescriptor_t keyboardHID; | ||
90 | #ifdef USB_CFG_HAVE_INTRIN_ENDPOINT | ||
91 | usbEndpointDescriptor_t keyboardINEndpoint; | ||
92 | #endif | ||
93 | |||
94 | #if defined(MOUSE_ENABLE) || defined(EXTRAKEY_ENABLE) | ||
95 | usbInterfaceDescriptor_t mouseExtraInterface; | ||
96 | usbHIDDescriptor_t mouseExtraHID; | ||
97 | # ifdef USB_CFG_HAVE_INTRIN_ENDPOINT3 | ||
98 | usbEndpointDescriptor_t mouseExtraINEndpoint; | ||
99 | # endif | ||
100 | #endif | ||
101 | } __attribute__((packed)) usbConfigurationDescriptor_t; | ||
102 | |||
33 | #define USB_STRING_LEN(s) (sizeof(usbDescriptorHeader_t) + ((s) << 1)) | 103 | #define USB_STRING_LEN(s) (sizeof(usbDescriptorHeader_t) + ((s) << 1)) |
34 | 104 | ||
35 | host_driver_t *vusb_driver(void); | 105 | host_driver_t *vusb_driver(void); |
36 | void vusb_transfer_keyboard(void); | 106 | void vusb_transfer_keyboard(void); |
37 | |||
38 | #endif | ||