summaryrefslogtreecommitdiffstats
path: root/tmk_core/protocol/lufa
diff options
context:
space:
mode:
authorPurdea Andrei <andrei@purdea.ro>2021-09-29 23:31:39 +0300
committerGitHub <noreply@github.com>2021-09-30 06:31:39 +1000
commitb02a5396251c0fadb92f2632e242b555c238ad8b (patch)
tree4f01ce4de39773b3225180af56723351862c4aa8 /tmk_core/protocol/lufa
parent552c126bea24b4f182caa62ada8c2213dc06de23 (diff)
Added power tracking api (#12691)
* Add power tracking API to lufa and chibios targets * power.c: Pass through power state to the notify function * power: added notify_power_state_change_user too. * making it pass the PR linter * Add a POWER_STATE_NO_INIT state, that we start in before calling power_init(); * Rename *power* to *usb_power* * removing stray newline * Rename usb_power* to usb_device_state* * Update quantum/usb_device_state.h Co-authored-by: Drashna Jaelre <drashna@live.com> * Fix comment * usb_device_state.h: Don't include quantum.h, only the necessary headers. Co-authored-by: Drashna Jaelre <drashna@live.com>
Diffstat (limited to 'tmk_core/protocol/lufa')
-rw-r--r--tmk_core/protocol/lufa/lufa.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/tmk_core/protocol/lufa/lufa.c b/tmk_core/protocol/lufa/lufa.c
index 4a30d22579..753762358d 100644
--- a/tmk_core/protocol/lufa/lufa.c
+++ b/tmk_core/protocol/lufa/lufa.c
@@ -52,6 +52,7 @@
#include "usb_descriptor.h"
#include "lufa.h"
#include "quantum.h"
+#include "usb_device_state.h"
#include <util/atomic.h>
#ifdef NKRO_ENABLE
@@ -414,7 +415,10 @@ void EVENT_USB_Device_Disconnect(void) {
*
* FIXME: Needs doc
*/
-void EVENT_USB_Device_Reset(void) { print("[R]"); }
+void EVENT_USB_Device_Reset(void) {
+ print("[R]");
+ usb_device_state_set_reset();
+}
/** \brief Event USB Device Connect
*
@@ -422,6 +426,8 @@ void EVENT_USB_Device_Reset(void) { print("[R]"); }
*/
void EVENT_USB_Device_Suspend() {
print("[S]");
+ usb_device_state_set_suspend(USB_Device_ConfigurationNumber != 0, USB_Device_ConfigurationNumber);
+
#ifdef SLEEP_LED_ENABLE
sleep_led_enable();
#endif
@@ -437,6 +443,8 @@ void EVENT_USB_Device_WakeUp() {
suspend_wakeup_init();
#endif
+ usb_device_state_set_resume(USB_DeviceState == DEVICE_STATE_Configured, USB_Device_ConfigurationNumber);
+
#ifdef SLEEP_LED_ENABLE
sleep_led_disable();
// NOTE: converters may not accept this
@@ -529,6 +537,8 @@ void EVENT_USB_Device_ConfigurationChanged(void) {
/* Setup digitizer endpoint */
ConfigSuccess &= Endpoint_ConfigureEndpoint((DIGITIZER_IN_EPNUM | ENDPOINT_DIR_IN), EP_TYPE_INTERRUPT, DIGITIZER_EPSIZE, 1);
#endif
+
+ usb_device_state_set_configuration(USB_DeviceState == DEVICE_STATE_Configured, USB_Device_ConfigurationNumber);
}
/* FIXME: Expose this table in the docs somehow
@@ -1059,6 +1069,7 @@ void protocol_setup(void) {
#endif
setup_mcu();
+ usb_device_state_init();
keyboard_setup();
}