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);
32 static void switch_idle(void)
35 set_sleep_mode(SLEEP_MODE_IDLE);
39 static void init_board(void)
43 /* enable interal reference for
45 * When the bandgap reference is connected to the Analog Comparator (by setting the ACBG bit in ACSR). */
53 DDRB |= (1 << DDB0); /* set PB0 as output */
55 TCCR0A |= (1 << WGM01) | (1 << WGM00) | (1 << COM0A1);
56 TCCR0B |= (1 << CS02) | (1 << CS00); /* clk/1024 prescaler */
57 OCR0A = 0x7F; /* 50% duty cycle */
59 TIMSK = (1 << OCIE0A) | (1 << OCIE0B) | (1 << TOIE0); /* enable interrupts for overflow and compare */
64 /* set LRA as sensor and switch to idle mode
65 * check back-EMF of LRA: if treshold is surpassed
66 * comparator intterupt is triggered */
67 // set_lra_as_sensor();
70 // /* board wakes up, set LRA as actuator and
71 // * plays haptic effect */
72 // set_lra_as_actuator();