6 void suspend_power_down(void)
8 #ifndef NO_SUSPEND_POWER_DOWN
9 // Enable watchdog to wake from MCU sleep
13 // Watchdog Interrupt and System Reset Mode
14 //wdt_enable(WDTO_1S);
15 //WDTCSR |= _BV(WDIE);
17 // Watchdog Interrupt Mode
18 wdt_intr_enable(WDTO_120MS);
20 // TODO: more power saving
21 // See PicoPower application note
22 // - I/O port input with pullup
25 // - Power Reduction Register PRR
26 // sleep in power down mode
27 set_sleep_mode(SLEEP_MODE_PWR_DOWN);
33 // Disable watchdog after sleep
38 bool suspend_wakeup_condition(void)
41 for (uint8_t r = 0; r < MATRIX_ROWS; r++) {
42 if (matrix_get_row(r)) return true;
47 // run immediately after wakeup
48 void suspend_wakeup_init(void)
50 // clear matrix and keyboard state
55 #ifndef NO_SUSPEND_POWER_DOWN
56 /* watchdog timeout */
59 /* wakeup from MCU sleep mode */
62 static uint8_t led_state = 0;
63 static uint8_t led_count = 0;
65 if ((led_count & 0x07) == 0) {
66 led_set((led_state ^= (1<<USB_LED_CAPS_LOCK)));