X-Git-Url: https://robinkrens.nl/gitweb/?p=lra-as-sensor;a=blobdiff_plain;f=hbc.c;h=c5749ccbe4706cbc5ca4db877c7138959589f3cf;hp=a0e77e0385048f6dfc34c2318b306ee4c6c704ae;hb=b24e7613a4cca474c0d9c101ddbc7ec885a08d59;hpb=b5003bc24fecbcdf437ddb7d8ef2b54f3649c6c2 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(); + + } }