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
#include <util/delay.h>
#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();
{
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();
+
+ }
}