2 #include <util/delay.h>
4 #include <avr/interrupt.h>
23 set_sleep_mode(SLEEP_MODE_IDLE);
38 uint16_t wake_count = 0;
42 // enable PCINT14, so that user can wake up later
44 PCMSK1 |= _BV(PCINT14);
47 set_sleep_mode(SLEEP_MODE_PWR_DOWN);
60 PCMSK1 &= ~_BV(PCINT14);
62 // allow wakeup by long button-press only
63 for (btn = 0; btn < 5; btn++) {
64 if ((PINB & _BV(PB6)) != 0) {
71 // ok, so I will wake up
83 PCMSK1 &= ~_BV(PCINT14);
89 power_usi_disable(); // Once for lifetime
110 PORTB &=~ _BV( PB2 );