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

ChibiOS USB: Add a dummy IN callback to work around LLD bugs #18811

Merged
merged 1 commit into from
Oct 22, 2022
Merged
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
20 changes: 15 additions & 5 deletions tmk_core/protocol/chibios/usb_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -120,14 +120,24 @@ static const USBDescriptor *usb_get_descriptor_cb(USBDriver *usbp, uint8_t dtype
return &desc;
}

/*
* USB notification callback that does nothing. Needed to work around bugs in
* some USB LLDs that fail to resume the waiting thread when the notification
* callback pointer is NULL.
*/
static void dummy_usb_cb(USBDriver *usbp, usbep_t ep) {
(void)usbp;
(void)ep;
}

#ifndef KEYBOARD_SHARED_EP
/* keyboard endpoint state structure */
static USBInEndpointState kbd_ep_state;
/* keyboard endpoint initialization structure (IN) - see USBEndpointConfig comment at top of file */
static const USBEndpointConfig kbd_ep_config = {
USB_EP_MODE_TYPE_INTR, /* Interrupt EP */
NULL, /* SETUP packet notification callback */
NULL, /* IN notification callback */
dummy_usb_cb, /* IN notification callback */
NULL, /* OUT notification callback */
KEYBOARD_EPSIZE, /* IN maximum packet size */
0, /* OUT maximum packet size */
Expand All @@ -145,7 +155,7 @@ static USBInEndpointState mouse_ep_state;
static const USBEndpointConfig mouse_ep_config = {
USB_EP_MODE_TYPE_INTR, /* Interrupt EP */
NULL, /* SETUP packet notification callback */
NULL, /* IN notification callback */
dummy_usb_cb, /* IN notification callback */
NULL, /* OUT notification callback */
MOUSE_EPSIZE, /* IN maximum packet size */
0, /* OUT maximum packet size */
Expand All @@ -163,7 +173,7 @@ static USBInEndpointState shared_ep_state;
static const USBEndpointConfig shared_ep_config = {
USB_EP_MODE_TYPE_INTR, /* Interrupt EP */
NULL, /* SETUP packet notification callback */
NULL, /* IN notification callback */
dummy_usb_cb, /* IN notification callback */
NULL, /* OUT notification callback */
SHARED_EPSIZE, /* IN maximum packet size */
0, /* OUT maximum packet size */
Expand All @@ -181,7 +191,7 @@ static USBInEndpointState joystick_ep_state;
static const USBEndpointConfig joystick_ep_config = {
USB_EP_MODE_TYPE_INTR, /* Interrupt EP */
NULL, /* SETUP packet notification callback */
NULL, /* IN notification callback */
dummy_usb_cb, /* IN notification callback */
NULL, /* OUT notification callback */
JOYSTICK_EPSIZE, /* IN maximum packet size */
0, /* OUT maximum packet size */
Expand All @@ -199,7 +209,7 @@ static USBInEndpointState digitizer_ep_state;
static const USBEndpointConfig digitizer_ep_config = {
USB_EP_MODE_TYPE_INTR, /* Interrupt EP */
NULL, /* SETUP packet notification callback */
NULL, /* IN notification callback */
dummy_usb_cb, /* IN notification callback */
NULL, /* OUT notification callback */
DIGITIZER_EPSIZE, /* IN maximum packet size */
0, /* OUT maximum packet size */
Expand Down