X-Git-Url: https://oss.titaniummirror.com/gitweb?a=blobdiff_plain;f=task.c;h=b2197f936908fa12b5a42844678124eda1501e8d;hb=a3982b963fd174f5d267e88ad97388f1697f6f83;hp=a3489248a6d6242d77392cea0e3d4d9557f06f0b;hpb=d7221e9aeb82c97fbbff18963ef69a300b3d0cd3;p=rgblamp.git diff --git a/task.c b/task.c index a348924..b2197f9 100644 --- a/task.c +++ b/task.c @@ -27,7 +27,7 @@ bit task_check() task_id_t task_get(unsigned char block) { - task_id_t t = 0; + task_id_t t = -1; unsigned long ids; do { @@ -35,24 +35,18 @@ task_id_t task_get(unsigned char block) ids = _task_ids; nei(); if (ids) { - for (unsigned char i = 0; t == 0 && i < TASK_COUNT; i++) { - if (ids & (1UL << _task_bitno)) + for (unsigned char i = 0; t == -1 && i < TASK_COUNT; i++) { + if (bit_get(ids, _task_bitno)) { t = _task_bitno; - _task_bitno = (_task_bitno + 1) % TASK_COUNT; + ndi(); + bit_clr(_task_ids, t); + nei(); + } + if (++_task_bitno == TASK_COUNT) + _task_bitno = 0; } } -#if 0 /* Not until we have a crystal and can wake from sleep via tmr module */ - else - SLEEP(); -#endif - } while (t == 0 && block == 1); + } while (t == -1 && block == 1); return t; } -void task_post(task_id_t t) -{ - ndi(); - _task_post(t); - nei(); -} -