]> git.donarmstrong.com Git - qmk_firmware.git/blobdiff - tmk_core/common/avr/suspend.c
Merge branch 'master' of github.com:qmk/qmk_firmware into hf/shinydox
[qmk_firmware.git] / tmk_core / common / avr / suspend.c
index 81e4266410b2349a1f7549b9a3d1576403bda102..dfa1af273c0b238aea6e7fe7933a248b6c67a2f4 100644 (file)
@@ -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
@@ -101,8 +116,10 @@ static void power_down(uint8_t wdto)
 #ifdef RGBLIGHT_ANIMATIONS
   rgblight_timer_disable();
 #endif
-  rgblight_disable();
+  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
@@ -157,11 +189,12 @@ void suspend_wakeup_init(void)
 #endif
        led_set(host_keyboard_leds());
 #ifdef RGBLIGHT_SLEEP
-  rgblight_enable();
+  rgblight_enable_noeeprom();
 #ifdef RGBLIGHT_ANIMATIONS
   rgblight_timer_enable();
 #endif
 #endif
+  suspend_wakeup_init_kb();
 }
 
 #ifndef NO_SUSPEND_POWER_DOWN