X-Git-Url: https://git.friedersdorff.com/?a=blobdiff_plain;f=tmk_core%2Fcommon%2Favr%2Fsuspend.c;h=ea8099d067061fc178f775f7f86b47f7e431db83;hb=e7d6d24c17ba103282bf8126011816fc3a0adac3;hp=af99f52b5ee18336f4f332eddf5c37bd9ab5b108;hpb=83a3de38b710d0eb5a752ffded6da2e8bf818b22;p=max%2Ftmk_keyboard.git diff --git a/tmk_core/common/avr/suspend.c b/tmk_core/common/avr/suspend.c index af99f52b..ea8099d0 100644 --- a/tmk_core/common/avr/suspend.c +++ b/tmk_core/common/avr/suspend.c @@ -30,16 +30,6 @@ __asm__ __volatile__ ( \ ) -void suspend_idle(uint8_t time) -{ - cli(); - set_sleep_mode(SLEEP_MODE_IDLE); - sleep_enable(); - sei(); - sleep_cpu(); - sleep_disable(); -} - /* Power down MCU with watchdog timer * wdto: watchdog timer timeout defined in * WDTO_15MS @@ -80,13 +70,49 @@ static void power_down(uint8_t wdto) wdt_disable(); } +#ifdef SUSPEND_MODE_STANDBY +static void standby(void) +{ +#ifdef SLEEP_MODE_STANDBY + set_sleep_mode(SLEEP_MODE_STANDBY); + sleep_enable(); + sei(); + sleep_cpu(); + sleep_disable(); +#endif +} +#endif + +static void idle(void) +{ + set_sleep_mode(SLEEP_MODE_IDLE); + sleep_enable(); + sei(); + sleep_cpu(); + sleep_disable(); +} + + +void suspend_idle(uint8_t time) +{ + idle(); +} + void suspend_power_down(void) { +#ifdef NO_SUSPEND_POWER_DOWN + ; +#elif defined(SUSPEND_MODE_NOPOWERSAVE) + ; +#elif defined(SUSPEND_MODE_STANDBY) + standby(); +#elif defined(SUSPEND_MODE_IDLE) + idle(); +#else power_down(WDTO_15MS); +#endif } -__attribute__ ((weak)) void matrix_power_up(void) {} -__attribute__ ((weak)) void matrix_power_down(void) {} bool suspend_wakeup_condition(void) { matrix_power_up(); @@ -102,6 +128,7 @@ bool suspend_wakeup_condition(void) void suspend_wakeup_init(void) { // clear keyboard state + matrix_clear(); clear_keyboard(); #ifdef BACKLIGHT_ENABLE backlight_init();