7 #include <avr/interrupt.h>
8 #include <util/delay.h>
11 volatile int xvar = 1;
13 /* idle mode will wake up board and will
14 * return PC after latest sleep_mode() call */
15 EMPTY_INTERRUPT(SIG_COMPARATOR);
22 static void switch_idle(void)
25 set_sleep_mode(SLEEP_MODE_IDLE);
29 static void init_board(void)
33 /* enable interal reference for
35 * When the bandgap reference is connected to the Analog Comparator (by setting the ACBG bit in ACSR). */
43 DDRB |= (1 << DDB0); /* set PB0 as output */
45 TCCR0A |= (1 << WGM01) | (1 << WGM00) | (1 << COM0A1);
46 TCCR0B |= (1 << CS02) | (1 << CS00); /* clk/1024 prescaler */
47 OCR0A = 0x7F; /* 50% duty cycle */
49 TIMSK = (1 << OCIE0A); /* enable interrupts for overflow and compare */
54 /* set LRA as sensor and switch to idle mode
55 * check back-EMF of LRA: if treshold is surpassed
56 * comparator intterupt is triggered */
57 // set_lra_as_sensor();
60 // /* board wakes up, set LRA as actuator and
61 // * plays haptic effect */
62 // set_lra_as_actuator();