commit
53bd4a01be
17 changed files with 372 additions and 67 deletions
|
|
@ -48,6 +48,7 @@
|
|||
#include "sleep_led.h"
|
||||
#endif
|
||||
#include "suspend.h"
|
||||
#include "hook.h"
|
||||
|
||||
#include "descriptor.h"
|
||||
#include "lufa.h"
|
||||
|
|
@ -180,21 +181,13 @@ void EVENT_USB_Device_Reset(void)
|
|||
void EVENT_USB_Device_Suspend()
|
||||
{
|
||||
print("[S]");
|
||||
#ifdef SLEEP_LED_ENABLE
|
||||
sleep_led_enable();
|
||||
#endif
|
||||
hook_usb_suspend_entry();
|
||||
}
|
||||
|
||||
void EVENT_USB_Device_WakeUp()
|
||||
{
|
||||
print("[W]");
|
||||
suspend_wakeup_init();
|
||||
|
||||
#ifdef SLEEP_LED_ENABLE
|
||||
sleep_led_disable();
|
||||
// NOTE: converters may not accept this
|
||||
led_set(host_keyboard_leds());
|
||||
#endif
|
||||
hook_usb_wakeup();
|
||||
}
|
||||
|
||||
#ifdef CONSOLE_ENABLE
|
||||
|
|
@ -592,6 +585,7 @@ int main(void) __attribute__ ((weak));
|
|||
int main(void)
|
||||
{
|
||||
setup_mcu();
|
||||
hook_early_init();
|
||||
keyboard_setup();
|
||||
setup_usb();
|
||||
sei();
|
||||
|
|
@ -614,13 +608,11 @@ int main(void)
|
|||
#endif
|
||||
|
||||
print("Keyboard start.\n");
|
||||
hook_late_init();
|
||||
while (1) {
|
||||
while (USB_DeviceState == DEVICE_STATE_Suspended) {
|
||||
print("[s]");
|
||||
suspend_power_down();
|
||||
if (USB_Device_RemoteWakeupEnabled && suspend_wakeup_condition()) {
|
||||
USB_Device_SendRemoteWakeup();
|
||||
}
|
||||
hook_usb_suspend_loop();
|
||||
}
|
||||
|
||||
keyboard_task();
|
||||
|
|
@ -630,3 +622,39 @@ int main(void)
|
|||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* hooks */
|
||||
__attribute__((weak))
|
||||
void hook_early_init(void) {}
|
||||
|
||||
__attribute__((weak))
|
||||
void hook_late_init(void) {}
|
||||
|
||||
__attribute__((weak))
|
||||
void hook_usb_suspend_entry(void)
|
||||
{
|
||||
#ifdef SLEEP_LED_ENABLE
|
||||
sleep_led_enable();
|
||||
#endif
|
||||
}
|
||||
|
||||
__attribute__((weak))
|
||||
void hook_usb_suspend_loop(void)
|
||||
{
|
||||
suspend_power_down();
|
||||
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();
|
||||
// NOTE: converters may not accept this
|
||||
led_set(host_keyboard_leds());
|
||||
#endif
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue