7 void suspend_power_down(void)
9 #ifdef BACKLIGHT_ENABLE
12 #ifndef NO_SUSPEND_POWER_DOWN
13 // Enable watchdog to wake from MCU sleep
17 // Watchdog Interrupt and System Reset Mode
18 //wdt_enable(WDTO_1S);
19 //WDTCSR |= _BV(WDIE);
21 // Watchdog Interrupt Mode
22 wdt_intr_enable(WDTO_120MS);
24 // TODO: more power saving
25 // See PicoPower application note
26 // - I/O port input with pullup
29 // - Power Reduction Register PRR
30 // sleep in power down mode
31 set_sleep_mode(SLEEP_MODE_PWR_DOWN);
37 // Disable watchdog after sleep
42 bool suspend_wakeup_condition(void)
45 for (uint8_t r = 0; r < MATRIX_ROWS; r++) {
46 if (matrix_get_row(r)) return true;
51 // run immediately after wakeup
52 void suspend_wakeup_init(void)
54 // clear keyboard state
56 #ifdef BACKLIGHT_ENABLE
61 #ifndef NO_SUSPEND_POWER_DOWN
62 /* watchdog timeout */
65 /* wakeup from MCU sleep mode */
68 static uint8_t led_state = 0;
69 static uint8_t led_count = 0;
71 if ((led_count & 0x07) == 0) {
72 led_set((led_state ^= (1<<USB_LED_CAPS_LOCK)));