diff options
Diffstat (limited to 'tmk_core')
| -rw-r--r-- | tmk_core/common/avr/suspend.c | 98 | ||||
| -rw-r--r-- | tmk_core/common/chibios/suspend.c | 85 | ||||
| -rw-r--r-- | tmk_core/common/suspend.h | 2 | ||||
| -rw-r--r-- | tmk_core/protocol/usb_hid/parser.h | 5 | ||||
| -rw-r--r-- | tmk_core/protocol/usb_hid/usb_hid.h | 6 |
5 files changed, 8 insertions, 188 deletions
diff --git a/tmk_core/common/avr/suspend.c b/tmk_core/common/avr/suspend.c index 690d7f38c..b614746e6 100644 --- a/tmk_core/common/avr/suspend.c +++ b/tmk_core/common/avr/suspend.c | |||
| @@ -16,25 +16,6 @@ | |||
| 16 | # include "vusb.h" | 16 | # include "vusb.h" |
| 17 | #endif | 17 | #endif |
| 18 | 18 | ||
| 19 | #ifdef BACKLIGHT_ENABLE | ||
| 20 | # include "backlight.h" | ||
| 21 | #endif | ||
| 22 | |||
| 23 | #ifdef AUDIO_ENABLE | ||
| 24 | # include "audio.h" | ||
| 25 | #endif /* AUDIO_ENABLE */ | ||
| 26 | |||
| 27 | #if defined(RGBLIGHT_SLEEP) && defined(RGBLIGHT_ENABLE) | ||
| 28 | # include "rgblight.h" | ||
| 29 | #endif | ||
| 30 | |||
| 31 | #ifdef LED_MATRIX_ENABLE | ||
| 32 | # include "led_matrix.h" | ||
| 33 | #endif | ||
| 34 | #ifdef RGB_MATRIX_ENABLE | ||
| 35 | # include "rgb_matrix.h" | ||
| 36 | #endif | ||
| 37 | |||
| 38 | /** \brief Suspend idle | 19 | /** \brief Suspend idle |
| 39 | * | 20 | * |
| 40 | * FIXME: needs doc | 21 | * FIXME: needs doc |
| @@ -50,17 +31,6 @@ void suspend_idle(uint8_t time) { | |||
| 50 | 31 | ||
| 51 | // TODO: This needs some cleanup | 32 | // TODO: This needs some cleanup |
| 52 | 33 | ||
| 53 | /** \brief Run keyboard level Power down | ||
| 54 | * | ||
| 55 | * FIXME: needs doc | ||
| 56 | */ | ||
| 57 | __attribute__((weak)) void suspend_power_down_user(void) {} | ||
| 58 | /** \brief Run keyboard level Power down | ||
| 59 | * | ||
| 60 | * FIXME: needs doc | ||
| 61 | */ | ||
| 62 | __attribute__((weak)) void suspend_power_down_kb(void) { suspend_power_down_user(); } | ||
| 63 | |||
| 64 | #if !defined(NO_SUSPEND_POWER_DOWN) && defined(WDT_vect) | 34 | #if !defined(NO_SUSPEND_POWER_DOWN) && defined(WDT_vect) |
| 65 | 35 | ||
| 66 | // clang-format off | 36 | // clang-format off |
| @@ -135,41 +105,9 @@ void suspend_power_down(void) { | |||
| 135 | if (!vusb_suspended) return; | 105 | if (!vusb_suspended) return; |
| 136 | #endif | 106 | #endif |
| 137 | 107 | ||
| 138 | suspend_power_down_kb(); | 108 | suspend_power_down_quantum(); |
| 139 | 109 | ||
| 140 | #ifndef NO_SUSPEND_POWER_DOWN | 110 | #ifndef NO_SUSPEND_POWER_DOWN |
| 141 | // Turn off backlight | ||
| 142 | # ifdef BACKLIGHT_ENABLE | ||
| 143 | backlight_set(0); | ||
| 144 | # endif | ||
| 145 | |||
| 146 | // Turn off LED indicators | ||
| 147 | uint8_t leds_off = 0; | ||
| 148 | # if defined(BACKLIGHT_CAPS_LOCK) && defined(BACKLIGHT_ENABLE) | ||
| 149 | if (is_backlight_enabled()) { | ||
| 150 | // Don't try to turn off Caps Lock indicator as it is backlight and backlight is already off | ||
| 151 | leds_off |= (1 << USB_LED_CAPS_LOCK); | ||
| 152 | } | ||
| 153 | # endif | ||
| 154 | led_set(leds_off); | ||
| 155 | |||
| 156 | // Turn off audio | ||
| 157 | # ifdef AUDIO_ENABLE | ||
| 158 | stop_all_notes(); | ||
| 159 | # endif | ||
| 160 | |||
| 161 | // Turn off underglow | ||
| 162 | # if defined(RGBLIGHT_SLEEP) && defined(RGBLIGHT_ENABLE) | ||
| 163 | rgblight_suspend(); | ||
| 164 | # endif | ||
| 165 | |||
| 166 | # if defined(LED_MATRIX_ENABLE) | ||
| 167 | led_matrix_set_suspend_state(true); | ||
| 168 | # endif | ||
| 169 | # if defined(RGB_MATRIX_ENABLE) | ||
| 170 | rgb_matrix_set_suspend_state(true); | ||
| 171 | # endif | ||
| 172 | |||
| 173 | // Enter sleep state if possible (ie, the MCU has a watchdog timeout interrupt) | 111 | // Enter sleep state if possible (ie, the MCU has a watchdog timeout interrupt) |
| 174 | # if defined(WDT_vect) | 112 | # if defined(WDT_vect) |
| 175 | power_down(WDTO_15MS); | 113 | power_down(WDTO_15MS); |
| @@ -189,18 +127,6 @@ bool suspend_wakeup_condition(void) { | |||
| 189 | return false; | 127 | return false; |
| 190 | } | 128 | } |
| 191 | 129 | ||
| 192 | /** \brief run user level code immediately after wakeup | ||
| 193 | * | ||
| 194 | * FIXME: needs doc | ||
| 195 | */ | ||
| 196 | __attribute__((weak)) void suspend_wakeup_init_user(void) {} | ||
| 197 | |||
| 198 | /** \brief run keyboard level code immediately after wakeup | ||
| 199 | * | ||
| 200 | * FIXME: needs doc | ||
| 201 | */ | ||
| 202 | __attribute__((weak)) void suspend_wakeup_init_kb(void) { suspend_wakeup_init_user(); } | ||
| 203 | |||
| 204 | /** \brief run immediately after wakeup | 130 | /** \brief run immediately after wakeup |
| 205 | * | 131 | * |
| 206 | * FIXME: needs doc | 132 | * FIXME: needs doc |
| @@ -209,27 +135,7 @@ void suspend_wakeup_init(void) { | |||
| 209 | // clear keyboard state | 135 | // clear keyboard state |
| 210 | clear_keyboard(); | 136 | clear_keyboard(); |
| 211 | 137 | ||
| 212 | // Turn on backlight | 138 | suspend_wakeup_init_quantum(); |
| 213 | #ifdef BACKLIGHT_ENABLE | ||
| 214 | backlight_init(); | ||
| 215 | #endif | ||
| 216 | |||
| 217 | // Restore LED indicators | ||
| 218 | led_set(host_keyboard_leds()); | ||
| 219 | |||
| 220 | // Wake up underglow | ||
| 221 | #if defined(RGBLIGHT_SLEEP) && defined(RGBLIGHT_ENABLE) | ||
| 222 | rgblight_wakeup(); | ||
| 223 | #endif | ||
| 224 | |||
| 225 | #if defined(LED_MATRIX_ENABLE) | ||
| 226 | led_matrix_set_suspend_state(false); | ||
| 227 | #endif | ||
| 228 | #if defined(RGB_MATRIX_ENABLE) | ||
| 229 | rgb_matrix_set_suspend_state(false); | ||
| 230 | #endif | ||
| 231 | |||
| 232 | suspend_wakeup_init_kb(); | ||
| 233 | } | 139 | } |
| 234 | 140 | ||
| 235 | #if !defined(NO_SUSPEND_POWER_DOWN) && defined(WDT_vect) | 141 | #if !defined(NO_SUSPEND_POWER_DOWN) && defined(WDT_vect) |
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 | */ |
| 58 | void suspend_power_down(void) { | 28 | void 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 | } |
diff --git a/tmk_core/common/suspend.h b/tmk_core/common/suspend.h index 95845e4b6..081735f90 100644 --- a/tmk_core/common/suspend.h +++ b/tmk_core/common/suspend.h | |||
| @@ -10,8 +10,10 @@ void suspend_wakeup_init(void); | |||
| 10 | 10 | ||
| 11 | void suspend_wakeup_init_user(void); | 11 | void suspend_wakeup_init_user(void); |
| 12 | void suspend_wakeup_init_kb(void); | 12 | void suspend_wakeup_init_kb(void); |
| 13 | void suspend_wakeup_init_quantum(void); | ||
| 13 | void suspend_power_down_user(void); | 14 | void suspend_power_down_user(void); |
| 14 | void suspend_power_down_kb(void); | 15 | void suspend_power_down_kb(void); |
| 16 | void suspend_power_down_quantum(void); | ||
| 15 | 17 | ||
| 16 | #ifndef USB_SUSPEND_WAKEUP_DELAY | 18 | #ifndef USB_SUSPEND_WAKEUP_DELAY |
| 17 | # define USB_SUSPEND_WAKEUP_DELAY 0 | 19 | # define USB_SUSPEND_WAKEUP_DELAY 0 |
diff --git a/tmk_core/protocol/usb_hid/parser.h b/tmk_core/protocol/usb_hid/parser.h index 036281fa6..ba35b7af5 100644 --- a/tmk_core/protocol/usb_hid/parser.h +++ b/tmk_core/protocol/usb_hid/parser.h | |||
| @@ -1,5 +1,4 @@ | |||
| 1 | #ifndef PARSER_H | 1 | #pragma once |
| 2 | #define PARSER_H | ||
| 3 | 2 | ||
| 4 | #include "hid.h" | 3 | #include "hid.h" |
| 5 | #include "report.h" | 4 | #include "report.h" |
| @@ -11,5 +10,3 @@ public: | |||
| 11 | uint16_t time_stamp; | 10 | uint16_t time_stamp; |
| 12 | virtual void Parse(HID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf); | 11 | virtual void Parse(HID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf); |
| 13 | }; | 12 | }; |
| 14 | |||
| 15 | #endif | ||
diff --git a/tmk_core/protocol/usb_hid/usb_hid.h b/tmk_core/protocol/usb_hid/usb_hid.h index 083b68d1f..5cb5f5d03 100644 --- a/tmk_core/protocol/usb_hid/usb_hid.h +++ b/tmk_core/protocol/usb_hid/usb_hid.h | |||
| @@ -1,10 +1,6 @@ | |||
| 1 | #ifndef USB_HID_H | 1 | #pragma once |
| 2 | #define USB_HID_H | ||
| 3 | 2 | ||
| 4 | #include "report.h" | 3 | #include "report.h" |
| 5 | 4 | ||
| 6 | |||
| 7 | extern report_keyboard_t usb_hid_keyboard_report; | 5 | extern report_keyboard_t usb_hid_keyboard_report; |
| 8 | extern uint16_t usb_hid_time_stamp; | 6 | extern uint16_t usb_hid_time_stamp; |
| 9 | |||
| 10 | #endif | ||
