summaryrefslogtreecommitdiff
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.c3
-rw-r--r--tmk_core/protocol/chibios/usb_main.c15
2 files changed, 17 insertions, 1 deletions
diff --git a/tmk_core/protocol/chibios/chibios.c b/tmk_core/protocol/chibios/chibios.c
index 78a2e3fcbb..e5d3a4c540 100644
--- a/tmk_core/protocol/chibios/chibios.c
+++ b/tmk_core/protocol/chibios/chibios.c
@@ -27,6 +27,7 @@
#include "keyboard.h"
#include "action.h"
#include "action_util.h"
+#include "usb_device_state.h"
#include "mousekey.h"
#include "led.h"
#include "sendchar.h"
@@ -139,6 +140,8 @@ void boardInit(void) {
}
void protocol_setup(void) {
+ usb_device_state_init();
+
// TESTING
// chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL);
diff --git a/tmk_core/protocol/chibios/usb_main.c b/tmk_core/protocol/chibios/usb_main.c
index cc282e6a9b..9b139b3992 100644
--- a/tmk_core/protocol/chibios/usb_main.c
+++ b/tmk_core/protocol/chibios/usb_main.c
@@ -39,6 +39,7 @@
# include "led.h"
#endif
#include "wait.h"
+#include "usb_device_state.h"
#include "usb_descriptor.h"
#include "usb_driver.h"
@@ -412,6 +413,7 @@ static inline bool usb_event_queue_dequeue(usbevent_t *event) {
}
static inline void usb_event_suspend_handler(void) {
+ usb_device_state_set_suspend(USB_DRIVER.configuration != 0, USB_DRIVER.configuration);
#ifdef SLEEP_LED_ENABLE
sleep_led_enable();
#endif /* SLEEP_LED_ENABLE */
@@ -419,6 +421,7 @@ static inline void usb_event_suspend_handler(void) {
static inline void usb_event_wakeup_handler(void) {
suspend_wakeup_init();
+ usb_device_state_set_resume(USB_DRIVER.configuration != 0, USB_DRIVER.configuration);
#ifdef SLEEP_LED_ENABLE
sleep_led_disable();
// NOTE: converters may not accept this
@@ -440,6 +443,15 @@ void usb_event_queue_task(void) {
last_suspend_state = false;
usb_event_wakeup_handler();
break;
+ case USB_EVENT_CONFIGURED:
+ usb_device_state_set_configuration(USB_DRIVER.configuration != 0, USB_DRIVER.configuration);
+ break;
+ case USB_EVENT_UNCONFIGURED:
+ usb_device_state_set_configuration(false, 0);
+ break;
+ case USB_EVENT_RESET:
+ usb_device_state_set_reset();
+ break;
default:
// Nothing to do, we don't handle it.
break;
@@ -482,13 +494,14 @@ static void usb_event_cb(USBDriver *usbp, usbevent_t event) {
if (last_suspend_state) {
usb_event_queue_enqueue(USB_EVENT_WAKEUP);
}
+ usb_event_queue_enqueue(USB_EVENT_CONFIGURED);
return;
case USB_EVENT_SUSPEND:
- usb_event_queue_enqueue(USB_EVENT_SUSPEND);
/* Falls into.*/
case USB_EVENT_UNCONFIGURED:
/* Falls into.*/
case USB_EVENT_RESET:
+ usb_event_queue_enqueue(event);
for (int i = 0; i < NUM_USB_DRIVERS; i++) {
chSysLockFromISR();
/* Disconnection event on suspend.*/