diff options
Diffstat (limited to 'tmk_core')
-rw-r--r-- | tmk_core/common/avr/suspend.c | 33 | ||||
-rw-r--r-- | tmk_core/common/chibios/suspend.c | 33 | ||||
-rw-r--r-- | tmk_core/common/suspend.h | 5 |
3 files changed, 71 insertions, 0 deletions
diff --git a/tmk_core/common/avr/suspend.c b/tmk_core/common/avr/suspend.c index 3aa3d12474..dfa1af273c 100644 --- a/tmk_core/common/avr/suspend.c +++ b/tmk_core/common/avr/suspend.c @@ -72,6 +72,21 @@ void suspend_idle(uint8_t time) */ static uint8_t wdt_timeout = 0; +/** \brief Run keyboard level Power down + * + * FIXME: needs doc + */ +__attribute__ ((weak)) +void suspend_power_down_user (void) { } +/** \brief Run keyboard level Power down + * + * FIXME: needs doc + */ +__attribute__ ((weak)) +void suspend_power_down_kb(void) { + suspend_power_down_user(); +} + /** \brief Power down * * FIXME: needs doc @@ -103,6 +118,8 @@ static void power_down(uint8_t wdto) #endif rgblight_disable_noeeprom(); #endif + suspend_power_down_kb(); + // TODO: more power saving // See PicoPower application note // - I/O port input with pullup @@ -144,6 +161,21 @@ bool suspend_wakeup_condition(void) return false; } +/** \brief run user level code immediately after wakeup + * + * FIXME: needs doc + */ +__attribute__ ((weak)) +void suspend_wakeup_init_user(void) { } + +/** \brief run keyboard level code immediately after wakeup + * + * FIXME: needs doc + */ +__attribute__ ((weak)) +void suspend_wakeup_init_kb(void) { + suspend_wakeup_init_user(); +} /** \brief run immediately after wakeup * * FIXME: needs doc @@ -162,6 +194,7 @@ void suspend_wakeup_init(void) rgblight_timer_enable(); #endif #endif + suspend_wakeup_init_kb(); } #ifndef NO_SUSPEND_POWER_DOWN diff --git a/tmk_core/common/chibios/suspend.c b/tmk_core/common/chibios/suspend.c index 32ef773e2e..4a119ccefe 100644 --- a/tmk_core/common/chibios/suspend.c +++ b/tmk_core/common/chibios/suspend.c @@ -21,6 +21,21 @@ void suspend_idle(uint8_t time) { wait_ms(time); } +/** \brief Run keyboard level Power down + * + * FIXME: needs doc + */ +__attribute__ ((weak)) +void suspend_power_down_user (void) { } +/** \brief Run keyboard level Power down + * + * FIXME: needs doc + */ +__attribute__ ((weak)) +void suspend_power_down_kb(void) { + suspend_power_down_user(); +} + /** \brief suspend power down * * FIXME: needs doc @@ -30,6 +45,7 @@ void suspend_power_down(void) { // shouldn't power down TPM/FTM if we want a breathing LED // also shouldn't power down USB + suspend_power_down_kb(); // on AVR, this enables the watchdog for 15ms (max), and goes to // SLEEP_MODE_PWR_DOWN @@ -53,6 +69,22 @@ bool suspend_wakeup_condition(void) return false; } +/** \brief run user level code immediately after wakeup + * + * FIXME: needs doc + */ +__attribute__ ((weak)) +void suspend_wakeup_init_user(void) { } + +/** \brief run keyboard level code immediately after wakeup + * + * FIXME: needs doc + */ +__attribute__ ((weak)) +void suspend_wakeup_init_kb(void) { + suspend_power_down_user(); +} + /** \brief suspend wakeup condition * * run immediately after wakeup @@ -79,4 +111,5 @@ void suspend_wakeup_init(void) #ifdef BACKLIGHT_ENABLE backlight_init(); #endif /* BACKLIGHT_ENABLE */ + suspend_wakeup_init_kb(); } diff --git a/tmk_core/common/suspend.h b/tmk_core/common/suspend.h index 80617a8244..c3e4447085 100644 --- a/tmk_core/common/suspend.h +++ b/tmk_core/common/suspend.h @@ -10,4 +10,9 @@ void suspend_power_down(void); bool suspend_wakeup_condition(void); void suspend_wakeup_init(void); +void suspend_wakeup_init_user(void); +void suspend_wakeup_init_kb(void); +void suspend_power_down_user (void); +void suspend_power_down_kb(void); + #endif |