From: Mart Lubbers Date: Thu, 2 Mar 2017 17:29:42 +0000 (+0100) Subject: build C support for interrupts X-Git-Url: https://git.martlubbers.net/?a=commitdiff_plain;h=c3bb3dde2bb886a9f86f9de5f4f96beb8d86b53d;p=mTask.git build C support for interrupts --- diff --git a/client/main.c b/client/main.c index f86beff..1818238 100644 --- a/client/main.c +++ b/client/main.c @@ -74,17 +74,19 @@ void loop(void) // debug("Task %d not implemented\n", ct); continue; } - //Onshot task - if(curtask->interval == 0){ - run_task(curtask); - curtask->used = false; - //Interrupt task - } else if(curtask->interval & 32768){ + //interrupt task + if(is_interrupt_task(curtask) && had_interrupt(curtask)){ debug("Interrupt task %d not implemented", ct); - //Interval task, check if interval is passed + run_task(curtask); + //Interval task, and interval passed } else if(cyclestart-curtask->lastrun > curtask->interval){ debug("Running interval task: %d", ct); run_task(curtask); + + //Oneshot task, thus disable + if(curtask->interval == 0){ + curtask->used = false; + } curtask->lastrun = cyclestart; } } diff --git a/client/task.c b/client/task.c index 1dd8ffb..dfdb71b 100644 --- a/client/task.c +++ b/client/task.c @@ -30,6 +30,12 @@ void task_register(void) memset(&tasks[ct], 0, sizeof(struct task)); //Read interval tasks[ct].interval = read16(); + + //Interrupt task + if(is_interrupt_task(&tasks[ct])) { + + } + //Read tasklength tasks[ct].tlen = read16(); debug("task interval: %d, length: %d\n", @@ -53,6 +59,18 @@ void task_register(void) write_byte('\n'); } +bool is_interrupt_task(struct task *t) +{ + return t->interval & (2 <<14); +} + +bool had_interrupt(struct task* t) +{ + //Not implemented yet... + return false; + (void)t; +} + void task_delete(void) { uint8_t c = read16(); diff --git a/client/task.h b/client/task.h index 0ea1b99..6c7dfd3 100644 --- a/client/task.h +++ b/client/task.h @@ -15,6 +15,9 @@ struct task { bool used; }; +bool is_interrupt_task(struct task* t); +bool had_interrupt(struct task* t); + void task_init(void); void task_register(void); void task_delete(void);