From: tmk Date: Wed, 8 May 2019 02:44:56 +0000 (+0900) Subject: core: Add hook_usb_startup_wait_loop X-Git-Url: https://git.friedersdorff.com/?a=commitdiff_plain;h=f3e498590cefe28dba4419aa9525655e747e01dd;p=max%2Ftmk_keyboard.git core: Add hook_usb_startup_wait_loop --- diff --git a/tmk_core/common/hook.h b/tmk_core/common/hook.h index 56fe5677..140e2779 100644 --- a/tmk_core/common/hook.h +++ b/tmk_core/common/hook.h @@ -21,6 +21,10 @@ along with this program. If not, see . #include "keyboard.h" #include "led.h" +#ifdef __cplusplus +extern "C" { +#endif + /* ------------------------------------- * Protocol hooks * ------------------------------------- */ @@ -47,6 +51,10 @@ void hook_usb_suspend_loop(void); * the "normal" indicator LED status by default. */ void hook_usb_wakeup(void); +/* Called repeatedly until getting to CONFIGURED state */ +/* Default behaviour: do nothing. */ +void hook_usb_startup_wait_loop(void); + /* ------------------------------------- * Keyboard hooks @@ -76,5 +84,8 @@ void hook_keyboard_leds_change(uint8_t led_status); /* Default behaviour: do nothing. */ void hook_bootmagic(void); +#ifdef __cplusplus +} +#endif #endif /* _HOOKS_H_ */ diff --git a/tmk_core/common/suspend.h b/tmk_core/common/suspend.h index 80617a82..f0a668cf 100644 --- a/tmk_core/common/suspend.h +++ b/tmk_core/common/suspend.h @@ -5,9 +5,17 @@ #include +#ifdef __cplusplus +extern "C" { +#endif + void suspend_idle(uint8_t timeout); void suspend_power_down(void); bool suspend_wakeup_condition(void); void suspend_wakeup_init(void); +#ifdef __cplusplus +} +#endif + #endif diff --git a/tmk_core/doc/hook.txt b/tmk_core/doc/hook.txt index 1689034e..acd77cce 100644 --- a/tmk_core/doc/hook.txt +++ b/tmk_core/doc/hook.txt @@ -9,6 +9,8 @@ Hook function | Timing `hook_early_init(void)` | Early in the boot process, before the matrix is initialized and before a connection is made with the host. Thus, this hook has access to very few parameters, but it is a good place to define any custom parameters needed by other early processes. `hook_late_init(void)` | Near the end of the boot process, after Boot Magic has run and LEDs have been initialized. `hook_bootmagic(void)` | During the Boot Magic window, after EEPROM and Bootloader checks are made, but before any other built-in Boot Magic checks are made. +`hook_usb_startup_wait_loop(void)` | Continuously, until the device gets ready and into USB configured state. + `hook_usb_wakeup(void)` | When the device wakes up from USB suspend state. `hook_usb_suspend_entry(void)` | When the device enters USB suspend state. `hook_usb_suspend_loop(void)` | Continuously, while the device is in USB suspend state. *Default action:* power down and periodically check the matrix, causing wakeup if needed. diff --git a/tmk_core/protocol/lufa/lufa.c b/tmk_core/protocol/lufa/lufa.c index ce15ec73..9dadd572 100644 --- a/tmk_core/protocol/lufa/lufa.c +++ b/tmk_core/protocol/lufa/lufa.c @@ -662,6 +662,7 @@ int main(void) #else USB_USBTask(); #endif + hook_usb_startup_wait_loop(); } print("\nUSB configured.\n"); #endif @@ -739,3 +740,6 @@ void hook_usb_wakeup(void) // Calling long task here can prevent USB state transition } + +__attribute__((weak)) +void hook_usb_startup_wait_loop(void) {}