X-Git-Url: http://cloudbase.mooo.com/gitweb/z180-stamp.git/blobdiff_plain/d684c21619905153eff68c43927207248925f6c2..72f5882239bb88b8a68f305802e0dde37a975604:/avr/background.c 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; +} + +