diff options
author | tmk <nobody@nowhere> | 2013-03-13 16:01:53 +0900 |
---|---|---|
committer | tmk <nobody@nowhere> | 2013-03-13 16:02:17 +0900 |
commit | c8cfde01389a7f945e237b8571c1d4202e0d60d0 (patch) | |
tree | 8f143db91dc46ae49f58498b3fb1ceb4d007a87b | |
parent | b78c654693014c60ced089648c29f46939d23437 (diff) | |
download | qmk_firmware-c8cfde01389a7f945e237b8571c1d4202e0d60d0.tar.gz qmk_firmware-c8cfde01389a7f945e237b8571c1d4202e0d60d0.zip |
Add intial code of RemoteWakeUp
-rw-r--r-- | protocol/lufa/lufa.c | 40 |
1 files changed, 36 insertions, 4 deletions
diff --git a/protocol/lufa/lufa.c b/protocol/lufa/lufa.c index 98c3a68ffb..fc3798cdf9 100644 --- a/protocol/lufa/lufa.c +++ b/protocol/lufa/lufa.c @@ -133,16 +133,29 @@ static void Console_Task(void) /******************************************************************************* * USB Events ******************************************************************************/ -/** Event handler for the USB_Connect event. */ +#include "led.h" void EVENT_USB_Device_Connect(void) { } -/** Event handler for the USB_Disconnect event. */ void EVENT_USB_Device_Disconnect(void) { } +void EVENT_USB_Device_Reset(void) +{ +} + +void EVENT_USB_Device_Suspend() +{ + led_set(1<<USB_LED_CAPS_LOCK); +} + +void EVENT_USB_Device_WakeUp() +{ + led_set(0); +} + void EVENT_USB_Device_StartOfFrame(void) { Console_Task(); @@ -466,6 +479,17 @@ static void SetupHardware(void) USB_Device_EnableSOFEvents(); } + +#include "matrix.h" +static bool wakeup_condition(void) +{ + matrix_scan(); + for (uint8_t r = 0; r < MATRIX_ROWS; r++) { + if (matrix_get_row(r)) return true; + } + return false; +} + int main(void) __attribute__ ((weak)); int main(void) { @@ -474,9 +498,17 @@ int main(void) host_set_driver(&lufa_driver); sei(); - // TODO: can't print here - debug("LUFA init\n"); while (1) { + while (USB_DeviceState == DEVICE_STATE_Suspended) { + // TODO: power saving + + if (USB_Device_RemoteWakeupEnabled) { + if (wakeup_condition()) { + USB_Device_SendRemoteWakeup(); + } + } + } + keyboard_task(); #if !defined(INTERRUPT_CONTROL_ENDPOINT) |