From: Robin Krens Date: Wed, 18 May 2022 22:29:43 +0000 (+0200) Subject: hbc: interrupt stubs X-Git-Url: https://robinkrens.nl/gitweb/?p=lra-as-sensor;a=commitdiff_plain;h=b24e7613a4cca474c0d9c101ddbc7ec885a08d59 hbc: interrupt stubs --- diff --git a/haptic.c b/haptic.c index 73a87d3..727c3b2 100644 --- a/haptic.c +++ b/haptic.c @@ -5,12 +5,13 @@ void set_lra_as_sensor(void) { - + /* enable interrupt routine and + * set correct PINs */ } void set_lra_as_actuator(void) { - + /* set correct PINs */ } /* play random haptic effect on lra diff --git a/hbc.c b/hbc.c index a0e77e0..c5749cc 100644 --- a/hbc.c +++ b/hbc.c @@ -8,7 +8,15 @@ #include #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(); + + } }