summaryrefslogtreecommitdiffstats
path: root/tmk_core/protocol/chibios
diff options
context:
space:
mode:
Diffstat (limited to 'tmk_core/protocol/chibios')
-rw-r--r--tmk_core/protocol/chibios/chibios.c26
-rw-r--r--tmk_core/protocol/chibios/chibios.mk17
2 files changed, 29 insertions, 14 deletions
diff --git a/tmk_core/protocol/chibios/chibios.c b/tmk_core/protocol/chibios/chibios.c
index 10a976608a..1eebdaf6c3 100644
--- a/tmk_core/protocol/chibios/chibios.c
+++ b/tmk_core/protocol/chibios/chibios.c
@@ -49,6 +49,8 @@
#include "suspend.h"
#include "wait.h"
+#define USB_GETSTATUS_REMOTE_WAKEUP_ENABLED (2U)
+
/* -------------------------
* TMK host driver defs
* -------------------------
@@ -178,28 +180,24 @@ void protocol_post_init(void) {
}
void protocol_pre_task(void) {
- usb_event_queue_task();
-
#if !defined(NO_USB_STARTUP_CHECK)
if (USB_DRIVER.state == USB_SUSPENDED) {
- print("[s]");
+ 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 (suspend_wakeup_condition()) {
+ suspend_power_down();
+ if ((USB_DRIVER.status & USB_GETSTATUS_REMOTE_WAKEUP_ENABLED) && suspend_wakeup_condition()) {
+ /* issue a remote wakeup event to the host which should resume
+ * the bus and get our keyboard out of suspension. */
usbWakeupHost(&USB_DRIVER);
- restart_usb_driver(&USB_DRIVER);
}
}
- /* Woken up */
- // variables has been already cleared by the wakeup hook
- send_keyboard_report();
-# ifdef MOUSEKEY_ENABLE
- mousekey_send();
-# endif /* MOUSEKEY_ENABLE */
+ /* after a successful wakeup a USB_EVENT_WAKEUP is signaled to QMK by
+ * ChibiOS, which triggers a wakeup callback that restores the state of
+ * the keyboard. Therefore we do nothing here. */
}
#endif
+
+ usb_event_queue_task();
}
void protocol_post_task(void) {
diff --git a/tmk_core/protocol/chibios/chibios.mk b/tmk_core/protocol/chibios/chibios.mk
new file mode 100644
index 0000000000..8eaf5b10d2
--- /dev/null
+++ b/tmk_core/protocol/chibios/chibios.mk
@@ -0,0 +1,17 @@
+PROTOCOL_DIR = protocol
+CHIBIOS_DIR = $(PROTOCOL_DIR)/chibios
+
+
+SRC += $(CHIBIOS_DIR)/usb_main.c
+SRC += $(CHIBIOS_DIR)/chibios.c
+SRC += usb_descriptor.c
+SRC += $(CHIBIOS_DIR)/usb_driver.c
+SRC += $(CHIBIOS_DIR)/usb_util.c
+SRC += $(LIBSRC)
+
+VPATH += $(TMK_PATH)/$(PROTOCOL_DIR)
+VPATH += $(TMK_PATH)/$(CHIBIOS_DIR)
+VPATH += $(TMK_PATH)/$(CHIBIOS_DIR)/lufa_utils
+
+OPT_DEFS += -DFIXED_CONTROL_ENDPOINT_SIZE=64
+OPT_DEFS += -DFIXED_NUM_CONFIGURATIONS=1