From 363317aed5baa977a38ce089300bf7ef8c323ed8 Mon Sep 17 00:00:00 2001 From: Robin Krens Date: Thu, 19 May 2022 13:36:39 +0200 Subject: [PATCH] hbc: timer setup --- hbc.c | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) 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(); } -- 2.7.4