2 #include <util/delay.h>
4 #include <avr/interrupt.h>
24 set_sleep_mode(SLEEP_MODE_IDLE);
39 uint16_t wake_count = 0;
43 // enable PCINT14, so that user can wake up later
45 PCMSK1 |= _BV(PCINT14);
48 set_sleep_mode(SLEEP_MODE_PWR_DOWN);
61 PCMSK1 &= ~_BV(PCINT14);
63 // allow wakeup by long button-press only
64 for (btn = 0; btn < 5; btn++) {
65 if ((PINB & _BV(PB6)) != 0) {
72 // ok, so I will wake up
84 PCMSK1 &= ~_BV(PCINT14);
90 power_usi_disable(); // Once for lifetime
111 PORTB &=~ _BV( PB2 );