From 8f969d6544275f5b79776fcfa5a2db973be09355 Mon Sep 17 00:00:00 2001 From: tmk Date: Tue, 4 Oct 2016 16:05:18 +0900 Subject: [PATCH] core: Add suspend mode options --- tmk_core/common/avr/suspend.c | 40 ++++++++++++++++++++++++++--------- 1 file changed, 30 insertions(+), 10 deletions(-) diff --git a/tmk_core/common/avr/suspend.c b/tmk_core/common/avr/suspend.c index 580d69e4..b9b58c15 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,9 +70,39 @@ static void power_down(uint8_t wdto) wdt_disable(); } +static void standby(void) +{ + set_sleep_mode(SLEEP_MODE_STANDBY); + sleep_enable(); + sei(); + sleep_cpu(); + sleep_disable(); +} + +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 SUSPEND_MODE_STANDBY + standby(); +#elif defined(SUSPEND_MODE_IDLE) + idle(); +#else power_down(WDTO_15MS); +#endif } __attribute__ ((weak)) void matrix_power_up(void) {} -- 2.39.3