diff options
author | Ryan <fauxpark@gmail.com> | 2020-06-07 15:00:21 +1000 |
---|---|---|
committer | James Young <18669334+noroadsleft@users.noreply.github.com> | 2020-08-29 14:30:02 -0700 |
commit | f209f91c7ce073aa0381e79c10219616cb7db523 (patch) | |
tree | e27464d1c993f960f508edbd52a47c646cfaee42 /tmk_core/protocol | |
parent | 385d49cc39b57e74203e0c1c78c0789d249e4742 (diff) | |
download | qmk_firmware-f209f91c7ce073aa0381e79c10219616cb7db523.tar.gz qmk_firmware-f209f91c7ce073aa0381e79c10219616cb7db523.zip |
Various tidyups for USB descriptor code (#9005)
Diffstat (limited to 'tmk_core/protocol')
-rw-r--r-- | tmk_core/protocol/chibios/usb_main.c | 8 | ||||
-rw-r--r-- | tmk_core/protocol/lufa/lufa.c | 120 | ||||
-rw-r--r-- | tmk_core/protocol/lufa/lufa.h | 4 | ||||
-rw-r--r-- | tmk_core/protocol/usb_descriptor.c | 10 | ||||
-rw-r--r-- | tmk_core/protocol/usb_descriptor.h | 5 | ||||
-rw-r--r-- | tmk_core/protocol/vusb/vusb.c | 24 |
6 files changed, 80 insertions, 91 deletions
diff --git a/tmk_core/protocol/chibios/usb_main.c b/tmk_core/protocol/chibios/usb_main.c index 65bd291be..9d68419f4 100644 --- a/tmk_core/protocol/chibios/usb_main.c +++ b/tmk_core/protocol/chibios/usb_main.c | |||
@@ -62,7 +62,7 @@ extern keymap_config_t keymap_config; | |||
62 | 62 | ||
63 | uint8_t keyboard_idle __attribute__((aligned(2))) = 0; | 63 | uint8_t keyboard_idle __attribute__((aligned(2))) = 0; |
64 | uint8_t keyboard_protocol __attribute__((aligned(2))) = 1; | 64 | uint8_t keyboard_protocol __attribute__((aligned(2))) = 1; |
65 | uint8_t keyboard_led_stats = 0; | 65 | uint8_t keyboard_led_state = 0; |
66 | volatile uint16_t keyboard_idle_count = 0; | 66 | volatile uint16_t keyboard_idle_count = 0; |
67 | static virtual_timer_t keyboard_idle_timer; | 67 | static virtual_timer_t keyboard_idle_timer; |
68 | static void keyboard_idle_timer_cb(void *arg); | 68 | static void keyboard_idle_timer_cb(void *arg); |
@@ -386,10 +386,10 @@ static void set_led_transfer_cb(USBDriver *usbp) { | |||
386 | if (usbp->setup[6] == 2) { /* LSB(wLength) */ | 386 | if (usbp->setup[6] == 2) { /* LSB(wLength) */ |
387 | uint8_t report_id = set_report_buf[0]; | 387 | uint8_t report_id = set_report_buf[0]; |
388 | if ((report_id == REPORT_ID_KEYBOARD) || (report_id == REPORT_ID_NKRO)) { | 388 | if ((report_id == REPORT_ID_KEYBOARD) || (report_id == REPORT_ID_NKRO)) { |
389 | keyboard_led_stats = set_report_buf[1]; | 389 | keyboard_led_state = set_report_buf[1]; |
390 | } | 390 | } |
391 | } else { | 391 | } else { |
392 | keyboard_led_stats = set_report_buf[0]; | 392 | keyboard_led_state = set_report_buf[0]; |
393 | } | 393 | } |
394 | } | 394 | } |
395 | 395 | ||
@@ -610,7 +610,7 @@ static void keyboard_idle_timer_cb(void *arg) { | |||
610 | } | 610 | } |
611 | 611 | ||
612 | /* LED status */ | 612 | /* LED status */ |
613 | uint8_t keyboard_leds(void) { return keyboard_led_stats; } | 613 | uint8_t keyboard_leds(void) { return keyboard_led_state; } |
614 | 614 | ||
615 | /* prepare and start sending a report IN | 615 | /* prepare and start sending a report IN |
616 | * not callable from ISR or locked state */ | 616 | * not callable from ISR or locked state */ |
diff --git a/tmk_core/protocol/lufa/lufa.c b/tmk_core/protocol/lufa/lufa.c index 374add20f..19f417770 100644 --- a/tmk_core/protocol/lufa/lufa.c +++ b/tmk_core/protocol/lufa/lufa.c | |||
@@ -88,7 +88,7 @@ extern keymap_config_t keymap_config; | |||
88 | uint8_t keyboard_idle = 0; | 88 | uint8_t keyboard_idle = 0; |
89 | /* 0: Boot Protocol, 1: Report Protocol(default) */ | 89 | /* 0: Boot Protocol, 1: Report Protocol(default) */ |
90 | uint8_t keyboard_protocol = 1; | 90 | uint8_t keyboard_protocol = 1; |
91 | static uint8_t keyboard_led_stats = 0; | 91 | static uint8_t keyboard_led_state = 0; |
92 | 92 | ||
93 | static report_keyboard_t keyboard_report_sent; | 93 | static report_keyboard_t keyboard_report_sent; |
94 | 94 | ||
@@ -103,30 +103,30 @@ host_driver_t lufa_driver = { | |||
103 | }; | 103 | }; |
104 | 104 | ||
105 | #ifdef VIRTSER_ENABLE | 105 | #ifdef VIRTSER_ENABLE |
106 | // clang-format off | ||
107 | |||
106 | USB_ClassInfo_CDC_Device_t cdc_device = { | 108 | USB_ClassInfo_CDC_Device_t cdc_device = { |
107 | .Config = | 109 | .Config = { |
108 | { | 110 | .ControlInterfaceNumber = CCI_INTERFACE, |
109 | .ControlInterfaceNumber = CCI_INTERFACE, | 111 | .DataINEndpoint = { |
110 | .DataINEndpoint = | 112 | .Address = (CDC_IN_EPNUM | ENDPOINT_DIR_IN), |
111 | { | 113 | .Size = CDC_EPSIZE, |
112 | .Address = CDC_IN_EPADDR, | 114 | .Banks = 1 |
113 | .Size = CDC_EPSIZE, | 115 | }, |
114 | .Banks = 1, | 116 | .DataOUTEndpoint = { |
115 | }, | 117 | .Address = (CDC_OUT_EPNUM | ENDPOINT_DIR_OUT), |
116 | .DataOUTEndpoint = | 118 | .Size = CDC_EPSIZE, |
117 | { | 119 | .Banks = 1 |
118 | .Address = CDC_OUT_EPADDR, | ||
119 | .Size = CDC_EPSIZE, | ||
120 | .Banks = 1, | ||
121 | }, | ||
122 | .NotificationEndpoint = | ||
123 | { | ||
124 | .Address = CDC_NOTIFICATION_EPADDR, | ||
125 | .Size = CDC_NOTIFICATION_EPSIZE, | ||
126 | .Banks = 1, | ||
127 | }, | ||
128 | }, | 120 | }, |
121 | .NotificationEndpoint = { | ||
122 | .Address = (CDC_NOTIFICATION_EPNUM | ENDPOINT_DIR_IN), | ||
123 | .Size = CDC_NOTIFICATION_EPSIZE, | ||
124 | .Banks = 1 | ||
125 | } | ||
126 | } | ||
129 | }; | 127 | }; |
128 | |||
129 | // clang-format on | ||
130 | #endif | 130 | #endif |
131 | 131 | ||
132 | #ifdef RAW_ENABLE | 132 | #ifdef RAW_ENABLE |
@@ -254,7 +254,7 @@ static void Console_Task(void) { | |||
254 | // fill empty bank | 254 | // fill empty bank |
255 | while (Endpoint_IsReadWriteAllowed()) Endpoint_Write_8(0); | 255 | while (Endpoint_IsReadWriteAllowed()) Endpoint_Write_8(0); |
256 | 256 | ||
257 | // flash senchar packet | 257 | // flush sendchar packet |
258 | if (Endpoint_IsINReady()) { | 258 | if (Endpoint_IsINReady()) { |
259 | Endpoint_ClearIN(); | 259 | Endpoint_ClearIN(); |
260 | } | 260 | } |
@@ -370,45 +370,46 @@ void EVENT_USB_Device_StartOfFrame(void) { | |||
370 | void EVENT_USB_Device_ConfigurationChanged(void) { | 370 | void EVENT_USB_Device_ConfigurationChanged(void) { |
371 | bool ConfigSuccess = true; | 371 | bool ConfigSuccess = true; |
372 | 372 | ||
373 | /* Setup Keyboard HID Report Endpoints */ | ||
374 | #ifndef KEYBOARD_SHARED_EP | 373 | #ifndef KEYBOARD_SHARED_EP |
375 | ConfigSuccess &= ENDPOINT_CONFIG(KEYBOARD_IN_EPNUM, EP_TYPE_INTERRUPT, ENDPOINT_DIR_IN, KEYBOARD_EPSIZE, ENDPOINT_BANK_SINGLE); | 374 | /* Setup keyboard report endpoint */ |
375 | ConfigSuccess &= Endpoint_ConfigureEndpoint((KEYBOARD_IN_EPNUM | ENDPOINT_DIR_IN), EP_TYPE_INTERRUPT, KEYBOARD_EPSIZE, 1); | ||
376 | #endif | 376 | #endif |
377 | 377 | ||
378 | #if defined(MOUSE_ENABLE) && !defined(MOUSE_SHARED_EP) | 378 | #if defined(MOUSE_ENABLE) && !defined(MOUSE_SHARED_EP) |
379 | /* Setup Mouse HID Report Endpoint */ | 379 | /* Setup mouse report endpoint */ |
380 | ConfigSuccess &= ENDPOINT_CONFIG(MOUSE_IN_EPNUM, EP_TYPE_INTERRUPT, ENDPOINT_DIR_IN, MOUSE_EPSIZE, ENDPOINT_BANK_SINGLE); | 380 | ConfigSuccess &= Endpoint_ConfigureEndpoint((MOUSE_IN_EPNUM | ENDPOINT_DIR_IN), EP_TYPE_INTERRUPT, MOUSE_EPSIZE, 1); |
381 | #endif | 381 | #endif |
382 | 382 | ||
383 | #ifdef SHARED_EP_ENABLE | 383 | #ifdef SHARED_EP_ENABLE |
384 | /* Setup Shared HID Report Endpoint */ | 384 | /* Setup shared report endpoint */ |
385 | ConfigSuccess &= ENDPOINT_CONFIG(SHARED_IN_EPNUM, EP_TYPE_INTERRUPT, ENDPOINT_DIR_IN, SHARED_EPSIZE, ENDPOINT_BANK_SINGLE); | 385 | ConfigSuccess &= Endpoint_ConfigureEndpoint((SHARED_IN_EPNUM | ENDPOINT_DIR_IN), EP_TYPE_INTERRUPT, SHARED_EPSIZE, 1); |
386 | #endif | 386 | #endif |
387 | 387 | ||
388 | #ifdef RAW_ENABLE | 388 | #ifdef RAW_ENABLE |
389 | /* Setup Raw HID Report Endpoints */ | 389 | /* Setup raw HID endpoints */ |
390 | ConfigSuccess &= ENDPOINT_CONFIG(RAW_IN_EPNUM, EP_TYPE_INTERRUPT, ENDPOINT_DIR_IN, RAW_EPSIZE, ENDPOINT_BANK_SINGLE); | 390 | ConfigSuccess &= Endpoint_ConfigureEndpoint((RAW_IN_EPNUM | ENDPOINT_DIR_IN), EP_TYPE_INTERRUPT, RAW_EPSIZE, 1); |
391 | ConfigSuccess &= ENDPOINT_CONFIG(RAW_OUT_EPNUM, EP_TYPE_INTERRUPT, ENDPOINT_DIR_OUT, RAW_EPSIZE, ENDPOINT_BANK_SINGLE); | 391 | ConfigSuccess &= Endpoint_ConfigureEndpoint((RAW_OUT_EPNUM | ENDPOINT_DIR_OUT), EP_TYPE_INTERRUPT, RAW_EPSIZE, 1); |
392 | #endif | 392 | #endif |
393 | 393 | ||
394 | #ifdef CONSOLE_ENABLE | 394 | #ifdef CONSOLE_ENABLE |
395 | /* Setup Console HID Report Endpoints */ | 395 | /* Setup console endpoint */ |
396 | ConfigSuccess &= ENDPOINT_CONFIG(CONSOLE_IN_EPNUM, EP_TYPE_INTERRUPT, ENDPOINT_DIR_IN, CONSOLE_EPSIZE, ENDPOINT_BANK_SINGLE); | 396 | ConfigSuccess &= Endpoint_ConfigureEndpoint((CONSOLE_IN_EPNUM | ENDPOINT_DIR_IN), EP_TYPE_INTERRUPT, CONSOLE_EPSIZE, 1); |
397 | # if 0 | 397 | # if 0 |
398 | ConfigSuccess &= ENDPOINT_CONFIG(CONSOLE_OUT_EPNUM, EP_TYPE_INTERRUPT, ENDPOINT_DIR_OUT, | 398 | ConfigSuccess &= Endpoint_ConfigureEndpoint((CONSOLE_OUT_EPNUM | ENDPOINT_DIR_OUT), EP_TYPE_INTERRUPT, CONSOLE_EPSIZE, 1); |
399 | CONSOLE_EPSIZE, ENDPOINT_BANK_SINGLE); | ||
400 | # endif | 399 | # endif |
401 | #endif | 400 | #endif |
402 | 401 | ||
403 | #ifdef MIDI_ENABLE | 402 | #ifdef MIDI_ENABLE |
404 | ConfigSuccess &= Endpoint_ConfigureEndpoint(MIDI_STREAM_IN_EPADDR, EP_TYPE_BULK, MIDI_STREAM_EPSIZE, ENDPOINT_BANK_SINGLE); | 403 | /* Setup MIDI stream endpoints */ |
405 | ConfigSuccess &= Endpoint_ConfigureEndpoint(MIDI_STREAM_OUT_EPADDR, EP_TYPE_BULK, MIDI_STREAM_EPSIZE, ENDPOINT_BANK_SINGLE); | 404 | ConfigSuccess &= Endpoint_ConfigureEndpoint((MIDI_STREAM_IN_EPNUM | ENDPOINT_DIR_IN), EP_TYPE_BULK, MIDI_STREAM_EPSIZE, 1); |
405 | ConfigSuccess &= Endpoint_ConfigureEndpoint((MIDI_STREAM_OUT_EPNUM | ENDPOINT_DIR_IN), EP_TYPE_BULK, MIDI_STREAM_EPSIZE, 1); | ||
406 | #endif | 406 | #endif |
407 | 407 | ||
408 | #ifdef VIRTSER_ENABLE | 408 | #ifdef VIRTSER_ENABLE |
409 | ConfigSuccess &= Endpoint_ConfigureEndpoint(CDC_NOTIFICATION_EPADDR, EP_TYPE_INTERRUPT, CDC_NOTIFICATION_EPSIZE, ENDPOINT_BANK_SINGLE); | 409 | /* Setup virtual serial endpoints */ |
410 | ConfigSuccess &= Endpoint_ConfigureEndpoint(CDC_OUT_EPADDR, EP_TYPE_BULK, CDC_EPSIZE, ENDPOINT_BANK_SINGLE); | 410 | ConfigSuccess &= Endpoint_ConfigureEndpoint((CDC_NOTIFICATION_EPNUM | ENDPOINT_DIR_IN), EP_TYPE_INTERRUPT, CDC_NOTIFICATION_EPSIZE, 1); |
411 | ConfigSuccess &= Endpoint_ConfigureEndpoint(CDC_IN_EPADDR, EP_TYPE_BULK, CDC_EPSIZE, ENDPOINT_BANK_SINGLE); | 411 | ConfigSuccess &= Endpoint_ConfigureEndpoint((CDC_OUT_EPNUM | ENDPOINT_DIR_OUT), EP_TYPE_BULK, CDC_EPSIZE, 1); |
412 | ConfigSuccess &= Endpoint_ConfigureEndpoint((CDC_IN_EPNUM | ENDPOINT_DIR_IN), EP_TYPE_BULK, CDC_EPSIZE, 1); | ||
412 | #endif | 413 | #endif |
413 | } | 414 | } |
414 | 415 | ||
@@ -472,10 +473,10 @@ void EVENT_USB_Device_ControlRequest(void) { | |||
472 | uint8_t report_id = Endpoint_Read_8(); | 473 | uint8_t report_id = Endpoint_Read_8(); |
473 | 474 | ||
474 | if (report_id == REPORT_ID_KEYBOARD || report_id == REPORT_ID_NKRO) { | 475 | if (report_id == REPORT_ID_KEYBOARD || report_id == REPORT_ID_NKRO) { |
475 | keyboard_led_stats = Endpoint_Read_8(); | 476 | keyboard_led_state = Endpoint_Read_8(); |
476 | } | 477 | } |
477 | } else { | 478 | } else { |
478 | keyboard_led_stats = Endpoint_Read_8(); | 479 | keyboard_led_state = Endpoint_Read_8(); |
479 | } | 480 | } |
480 | 481 | ||
481 | Endpoint_ClearOUT(); | 482 | Endpoint_ClearOUT(); |
@@ -545,7 +546,7 @@ void EVENT_USB_Device_ControlRequest(void) { | |||
545 | * | 546 | * |
546 | * FIXME: Needs doc | 547 | * FIXME: Needs doc |
547 | */ | 548 | */ |
548 | static uint8_t keyboard_leds(void) { return keyboard_led_stats; } | 549 | static uint8_t keyboard_leds(void) { return keyboard_led_state; } |
549 | 550 | ||
550 | /** \brief Send Keyboard | 551 | /** \brief Send Keyboard |
551 | * | 552 | * |
@@ -808,25 +809,26 @@ ERROR_EXIT: | |||
808 | ******************************************************************************/ | 809 | ******************************************************************************/ |
809 | 810 | ||
810 | #ifdef MIDI_ENABLE | 811 | #ifdef MIDI_ENABLE |
812 | // clang-format off | ||
813 | |||
811 | USB_ClassInfo_MIDI_Device_t USB_MIDI_Interface = { | 814 | USB_ClassInfo_MIDI_Device_t USB_MIDI_Interface = { |
812 | .Config = | 815 | .Config = { |
813 | { | 816 | .StreamingInterfaceNumber = AS_INTERFACE, |
814 | .StreamingInterfaceNumber = AS_INTERFACE, | 817 | .DataINEndpoint = { |
815 | .DataINEndpoint = | 818 | .Address = (MIDI_STREAM_IN_EPNUM | ENDPOINT_DIR_IN), |
816 | { | 819 | .Size = MIDI_STREAM_EPSIZE, |
817 | .Address = MIDI_STREAM_IN_EPADDR, | 820 | .Banks = 1 |
818 | .Size = MIDI_STREAM_EPSIZE, | ||
819 | .Banks = 1, | ||
820 | }, | ||
821 | .DataOUTEndpoint = | ||
822 | { | ||
823 | .Address = MIDI_STREAM_OUT_EPADDR, | ||
824 | .Size = MIDI_STREAM_EPSIZE, | ||
825 | .Banks = 1, | ||
826 | }, | ||
827 | }, | 821 | }, |
822 | .DataOUTEndpoint = { | ||
823 | .Address = (MIDI_STREAM_OUT_EPNUM | ENDPOINT_DIR_OUT), | ||
824 | .Size = MIDI_STREAM_EPSIZE, | ||
825 | .Banks = 1 | ||
826 | } | ||
827 | } | ||
828 | }; | 828 | }; |
829 | 829 | ||
830 | // clang-format on | ||
831 | |||
830 | void send_midi_packet(MIDI_EventPacket_t *event) { MIDI_Device_SendEventPacket(&USB_MIDI_Interface, event); } | 832 | void send_midi_packet(MIDI_EventPacket_t *event) { MIDI_Device_SendEventPacket(&USB_MIDI_Interface, event); } |
831 | 833 | ||
832 | bool recv_midi_packet(MIDI_EventPacket_t *const event) { return MIDI_Device_ReceiveEventPacket(&USB_MIDI_Interface, event); } | 834 | bool recv_midi_packet(MIDI_EventPacket_t *const event) { return MIDI_Device_ReceiveEventPacket(&USB_MIDI_Interface, event); } |
diff --git a/tmk_core/protocol/lufa/lufa.h b/tmk_core/protocol/lufa/lufa.h index 82a5f8e05..71fd7aad8 100644 --- a/tmk_core/protocol/lufa/lufa.h +++ b/tmk_core/protocol/lufa/lufa.h | |||
@@ -69,8 +69,4 @@ extern host_driver_t lufa_driver; | |||
69 | # define MIDI_SYSEX_BUFFER (API_SYSEX_MAX_SIZE + API_SYSEX_MAX_SIZE / 7 + (API_SYSEX_MAX_SIZE % 7 ? 1 : 0)) | 69 | # define MIDI_SYSEX_BUFFER (API_SYSEX_MAX_SIZE + API_SYSEX_MAX_SIZE / 7 + (API_SYSEX_MAX_SIZE % 7 ? 1 : 0)) |
70 | #endif | 70 | #endif |
71 | 71 | ||
72 | #define ENDPOINT_BANK_SINGLE 1 | ||
73 | #define ENDPOINT_BANK_DOUBLE 2 | ||
74 | #define ENDPOINT_CONFIG(epnum, eptype, epdir, epsize, epbank) Endpoint_ConfigureEndpoint((epdir) | (epnum), eptype, epsize, epbank) | ||
75 | |||
76 | #endif | 72 | #endif |
diff --git a/tmk_core/protocol/usb_descriptor.c b/tmk_core/protocol/usb_descriptor.c index 8c71dd1dd..bcca24586 100644 --- a/tmk_core/protocol/usb_descriptor.c +++ b/tmk_core/protocol/usb_descriptor.c | |||
@@ -673,7 +673,7 @@ const USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor = { | |||
673 | .Size = sizeof(USB_Audio_Descriptor_StreamEndpoint_Std_t), | 673 | .Size = sizeof(USB_Audio_Descriptor_StreamEndpoint_Std_t), |
674 | .Type = DTYPE_Endpoint | 674 | .Type = DTYPE_Endpoint |
675 | }, | 675 | }, |
676 | .EndpointAddress = MIDI_STREAM_OUT_EPADDR, | 676 | .EndpointAddress = (ENDPOINT_DIR_OUT | MIDI_STREAM_OUT_EPNUM), |
677 | .Attributes = (EP_TYPE_BULK | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA), | 677 | .Attributes = (EP_TYPE_BULK | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA), |
678 | .EndpointSize = MIDI_STREAM_EPSIZE, | 678 | .EndpointSize = MIDI_STREAM_EPSIZE, |
679 | .PollingIntervalMS = 0x05 | 679 | .PollingIntervalMS = 0x05 |
@@ -696,7 +696,7 @@ const USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor = { | |||
696 | .Size = sizeof(USB_Audio_Descriptor_StreamEndpoint_Std_t), | 696 | .Size = sizeof(USB_Audio_Descriptor_StreamEndpoint_Std_t), |
697 | .Type = DTYPE_Endpoint | 697 | .Type = DTYPE_Endpoint |
698 | }, | 698 | }, |
699 | .EndpointAddress = MIDI_STREAM_IN_EPADDR, | 699 | .EndpointAddress = (ENDPOINT_DIR_IN | MIDI_STREAM_IN_EPNUM), |
700 | .Attributes = (EP_TYPE_BULK | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA), | 700 | .Attributes = (EP_TYPE_BULK | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA), |
701 | .EndpointSize = MIDI_STREAM_EPSIZE, | 701 | .EndpointSize = MIDI_STREAM_EPSIZE, |
702 | .PollingIntervalMS = 0x05 | 702 | .PollingIntervalMS = 0x05 |
@@ -774,7 +774,7 @@ const USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor = { | |||
774 | .Size = sizeof(USB_Descriptor_Endpoint_t), | 774 | .Size = sizeof(USB_Descriptor_Endpoint_t), |
775 | .Type = DTYPE_Endpoint | 775 | .Type = DTYPE_Endpoint |
776 | }, | 776 | }, |
777 | .EndpointAddress = CDC_NOTIFICATION_EPADDR, | 777 | .EndpointAddress = (ENDPOINT_DIR_IN | CDC_NOTIFICATION_EPNUM), |
778 | .Attributes = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA), | 778 | .Attributes = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA), |
779 | .EndpointSize = CDC_NOTIFICATION_EPSIZE, | 779 | .EndpointSize = CDC_NOTIFICATION_EPSIZE, |
780 | .PollingIntervalMS = 0xFF | 780 | .PollingIntervalMS = 0xFF |
@@ -797,7 +797,7 @@ const USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor = { | |||
797 | .Size = sizeof(USB_Descriptor_Endpoint_t), | 797 | .Size = sizeof(USB_Descriptor_Endpoint_t), |
798 | .Type = DTYPE_Endpoint | 798 | .Type = DTYPE_Endpoint |
799 | }, | 799 | }, |
800 | .EndpointAddress = CDC_OUT_EPADDR, | 800 | .EndpointAddress = (ENDPOINT_DIR_OUT | CDC_OUT_EPNUM), |
801 | .Attributes = (EP_TYPE_BULK | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA), | 801 | .Attributes = (EP_TYPE_BULK | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA), |
802 | .EndpointSize = CDC_EPSIZE, | 802 | .EndpointSize = CDC_EPSIZE, |
803 | .PollingIntervalMS = 0x05 | 803 | .PollingIntervalMS = 0x05 |
@@ -807,7 +807,7 @@ const USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor = { | |||
807 | .Size = sizeof(USB_Descriptor_Endpoint_t), | 807 | .Size = sizeof(USB_Descriptor_Endpoint_t), |
808 | .Type = DTYPE_Endpoint | 808 | .Type = DTYPE_Endpoint |
809 | }, | 809 | }, |
810 | .EndpointAddress = CDC_IN_EPADDR, | 810 | .EndpointAddress = (ENDPOINT_DIR_IN | CDC_IN_EPNUM), |
811 | .Attributes = (EP_TYPE_BULK | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA), | 811 | .Attributes = (EP_TYPE_BULK | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA), |
812 | .EndpointSize = CDC_EPSIZE, | 812 | .EndpointSize = CDC_EPSIZE, |
813 | .PollingIntervalMS = 0x05 | 813 | .PollingIntervalMS = 0x05 |
diff --git a/tmk_core/protocol/usb_descriptor.h b/tmk_core/protocol/usb_descriptor.h index b2423fa7e..34a85978a 100644 --- a/tmk_core/protocol/usb_descriptor.h +++ b/tmk_core/protocol/usb_descriptor.h | |||
@@ -212,17 +212,12 @@ enum usb_endpoints { | |||
212 | #ifdef MIDI_ENABLE | 212 | #ifdef MIDI_ENABLE |
213 | MIDI_STREAM_IN_EPNUM = NEXT_EPNUM, | 213 | MIDI_STREAM_IN_EPNUM = NEXT_EPNUM, |
214 | MIDI_STREAM_OUT_EPNUM = NEXT_EPNUM, | 214 | MIDI_STREAM_OUT_EPNUM = NEXT_EPNUM, |
215 | # define MIDI_STREAM_IN_EPADDR (ENDPOINT_DIR_IN | MIDI_STREAM_IN_EPNUM) | ||
216 | # define MIDI_STREAM_OUT_EPADDR (ENDPOINT_DIR_OUT | MIDI_STREAM_OUT_EPNUM) | ||
217 | #endif | 215 | #endif |
218 | 216 | ||
219 | #ifdef VIRTSER_ENABLE | 217 | #ifdef VIRTSER_ENABLE |
220 | CDC_NOTIFICATION_EPNUM = NEXT_EPNUM, | 218 | CDC_NOTIFICATION_EPNUM = NEXT_EPNUM, |
221 | CDC_IN_EPNUM = NEXT_EPNUM, | 219 | CDC_IN_EPNUM = NEXT_EPNUM, |
222 | CDC_OUT_EPNUM = NEXT_EPNUM, | 220 | CDC_OUT_EPNUM = NEXT_EPNUM, |
223 | # define CDC_NOTIFICATION_EPADDR (ENDPOINT_DIR_IN | CDC_NOTIFICATION_EPNUM) | ||
224 | # define CDC_IN_EPADDR (ENDPOINT_DIR_IN | CDC_IN_EPNUM) | ||
225 | # define CDC_OUT_EPADDR (ENDPOINT_DIR_OUT | CDC_OUT_EPNUM) | ||
226 | #endif | 221 | #endif |
227 | }; | 222 | }; |
228 | 223 | ||
diff --git a/tmk_core/protocol/vusb/vusb.c b/tmk_core/protocol/vusb/vusb.c index 5feff889a..f4727a0c3 100644 --- a/tmk_core/protocol/vusb/vusb.c +++ b/tmk_core/protocol/vusb/vusb.c | |||
@@ -65,7 +65,7 @@ enum usb_interfaces { | |||
65 | # 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 | 65 | # 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 |
66 | #endif | 66 | #endif |
67 | 67 | ||
68 | static uint8_t vusb_keyboard_leds = 0; | 68 | static uint8_t keyboard_led_state = 0; |
69 | static uint8_t vusb_idle_rate = 0; | 69 | static uint8_t vusb_idle_rate = 0; |
70 | 70 | ||
71 | /* Keyboard report send buffer */ | 71 | /* Keyboard report send buffer */ |
@@ -74,13 +74,7 @@ static report_keyboard_t kbuf[KBUF_SIZE]; | |||
74 | static uint8_t kbuf_head = 0; | 74 | static uint8_t kbuf_head = 0; |
75 | static uint8_t kbuf_tail = 0; | 75 | static uint8_t kbuf_tail = 0; |
76 | 76 | ||
77 | typedef struct { | 77 | static report_keyboard_t keyboard_report_sent; |
78 | uint8_t modifier; | ||
79 | uint8_t reserved; | ||
80 | uint8_t keycode[6]; | ||
81 | } keyboard_report_t; | ||
82 | |||
83 | static keyboard_report_t keyboard_report; // sent to PC | ||
84 | 78 | ||
85 | #define VUSB_TRANSFER_KEYBOARD_MAX_TRIES 10 | 79 | #define VUSB_TRANSFER_KEYBOARD_MAX_TRIES 10 |
86 | 80 | ||
@@ -218,7 +212,7 @@ static host_driver_t driver = {keyboard_leds, send_keyboard, send_mouse, send_sy | |||
218 | 212 | ||
219 | host_driver_t *vusb_driver(void) { return &driver; } | 213 | host_driver_t *vusb_driver(void) { return &driver; } |
220 | 214 | ||
221 | static uint8_t keyboard_leds(void) { return vusb_keyboard_leds; } | 215 | static uint8_t keyboard_leds(void) { return keyboard_led_state; } |
222 | 216 | ||
223 | static void send_keyboard(report_keyboard_t *report) { | 217 | static void send_keyboard(report_keyboard_t *report) { |
224 | uint8_t next = (kbuf_head + 1) % KBUF_SIZE; | 218 | uint8_t next = (kbuf_head + 1) % KBUF_SIZE; |
@@ -232,6 +226,7 @@ static void send_keyboard(report_keyboard_t *report) { | |||
232 | // NOTE: send key strokes of Macro | 226 | // NOTE: send key strokes of Macro |
233 | usbPoll(); | 227 | usbPoll(); |
234 | vusb_transfer_keyboard(); | 228 | vusb_transfer_keyboard(); |
229 | keyboard_report_sent = *report; | ||
235 | } | 230 | } |
236 | 231 | ||
237 | typedef struct { | 232 | typedef struct { |
@@ -289,9 +284,10 @@ usbMsgLen_t usbFunctionSetup(uchar data[8]) { | |||
289 | if ((rq->bmRequestType & USBRQ_TYPE_MASK) == USBRQ_TYPE_CLASS) { /* class request type */ | 284 | if ((rq->bmRequestType & USBRQ_TYPE_MASK) == USBRQ_TYPE_CLASS) { /* class request type */ |
290 | if (rq->bRequest == USBRQ_HID_GET_REPORT) { | 285 | if (rq->bRequest == USBRQ_HID_GET_REPORT) { |
291 | debug("GET_REPORT:"); | 286 | debug("GET_REPORT:"); |
292 | /* we only have one report type, so don't look at wValue */ | 287 | if (rq->wIndex.word == KEYBOARD_INTERFACE) { |
293 | usbMsgPtr = (usbMsgPtr_t)&keyboard_report; | 288 | usbMsgPtr = (usbMsgPtr_t)&keyboard_report_sent; |
294 | return sizeof(keyboard_report); | 289 | return sizeof(keyboard_report_sent); |
290 | } | ||
295 | } else if (rq->bRequest == USBRQ_HID_GET_IDLE) { | 291 | } else if (rq->bRequest == USBRQ_HID_GET_IDLE) { |
296 | debug("GET_IDLE: "); | 292 | debug("GET_IDLE: "); |
297 | // debug_hex(vusb_idle_rate); | 293 | // debug_hex(vusb_idle_rate); |
@@ -304,7 +300,7 @@ usbMsgLen_t usbFunctionSetup(uchar data[8]) { | |||
304 | } else if (rq->bRequest == USBRQ_HID_SET_REPORT) { | 300 | } else if (rq->bRequest == USBRQ_HID_SET_REPORT) { |
305 | debug("SET_REPORT: "); | 301 | debug("SET_REPORT: "); |
306 | // Report Type: 0x02(Out)/ReportID: 0x00(none) && Interface: 0(keyboard) | 302 | // Report Type: 0x02(Out)/ReportID: 0x00(none) && Interface: 0(keyboard) |
307 | if (rq->wValue.word == 0x0200 && rq->wIndex.word == 0) { | 303 | if (rq->wValue.word == 0x0200 && rq->wIndex.word == KEYBOARD_INTERFACE) { |
308 | debug("SET_LED: "); | 304 | debug("SET_LED: "); |
309 | last_req.kind = SET_LED; | 305 | last_req.kind = SET_LED; |
310 | last_req.len = rq->wLength.word; | 306 | last_req.len = rq->wLength.word; |
@@ -330,7 +326,7 @@ uchar usbFunctionWrite(uchar *data, uchar len) { | |||
330 | debug("SET_LED: "); | 326 | debug("SET_LED: "); |
331 | debug_hex(data[0]); | 327 | debug_hex(data[0]); |
332 | debug("\n"); | 328 | debug("\n"); |
333 | vusb_keyboard_leds = data[0]; | 329 | keyboard_led_state = data[0]; |
334 | last_req.len = 0; | 330 | last_req.len = 0; |
335 | return 1; | 331 | return 1; |
336 | break; | 332 | break; |