#include <avr/interrupt.h>
#include <util/delay.h>
#include "haptic.h"
+
+volatile int xvar = 1;
+
+/* idle mode will wake up board and will
+ * return PC after latest sleep_mode() call */
+EMPTY_INTERRUPT(SIG_COMPARATOR);
+
+ISR(TIM0_COMPA_vect)
+{
+ xvar++;
+}
+ISR(TIM0_COMPB_vect)
+{
+ xvar++;
+}
+
+ISR(TIM0_OVF_vect)
+{
+ //xvar++;
+}
+
-/* wake up on interrupt */
static void switch_idle(void)
{
sei();
int main(void)
{
-
- init_board();
- DDRB |= (1 << DDB3);
- PORTB = (1 << PB3);
+ init_board();
+ xvar = 1;
+ cli();
+ DDRB |= (1 << DDB0); /* set PB0 as output */
+ TCCR0A = TCCR0B = 0;
+ TCCR0A |= (1 << WGM01) | (1 << WGM00) | (1 << COM0A1);
+ TCCR0B |= (1 << CS02) | (1 << CS00); /* clk/1024 prescaler */
+ OCR0A = 0x7F; /* 50% duty cycle */
+ TCNT0 = 0;
+ TIMSK = (1 << OCIE0A) | (1 << OCIE0B) | (1 << TOIE0); /* enable interrupts for overflow and compare */
+ sei();
while(1) {
- _delay_ms(2);
- PORTB = 0;
- _delay_ms(2);
- PORTB = (1 << PB3);
- }
+ _delay_ms(100);
+ /* set LRA as sensor and switch to idle mode
+ * check back-EMF of LRA: if treshold is surpassed
+ * comparator intterupt is triggered */
+// set_lra_as_sensor();
+// switch_idle();
+//
+// /* board wakes up, set LRA as actuator and
+// * plays haptic effect */
+// set_lra_as_actuator();
+// play_haptic();
- return 0;
+ }
}