From: Robin Krens Date: Thu, 19 May 2022 11:36:39 +0000 (+0200) Subject: hbc: timer setup X-Git-Url: https://robinkrens.nl/gitweb/?a=commitdiff_plain;h=363317aed5baa977a38ce089300bf7ef8c323ed8;p=lra-as-sensor hbc: timer setup --- diff --git a/hbc.c b/hbc.c index c5749cc..d0169bd 100644 --- a/hbc.c +++ b/hbc.c @@ -7,16 +7,24 @@ #include #include #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(); }