summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2017-04-02 16:37:42 -0700
committerKeith Packard <keithp@keithp.com>2017-04-02 16:37:42 -0700
commit1bc48b075f76bfef258f516549573429b24f284c (patch)
treeaa67f380b3358e84621846a4ac60b62f23367281
parent8284d3639cd24e2fa0faf1e35e7276ba35a24f8f (diff)
cortexelf-v1: Add buttons
Signed-off-by: Keith Packard <keithp@keithp.com>
-rw-r--r--src/cortexelf-v1/Makefile2
-rw-r--r--src/cortexelf-v1/ao_cortexelf.c20
-rw-r--r--src/cortexelf-v1/ao_pins.h24
3 files changed, 46 insertions, 0 deletions
diff --git a/src/cortexelf-v1/Makefile b/src/cortexelf-v1/Makefile
index cea75ddf..f7c892bc 100644
--- a/src/cortexelf-v1/Makefile
+++ b/src/cortexelf-v1/Makefile
@@ -68,6 +68,8 @@ ALTOS_SRC = \
ao_bufio.c \
ao_fat.c \
ao_flash_stm.c \
+ ao_button.c \
+ ao_event.c \
ao_lisp_lex.c \
ao_lisp_mem.c \
ao_lisp_cons.c \
diff --git a/src/cortexelf-v1/ao_cortexelf.c b/src/cortexelf-v1/ao_cortexelf.c
index f9be59e8..8be7ef15 100644
--- a/src/cortexelf-v1/ao_cortexelf.c
+++ b/src/cortexelf-v1/ao_cortexelf.c
@@ -28,6 +28,8 @@
#include <ao_sdcard.h>
#include <ao_fat.h>
#include <ao_lisp.h>
+#include <ao_button.h>
+#include <ao_event.h>
struct ao_task ball_task;
@@ -208,6 +210,21 @@ __code struct ao_cmds ao_demo_cmds[] = {
{ 0, NULL }
};
+static struct ao_task event_task;
+
+static void
+ao_event_loop(void)
+{
+ for (;;) {
+ struct ao_event ev;
+
+ ao_event_get(&ev);
+ printf("type %d uint %d tick %d value %d\n",
+ ev.type, ev.unit, ev.tick, ev.value);
+ flush();
+ }
+}
+
int
main(void)
{
@@ -236,9 +253,12 @@ main(void)
ao_usb_init();
+ ao_button_init();
+
ao_config_init();
ao_add_task(&ball_task, ao_ball, "ball");
+ ao_add_task(&event_task, ao_event_loop, "events");
ao_cmd_register(&ao_demo_cmds[0]);
ao_start_scheduler();
diff --git a/src/cortexelf-v1/ao_pins.h b/src/cortexelf-v1/ao_pins.h
index e9c9deb3..d39f4022 100644
--- a/src/cortexelf-v1/ao_pins.h
+++ b/src/cortexelf-v1/ao_pins.h
@@ -125,4 +125,28 @@
#define AO_SDCARD_SPI_MISO_PIN 3
#define AO_SDCARD_SPI_MOSI_PIN 4
+/* Buttons */
+
+#define AO_EVENT 1
+
+#define AO_BUTTON_COUNT 4
+#define AO_BUTTON_MODE AO_EXTI_MODE_PULL_DOWN
+
+/* INPUT */
+#define AO_BUTTON_0_PORT (&stm_gpioc)
+#define AO_BUTTON_0 8
+
+/* MP */
+#define AO_BUTTON_1_PORT (&stm_gpioc)
+#define AO_BUTTON_1 9
+
+/* RUN */
+#define AO_BUTTON_2_PORT (&stm_gpioc)
+#define AO_BUTTON_2 10
+
+/* LOAD */
+#define AO_BUTTON_3_PORT (&stm_gpioc)
+#define AO_BUTTON_3 11
+
+
#endif /* _AO_PINS_H_ */