Update host.c and chibios.c

This commit is contained in:
lalalademaxiya1 2023-10-16 14:18:07 +08:00
parent c0294096b8
commit d1074a0620
2 changed files with 42 additions and 6 deletions

View File

@ -179,10 +179,35 @@ void protocol_post_init(void) {
host_set_driver(driver);
}
#if defined(STM32_USB_USE_OTG1)
void protocol_pre_task(void) {
# if !defined(NO_USB_STARTUP_CHECK)
if (USB_DRIVER.state == USB_SUSPENDED) {
dprintln("suspending keyboard");
while (USB_DRIVER.state == USB_SUSPENDED) {
/* Do this in the suspended state */
suspend_power_down(); // on AVR this deep sleeps for 15ms
/* Remote wakeup */
if ((USB_DRIVER.status & USB_GETSTATUS_REMOTE_WAKEUP_ENABLED) && suspend_wakeup_condition()) {
usbWakeupHost(&USB_DRIVER);
wait_ms(300);
}
}
/* Woken up */
// variables has been already cleared by the wakeup hook
send_keyboard_report();
# ifdef MOUSEKEY_ENABLE
mousekey_send();
# endif /* MOUSEKEY_ENABLE */
}
# endif
usb_event_queue_task();
}
#else
void protocol_pre_task(void) {
usb_event_queue_task();
#if !defined(NO_USB_STARTUP_CHECK)
# if !defined(NO_USB_STARTUP_CHECK)
if (USB_DRIVER.state == USB_SUSPENDED) {
dprintln("suspending keyboard");
while (USB_DRIVER.state == USB_SUSPENDED) {
@ -197,12 +222,13 @@ void protocol_pre_task(void) {
/* Woken up */
// variables has been already cleared by the wakeup hook
send_keyboard_report();
# ifdef MOUSEKEY_ENABLE
# ifdef MOUSEKEY_ENABLE
mousekey_send();
# endif /* MOUSEKEY_ENABLE */
# endif /* MOUSEKEY_ENABLE */
}
#endif
# endif
}
#endif
void protocol_post_task(void) {
#ifdef CONSOLE_ENABLE

View File

@ -131,11 +131,16 @@ void host_system_send(uint16_t usage) {
last_system_usage = usage;
if (!driver) return;
#if defined(STM32_USB_USE_OTG1)
static report_extra_t report;
report.report_id = REPORT_ID_SYSTEM;
report.usage = usage;
#else
report_extra_t report = {
.report_id = REPORT_ID_SYSTEM,
.usage = usage,
};
#endif
(*driver->send_extra)(&report);
}
@ -151,11 +156,16 @@ void host_consumer_send(uint16_t usage) {
#endif
if (!driver) return;
#if defined(STM32_USB_USE_OTG1)
static report_extra_t report;
report.report_id = REPORT_ID_CONSUMER;
report.usage = usage;
#else
report_extra_t report = {
.report_id = REPORT_ID_CONSUMER,
.usage = usage,
};
#endif
(*driver->send_extra)(&report);
}