diff --git a/src/PontCoopScheduler.c b/src/PontCoopScheduler.c index db0efce..ec20dd3 100644 --- a/src/PontCoopScheduler.c +++ b/src/PontCoopScheduler.c @@ -36,6 +36,15 @@ void schAdd(void (*exec)(void *), void *handle, uint32_t delay, uint32_t period) } } +void schDel(void (*exec)(void *), void *handle) { + for (uint8_t i = 0; i < MAX_NUM_OF_TASKS; i++) { + if ((tasks[i].exec == exec) && (tasks[i].handle == handle)) { + tasks[i].exec = NULL; + break; + } + } +} + void schExec() { for (uint8_t i = 0; i < MAX_NUM_OF_TASKS; i++) { if (tasks[i].exec != NULL && tasks[i].run > 0) { @@ -48,6 +57,8 @@ void schExec() { } } + + void schUpdate() { for (uint8_t i = 0; i < MAX_NUM_OF_TASKS; i++) { if (tasks[i].exec != NULL) { diff --git a/src/PontCoopScheduler.h b/src/PontCoopScheduler.h index 211db09..675bed5 100644 --- a/src/PontCoopScheduler.h +++ b/src/PontCoopScheduler.h @@ -13,7 +13,7 @@ -#define MAX_NUM_OF_TASKS 5 +#define MAX_NUM_OF_TASKS 6 typedef struct { @@ -27,6 +27,7 @@ typedef struct { void schInit(); void schAdd(void (*exec)(void *), void *handle, uint32_t delay, uint32_t period); +void schDel(void (*exec)(void *), void *handle); void schExec(); void schUpdate();