summaryrefslogtreecommitdiff
path: root/fw/fe310/phone/timer.c
diff options
context:
space:
mode:
Diffstat (limited to 'fw/fe310/phone/timer.c')
-rw-r--r--fw/fe310/phone/timer.c47
1 files changed, 47 insertions, 0 deletions
diff --git a/fw/fe310/phone/timer.c b/fw/fe310/phone/timer.c
new file mode 100644
index 0000000..03593ff
--- /dev/null
+++ b/fw/fe310/phone/timer.c
@@ -0,0 +1,47 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+
+#include <eos.h>
+#include <soc/timer.h>
+#include <dev/net.h>
+
+#include <eve/eve.h>
+#include <eve/eve_kbd.h>
+#include <eve/eve_font.h>
+
+#include <eve/screen/window.h>
+#include <eve/screen/page.h>
+#include <eve/screen/form.h>
+
+#include "app/app.h"
+
+#include "timer.h"
+
+static void timer(unsigned char evt) {
+ int rv;
+
+ printf("TIMER\n");
+ eos_timer_set(EOS_TIMER_ETYPE_USR, 500);
+}
+
+int timer_app(EVEWindow *window, EVEViewStack *stack) {
+ EVEFormSpec spec[] = {
+ APP_SPACERW(1,1),
+ };
+ EVEPage *page = eve_form_create(window, stack, spec, APP_SPEC_SIZE(spec), NULL, timer_close);
+ if (page == NULL) return EVE_ERR_NOMEM;
+ eos_timer_set_handler(EOS_TIMER_ETYPE_USR, timer);
+ eos_timer_set(EOS_TIMER_ETYPE_USR, 500);
+ eos_net_acquire_for_evt(EOS_EVT_TIMER | EOS_TIMER_ETYPE_USR, 1);
+
+ return EVE_OK;
+}
+
+void timer_close(EVEPage *page) {
+ eos_timer_clear(EOS_TIMER_ETYPE_USR);
+ eos_timer_set_handler(EOS_TIMER_ETYPE_USR, NULL);
+ eos_net_acquire_for_evt(EOS_EVT_TIMER | EOS_TIMER_ETYPE_USR, 0);
+ eve_form_destroy(page);
+}