aboutsummaryrefslogtreecommitdiff
path: root/tmk_core/common/chibios/suspend.c
diff options
context:
space:
mode:
Diffstat (limited to 'tmk_core/common/chibios/suspend.c')
-rw-r--r--tmk_core/common/chibios/suspend.c85
1 files changed, 2 insertions, 83 deletions
diff --git a/tmk_core/common/chibios/suspend.c b/tmk_core/common/chibios/suspend.c
index 38517e06f..991fe6e08 100644
--- a/tmk_core/common/chibios/suspend.c
+++ b/tmk_core/common/chibios/suspend.c
@@ -12,25 +12,6 @@
12#include "led.h" 12#include "led.h"
13#include "wait.h" 13#include "wait.h"
14 14
15#ifdef AUDIO_ENABLE
16# include "audio.h"
17#endif /* AUDIO_ENABLE */
18
19#ifdef BACKLIGHT_ENABLE
20# include "backlight.h"
21#endif
22
23#if defined(RGBLIGHT_SLEEP) && defined(RGBLIGHT_ENABLE)
24# include "rgblight.h"
25#endif
26
27#ifdef LED_MATRIX_ENABLE
28# include "led_matrix.h"
29#endif
30#ifdef RGB_MATRIX_ENABLE
31# include "rgb_matrix.h"
32#endif
33
34/** \brief suspend idle 15/** \brief suspend idle
35 * 16 *
36 * FIXME: needs doc 17 * FIXME: needs doc
@@ -40,61 +21,12 @@ void suspend_idle(uint8_t time) {
40 wait_ms(time); 21 wait_ms(time);
41} 22}
42 23
43/** \brief Run keyboard level Power down
44 *
45 * FIXME: needs doc
46 */
47__attribute__((weak)) void suspend_power_down_user(void) {}
48/** \brief Run keyboard level Power down
49 *
50 * FIXME: needs doc
51 */
52__attribute__((weak)) void suspend_power_down_kb(void) { suspend_power_down_user(); }
53
54/** \brief suspend power down 24/** \brief suspend power down
55 * 25 *
56 * FIXME: needs doc 26 * FIXME: needs doc
57 */ 27 */
58void suspend_power_down(void) { 28void suspend_power_down(void) {
59#ifdef BACKLIGHT_ENABLE 29 suspend_power_down_quantum();
60 backlight_set(0);
61#endif
62
63#ifdef LED_MATRIX_ENABLE
64 led_matrix_task();
65#endif
66#ifdef RGB_MATRIX_ENABLE
67 rgb_matrix_task();
68#endif
69
70 // Turn off LED indicators
71 uint8_t leds_off = 0;
72#if defined(BACKLIGHT_CAPS_LOCK) && defined(BACKLIGHT_ENABLE)
73 if (is_backlight_enabled()) {
74 // Don't try to turn off Caps Lock indicator as it is backlight and backlight is already off
75 leds_off |= (1 << USB_LED_CAPS_LOCK);
76 }
77#endif
78 led_set(leds_off);
79
80 // TODO: figure out what to power down and how
81 // shouldn't power down TPM/FTM if we want a breathing LED
82 // also shouldn't power down USB
83#if defined(RGBLIGHT_SLEEP) && defined(RGBLIGHT_ENABLE)
84 rgblight_suspend();
85#endif
86
87#if defined(LED_MATRIX_ENABLE)
88 led_matrix_set_suspend_state(true);
89#endif
90#if defined(RGB_MATRIX_ENABLE)
91 rgb_matrix_set_suspend_state(true);
92#endif
93#ifdef AUDIO_ENABLE
94 stop_all_notes();
95#endif /* AUDIO_ENABLE */
96
97 suspend_power_down_kb();
98 // on AVR, this enables the watchdog for 15ms (max), and goes to 30 // on AVR, this enables the watchdog for 15ms (max), and goes to
99 // SLEEP_MODE_PWR_DOWN 31 // SLEEP_MODE_PWR_DOWN
100 32
@@ -151,19 +83,6 @@ void suspend_wakeup_init(void) {
151 host_system_send(0); 83 host_system_send(0);
152 host_consumer_send(0); 84 host_consumer_send(0);
153#endif /* EXTRAKEY_ENABLE */ 85#endif /* EXTRAKEY_ENABLE */
154#ifdef BACKLIGHT_ENABLE
155 backlight_init();
156#endif /* BACKLIGHT_ENABLE */
157 led_set(host_keyboard_leds());
158#if defined(RGBLIGHT_SLEEP) && defined(RGBLIGHT_ENABLE)
159 rgblight_wakeup();
160#endif
161 86
162#if defined(LED_MATRIX_ENABLE) 87 suspend_wakeup_init_quantum();
163 led_matrix_set_suspend_state(false);
164#endif
165#if defined(RGB_MATRIX_ENABLE)
166 rgb_matrix_set_suspend_state(false);
167#endif
168 suspend_wakeup_init_kb();
169} 88}