summaryrefslogtreecommitdiff
path: root/avr/background.c
diff options
context:
space:
mode:
authorLeo C2014-08-13 21:00:21 +0200
committerLeo C2014-08-13 21:00:21 +0200
commit72f5882239bb88b8a68f305802e0dde37a975604 (patch)
treea932ba22f7174de0fd773cf31d4d914dd548dfdd /avr/background.c
parentd684c21619905153eff68c43927207248925f6c2 (diff)
downloadz180-stamp-72f5882239bb88b8a68f305802e0dde37a975604.zip
Add memory commands (cmp, cp, md, mm, mw, nm)
Add kind of scheduler for background tasks
Diffstat (limited to 'avr/background.c')
-rw-r--r--avr/background.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/avr/background.c b/avr/background.c
new file mode 100644
index 0000000..37e4b02
--- /dev/null
+++ b/avr/background.c
@@ -0,0 +1,31 @@
+#include "common.h"
+#include "background.h"
+
+
+#define BG_FUNC_MAX 5
+
+static bg_func func_tab[BG_FUNC_MAX];
+static int_fast8_t fcount;
+
+int bg_register(bg_func f)
+{
+ if (fcount < BG_FUNC_MAX) {
+ func_tab[fcount++] = f;
+ return 1;
+ }
+ return 0;
+}
+
+
+void bg_shed(void)
+{
+ static int_fast8_t current;
+
+ if (func_tab[current]) {
+ func_tab[current](0);
+ }
+ if (++current >= fcount)
+ current = 0;
+}
+
+