hbc: added stub files
authorRobin Krens <robin@robinkrens.nl>
Wed, 18 May 2022 21:27:04 +0000 (23:27 +0200)
committerRobin Krens <robin@robinkrens.nl>
Wed, 18 May 2022 21:27:04 +0000 (23:27 +0200)
Makefile
haptic.c [new file with mode: 0644]
haptic.h [new file with mode: 0644]
hbc.c

index 6b3bf06..f8cbf9e 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -19,10 +19,10 @@ CFLAGS += -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums
 LDFLAGS = -Wl,-Map,hbc.map
 TARGET_ARCH = -mmcu=$(MCU)
 
-DEPS = 
+DEPS = haptic.h
 
 ODIR = obj
-_OBJ = hbc.o
+_OBJ = hbc.o haptic.o
 OBJ = $(patsubst %, $(ODIR)/%,$(_OBJ))
 
 $(ODIR)/%.o: %.c $(DEPS)
diff --git a/haptic.c b/haptic.c
new file mode 100644 (file)
index 0000000..73a87d3
--- /dev/null
+++ b/haptic.c
@@ -0,0 +1,27 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <avr/io.h>
+#include "haptic.h"
+
+void set_lra_as_sensor(void)
+{
+
+}
+
+void set_lra_as_actuator(void)
+{
+
+}
+
+/* play random haptic effect on lra
+ * lra is used as an actuator*/
+void play_haptic(void)
+{
+       int c = CLICK;
+       switch(c) {
+               case CLICK: 
+                       break;
+               default: 
+                       break;
+       }
+}
diff --git a/haptic.h b/haptic.h
new file mode 100644 (file)
index 0000000..ec02bd0
--- /dev/null
+++ b/haptic.h
@@ -0,0 +1,10 @@
+enum {
+       CLICK = 0,
+       DOUBLE_CLICK,
+       SWEEP,
+       BUZZ,
+};
+
+void set_lra_as_sensor(void);
+void set_lra_as_actuator(void);
+void play_haptic(void);
diff --git a/hbc.c b/hbc.c
index 0cca0dc..a0e77e0 100644 (file)
--- a/hbc.c
+++ b/hbc.c
@@ -1,14 +1,34 @@
+#include <stdio.h>
+#include <stdlib.h>
 #include <avr/io.h>
+#include <avr/wdt.h>
+#include <avr/sleep.h>
+#include <avr/power.h>
 #include <avr/interrupt.h>
+#include <util/delay.h>
+#include "haptic.h"
 
-#include <stdio.h>
-#include <stdlib.h>
+/* wake up on interrupt */
+static void switch_idle(void)
+{
+       sei();
+       set_sleep_mode(SLEEP_MODE_IDLE);
+       sleep_mode();
+}
 
-#include <util/delay.h>
+static void init_board(void)
+{
+       power_adc_disable();
+       wdt_disable();
+       /* enable interal reference for 
+        * comparator 
+        * When the bandgap reference is connected to the Analog Comparator (by setting the ACBG bit in ACSR). */
+}
 
-int main(void) {
-       
+int main(void)
+{
        
+       init_board();   
        DDRB |= (1 << DDB3);
        PORTB = (1 << PB3);