From 2a85a9a40009a91758a7cc2468452968603700c3 Mon Sep 17 00:00:00 2001 From: Wolfgang Hottgenroth Date: Sun, 18 Sep 2016 14:11:13 +0200 Subject: [PATCH] PontCoopScheduler migrated to HottisLib --- src/PontCoopScheduler.c | 75 ----------------------------------------- src/PontCoopScheduler.h | 35 ------------------- 2 files changed, 110 deletions(-) delete mode 100644 src/PontCoopScheduler.c delete mode 100644 src/PontCoopScheduler.h diff --git a/src/PontCoopScheduler.c b/src/PontCoopScheduler.c deleted file mode 100644 index af536e2..0000000 --- a/src/PontCoopScheduler.c +++ /dev/null @@ -1,75 +0,0 @@ -/* - * PontCoopScheduler.c - * - * Created on: 29.08.2016 - * Author: wn - */ - - -#include -#include - - -#include "PontCoopScheduler.h" - -tTask tasks[MAX_NUM_OF_TASKS]; - - -void schInit() { - for (uint8_t i = 0; i < MAX_NUM_OF_TASKS; i++) { - tasks[i].delay = 0; - tasks[i].period = 0; - tasks[i].run = 0; - tasks[i].exec = NULL; - tasks[i].handle = NULL; - } -} - -void schAdd(void (*exec)(void *), void *handle, uint32_t delay, uint32_t period) { - for (uint8_t i = 0; i < MAX_NUM_OF_TASKS; i++) { - if (tasks[i].exec == NULL) { - tasks[i].delay = delay; - tasks[i].period = period; - tasks[i].run = 0; - tasks[i].exec = exec; - tasks[i].handle = handle; - break; - } - } -} - -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) { - tasks[i].run--; - tasks[i].exec(tasks[i].handle); - if (tasks[i].period == 0) { - tasks[i].exec = NULL; - } - } - } -} - - - -void schUpdate() { - for (uint8_t i = 0; i < MAX_NUM_OF_TASKS; i++) { - if (tasks[i].exec != NULL) { - if (tasks[i].delay == 0) { - tasks[i].delay = tasks[i].period; - tasks[i].run++; - } else { - tasks[i].delay--; - } - } - } -} diff --git a/src/PontCoopScheduler.h b/src/PontCoopScheduler.h deleted file mode 100644 index 6dbef16..0000000 --- a/src/PontCoopScheduler.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * PontCoopScheduler.h - * - * Created on: 29.08.2016 - * Author: wn - */ - -#ifndef PONTCOOPSCHEDULER_H_ -#define PONTCOOPSCHEDULER_H_ - - -#include - - - -#define MAX_NUM_OF_TASKS 8 - - -typedef struct { - uint32_t delay; - uint32_t period; - uint8_t run; - void (*exec)(void *handle); - void *handle; -} tTask; - - -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(); - - -#endif /* PONTCOOPSCHEDULER_H_ */