summaryrefslogtreecommitdiff
path: root/tmk_core
diff options
context:
space:
mode:
authorJoel Challis <git@zvecr.com>2025-06-27 08:17:28 +0100
committerGitHub <noreply@github.com>2025-06-27 08:17:28 +0100
commitbc5c5e3251d019f3e070d7ea9e5c77501b25738d (patch)
treed97835b76f900f05e41d6a9b24f68c6f16bc0892 /tmk_core
parentf39e08e2baa14bd6e1031a64d1e879f450fb2fd7 (diff)
Align sleep_led logic (#25395)
Diffstat (limited to 'tmk_core')
-rw-r--r--tmk_core/protocol/chibios/chibios.c3
-rw-r--r--tmk_core/protocol/chibios/usb_main.c12
-rw-r--r--tmk_core/protocol/lufa/lufa.c13
-rw-r--r--tmk_core/protocol/vusb/protocol.c24
4 files changed, 2 insertions, 50 deletions
diff --git a/tmk_core/protocol/chibios/chibios.c b/tmk_core/protocol/chibios/chibios.c
index 19d8121e34..5720bc3c4c 100644
--- a/tmk_core/protocol/chibios/chibios.c
+++ b/tmk_core/protocol/chibios/chibios.c
@@ -40,9 +40,6 @@
40# define EARLY_INIT_PERFORM_BOOTLOADER_JUMP FALSE 40# define EARLY_INIT_PERFORM_BOOTLOADER_JUMP FALSE
41#endif 41#endif
42 42
43#ifdef SLEEP_LED_ENABLE
44# include "sleep_led.h"
45#endif
46#ifdef MIDI_ENABLE 43#ifdef MIDI_ENABLE
47# include "qmk_midi.h" 44# include "qmk_midi.h"
48#endif 45#endif
diff --git a/tmk_core/protocol/chibios/usb_main.c b/tmk_core/protocol/chibios/usb_main.c
index f9d7f5c4d6..b798a8d1cb 100644
--- a/tmk_core/protocol/chibios/usb_main.c
+++ b/tmk_core/protocol/chibios/usb_main.c
@@ -21,10 +21,6 @@
21#include "host.h" 21#include "host.h"
22#include "suspend.h" 22#include "suspend.h"
23#include "timer.h" 23#include "timer.h"
24#ifdef SLEEP_LED_ENABLE
25# include "sleep_led.h"
26# include "led.h"
27#endif
28#include "wait.h" 24#include "wait.h"
29#include "usb_endpoints.h" 25#include "usb_endpoints.h"
30#include "usb_device_state.h" 26#include "usb_device_state.h"
@@ -131,19 +127,11 @@ static inline bool usb_event_queue_dequeue(usbevent_t *event) {
131 127
132static inline void usb_event_suspend_handler(void) { 128static inline void usb_event_suspend_handler(void) {
133 usb_device_state_set_suspend(USB_DRIVER.configuration != 0, USB_DRIVER.configuration); 129 usb_device_state_set_suspend(USB_DRIVER.configuration != 0, USB_DRIVER.configuration);
134#ifdef SLEEP_LED_ENABLE
135 sleep_led_enable();
136#endif /* SLEEP_LED_ENABLE */
137} 130}
138 131
139static inline void usb_event_wakeup_handler(void) { 132static inline void usb_event_wakeup_handler(void) {
140 suspend_wakeup_init(); 133 suspend_wakeup_init();
141 usb_device_state_set_resume(USB_DRIVER.configuration != 0, USB_DRIVER.configuration); 134 usb_device_state_set_resume(USB_DRIVER.configuration != 0, USB_DRIVER.configuration);
142#ifdef SLEEP_LED_ENABLE
143 sleep_led_disable();
144 // NOTE: converters may not accept this
145 led_set(host_keyboard_leds());
146#endif /* SLEEP_LED_ENABLE */
147} 135}
148 136
149bool last_suspend_state = false; 137bool last_suspend_state = false;
diff --git a/tmk_core/protocol/lufa/lufa.c b/tmk_core/protocol/lufa/lufa.c
index d59468133c..e13f4b548e 100644
--- a/tmk_core/protocol/lufa/lufa.c
+++ b/tmk_core/protocol/lufa/lufa.c
@@ -44,9 +44,6 @@
44#include "led.h" 44#include "led.h"
45#include "sendchar.h" 45#include "sendchar.h"
46#include "debug.h" 46#include "debug.h"
47#ifdef SLEEP_LED_ENABLE
48# include "sleep_led.h"
49#endif
50#include "suspend.h" 47#include "suspend.h"
51#include "wait.h" 48#include "wait.h"
52 49
@@ -278,10 +275,6 @@ void EVENT_USB_Device_Reset(void) {
278void EVENT_USB_Device_Suspend(void) { 275void EVENT_USB_Device_Suspend(void) {
279 print("[S]"); 276 print("[S]");
280 usb_device_state_set_suspend(USB_Device_ConfigurationNumber != 0, USB_Device_ConfigurationNumber); 277 usb_device_state_set_suspend(USB_Device_ConfigurationNumber != 0, USB_Device_ConfigurationNumber);
281
282#ifdef SLEEP_LED_ENABLE
283 sleep_led_enable();
284#endif
285} 278}
286 279
287/** \brief Event USB Device Connect 280/** \brief Event USB Device Connect
@@ -295,12 +288,6 @@ void EVENT_USB_Device_WakeUp(void) {
295#endif 288#endif
296 289
297 usb_device_state_set_resume(USB_DeviceState == DEVICE_STATE_Configured, USB_Device_ConfigurationNumber); 290 usb_device_state_set_resume(USB_DeviceState == DEVICE_STATE_Configured, USB_Device_ConfigurationNumber);
298
299#ifdef SLEEP_LED_ENABLE
300 sleep_led_disable();
301 // NOTE: converters may not accept this
302 led_set(host_keyboard_leds());
303#endif
304} 291}
305 292
306#ifdef CONSOLE_ENABLE 293#ifdef CONSOLE_ENABLE
diff --git a/tmk_core/protocol/vusb/protocol.c b/tmk_core/protocol/vusb/protocol.c
index 41ccf451fd..e2d0c4112e 100644
--- a/tmk_core/protocol/vusb/protocol.c
+++ b/tmk_core/protocol/vusb/protocol.c
@@ -27,10 +27,6 @@
27#include "wait.h" 27#include "wait.h"
28#include "sendchar.h" 28#include "sendchar.h"
29 29
30#ifdef SLEEP_LED_ENABLE
31# include "sleep_led.h"
32#endif
33
34/* This is from main.c of USBaspLoader */ 30/* This is from main.c of USBaspLoader */
35static void initForUsbConnectivity(void) { 31static void initForUsbConnectivity(void) {
36 uint8_t i = 0; 32 uint8_t i = 0;
@@ -64,22 +60,6 @@ static inline void vusb_send_remote_wakeup(void) {
64 60
65bool vusb_suspended = false; 61bool vusb_suspended = false;
66 62
67static inline void vusb_suspend(void) {
68#ifdef SLEEP_LED_ENABLE
69 sleep_led_enable();
70#endif
71
72 suspend_power_down();
73}
74
75static inline void vusb_wakeup(void) {
76 suspend_wakeup_init();
77
78#ifdef SLEEP_LED_ENABLE
79 sleep_led_disable();
80#endif
81}
82
83/** \brief Setup USB 63/** \brief Setup USB
84 * 64 *
85 * FIXME: Needs doc 65 * FIXME: Needs doc
@@ -133,7 +113,7 @@ void protocol_pre_task(void) {
133 if (should_do_suspend()) { 113 if (should_do_suspend()) {
134 dprintln("suspending keyboard"); 114 dprintln("suspending keyboard");
135 while (should_do_suspend()) { 115 while (should_do_suspend()) {
136 vusb_suspend(); 116 suspend_power_down();
137 if (suspend_wakeup_condition()) { 117 if (suspend_wakeup_condition()) {
138 vusb_send_remote_wakeup(); 118 vusb_send_remote_wakeup();
139 119
@@ -148,7 +128,7 @@ void protocol_pre_task(void) {
148# endif 128# endif
149 } 129 }
150 } 130 }
151 vusb_wakeup(); 131 suspend_wakeup_init();
152 } 132 }
153#endif 133#endif
154} 134}