]> git.friedersdorff.com Git - max/tmk_keyboard.git/blobdiff - tmk_core/common/avr/suspend.c
core: Fix sleep_led
[max/tmk_keyboard.git] / tmk_core / common / avr / suspend.c
index 80243f02bc7448d8a6880afad9718bdff11af4fd..02d7e4c9426eea2921a4322d3959fe8952c7154d 100644 (file)
@@ -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 <avr/wdt.h>
  *          WDTO_15MS
@@ -80,9 +70,43 @@ 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 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
 }
 
 bool suspend_wakeup_condition(void)
@@ -100,6 +124,7 @@ bool suspend_wakeup_condition(void)
 void suspend_wakeup_init(void)
 {
     // clear keyboard state
+    matrix_clear();
     clear_keyboard();
 #ifdef BACKLIGHT_ENABLE
     backlight_init();