+
+
+/* hooks */
+__attribute__((weak))
+void hook_early_init(void) {}
+
+__attribute__((weak))
+void hook_late_init(void) {}
+
+static uint8_t _led_stats = 0;
+ __attribute__((weak))
+void hook_usb_suspend_entry(void)
+{
+ // Turn off LED to save power and keep its status to resotre it later.
+ // LED status will be updated by keyboard_task() in main loop hopefully.
+ _led_stats = keyboard_led_stats;
+ keyboard_led_stats = 0;
+
+ // Calling long task here can prevent USB state transition
+
+ matrix_clear();
+ clear_keyboard();
+#ifdef SLEEP_LED_ENABLE
+ sleep_led_enable();
+#endif
+}
+
+__attribute__((weak))
+void hook_usb_suspend_loop(void)
+{
+#ifndef LUFA_DEBUG_UART
+ // This corrupts debug print when suspend
+ suspend_power_down();
+#endif
+ if (USB_Device_RemoteWakeupEnabled && suspend_wakeup_condition()) {
+ USB_Device_SendRemoteWakeup();
+ }
+}
+
+__attribute__((weak))
+void hook_usb_wakeup(void)
+{
+ suspend_wakeup_init();
+#ifdef SLEEP_LED_ENABLE
+ sleep_led_disable();
+#endif
+
+ // Restore LED status and update at keyboard_task() in main loop
+ keyboard_led_stats = _led_stats;
+
+ // Calling long task here can prevent USB state transition
+}
+
+__attribute__((weak))
+void hook_usb_startup_wait_loop(void) {}