2 #include <util/delay.h>
4 #include <avr/interrupt.h>
10 static void hw_setup()
24 set_sleep_mode(SLEEP_MODE_IDLE);
27 static void hw_suspend()
39 uint16_t wake_count = 0;
44 // enable PCINT14, so that user can wake up later
46 PCMSK1 |= _BV(PCINT14);
49 set_sleep_mode(SLEEP_MODE_PWR_DOWN);
62 PCMSK1 &= ~_BV(PCINT14);
64 // allow wakeup by long button-press only
65 for (btn = 0; btn < 5; btn++) {
66 if ((PINB & _BV(PB6)) != 0) {
73 // ok, so I will wake up
85 PCMSK1 &= ~_BV(PCINT14);
91 power_usi_disable(); // Once for lifetime
111 PORTB &=~ _BV( PB2 );