hbc: interrupt stubs
[lra-as-sensor] / hbc.c
diff --git a/hbc.c b/hbc.c
index a0e77e0..c5749cc 100644 (file)
--- a/hbc.c
+++ b/hbc.c
@@ -8,7 +8,15 @@
 #include <util/delay.h>
 #include "haptic.h"
 
-/* wake up on interrupt */
+/* idle mode will wake up board and will
+ * return PC after latest sleep_mode() call */
+EMPTY_INTERRUPT(SIG_COMPARATOR);
+
+/* for debugging purposes */
+ISR(BADISR_vect) 
+{
+}
+
 static void switch_idle(void)
 {
        sei();
@@ -29,16 +37,20 @@ int main(void)
 {
        
        init_board();   
-       DDRB |= (1 << DDB3);
-       PORTB = (1 << PB3);
 
        while(1) {
-               _delay_ms(2);
-               PORTB = 0;
-               _delay_ms(2);
-               PORTB = (1 << PB3);
-       }
 
-       return 0;
+               /* 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();
+
+       }
 
 }