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:
30ec050
)
hbc: timer setup
author
Robin Krens
<robin@robinkrens.nl>
Thu, 19 May 2022 11:36:39 +0000
(13:36 +0200)
committer
Robin Krens
<robin@robinkrens.nl>
Thu, 19 May 2022 11:36:39 +0000
(13:36 +0200)
hbc.c
patch
|
blob
|
history
diff --git
a/hbc.c
b/hbc.c
index
c5749cc
..
d0169bd
100644
(file)
--- a/
hbc.c
+++ b/
hbc.c
@@
-7,16
+7,24
@@
#include <avr/interrupt.h>
#include <util/delay.h>
#include "haptic.h"
#include <avr/interrupt.h>
#include <util/delay.h>
#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);
/* 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)
{
}
/* for debugging purposes */
ISR(BADISR_vect)
{
}
+
static void switch_idle(void)
{
sei();
static void switch_idle(void)
{
sei();
@@
-36,20
+44,28
@@
static void init_board(void)
int main(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 */
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();
}
}