X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=tmk_core%2Fcommon%2Fchibios%2Fsuspend.c;h=4a119ccefee60d7e02280d026826953d27814227;hb=aeee735f3572d266a356926852838d4573369796;hp=6ca16034f3840f1b9230476ed2790af1d9f0a04f;hpb=55b8b8477cc6aee82dfe6792eea4e589cac433d5;p=qmk_firmware.git diff --git a/tmk_core/common/chibios/suspend.c b/tmk_core/common/chibios/suspend.c index 6ca16034f..4a119ccef 100644 --- a/tmk_core/common/chibios/suspend.c +++ b/tmk_core/common/chibios/suspend.c @@ -10,23 +10,52 @@ #include "host.h" #include "backlight.h" #include "suspend.h" +#include "wait.h" +/** \brief suspend idle + * + * FIXME: needs doc + */ void suspend_idle(uint8_t time) { // TODO: this is not used anywhere - what units is 'time' in? - chThdSleepMilliseconds(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 + */ void suspend_power_down(void) { // TODO: figure out what to power down and how // 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 - chThdSleepMilliseconds(17); + wait_ms(17); } +/** \brief suspend wakeup condition + * + * FIXME: needs doc + */ __attribute__ ((weak)) void matrix_power_up(void) {} __attribute__ ((weak)) void matrix_power_down(void) {} bool suspend_wakeup_condition(void) @@ -40,7 +69,27 @@ bool suspend_wakeup_condition(void) return false; } -// run immediately after wakeup +/** \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 + * FIXME: needs doc + */ void suspend_wakeup_init(void) { // clear keyboard state @@ -62,4 +111,5 @@ void suspend_wakeup_init(void) #ifdef BACKLIGHT_ENABLE backlight_init(); #endif /* BACKLIGHT_ENABLE */ + suspend_wakeup_init_kb(); }