hbc: timer setup
authorRobin Krens <robin@robinkrens.nl>
Thu, 19 May 2022 11:36:39 +0000 (13:36 +0200)
committerRobin Krens <robin@robinkrens.nl>
Thu, 19 May 2022 11:36:39 +0000 (13:36 +0200)
hbc.c

diff --git a/hbc.c b/hbc.c
index c5749cc..d0169bd 100644 (file)
--- a/hbc.c
+++ b/hbc.c
@@ -7,16 +7,24 @@
 #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_OVF_vect)
+{
+       xvar++;
+}
+
 /* for debugging purposes */
 ISR(BADISR_vect) 
 {
 }
 
+
 static void switch_idle(void)
 {
        sei();
@@ -36,20 +44,28 @@ static void init_board(void)
 int main(void)
 {
        
-       init_board();   
+       init_board();
+
+       xvar = 1;
+       cli();
+       TCCR0A = 0x00;
+       TCCR0B = (1 << CS00) | (1 << CS02);
+       TCNT0 = 0;
+       TIMSK |= (1 << TOIE0);
+       sei();
 
        while(1) {
 
                /* 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();
+//             set_lra_as_sensor();
+//             switch_idle(); 
+//
+//             /* board wakes up, set LRA as actuator and
+//              * plays haptic effect */
+//             set_lra_as_actuator();
+//             play_haptic();
 
        }