projects
/
lra-as-sensor
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
b5003bc
)
hbc: interrupt stubs
author
Robin Krens
<robin@robinkrens.nl>
Wed, 18 May 2022 22:29:43 +0000
(
00:29
+0200)
committer
Robin Krens
<robin@robinkrens.nl>
Wed, 18 May 2022 22:29:43 +0000
(
00:29
+0200)
haptic.c
patch
|
blob
|
history
hbc.c
patch
|
blob
|
history
diff --git
a/haptic.c
b/haptic.c
index
73a87d3
..
727c3b2
100644
(file)
--- a/
haptic.c
+++ b/
haptic.c
@@
-5,12
+5,13
@@
void set_lra_as_sensor(void)
{
void set_lra_as_sensor(void)
{
-
+ /* enable interrupt routine and
+ * set correct PINs */
}
void set_lra_as_actuator(void)
{
}
void set_lra_as_actuator(void)
{
-
+ /* set correct PINs */
}
/* play random haptic effect on lra
}
/* play random haptic effect on lra
diff --git
a/hbc.c
b/hbc.c
index
a0e77e0
..
c5749cc
100644
(file)
--- a/
hbc.c
+++ b/
hbc.c
@@
-8,7
+8,15
@@
#include <util/delay.h>
#include "haptic.h"
#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();
static void switch_idle(void)
{
sei();
@@
-29,16
+37,20
@@
int main(void)
{
init_board();
{
init_board();
- DDRB |= (1 << DDB3);
- PORTB = (1 << PB3);
while(1) {
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();
+
+ }
}
}