#ifndef __PBORT_H //if __PBORT_H is not defined previously then include all this until the #endif #define __PBORT_H #include /* maximum number of spawned tasks allowed - determines size of arrays */ /* Do not change without recompiling pbort.c!!! (Can this be moved to sched.c?) */ #define NUM_OF_TASKS 10 /* Command and return values used by the scheduler */ #define I_OK 1 #define I_ERROR -1 #define SBS_ON 100 #define SBS_OFF 101 typedef void (*voidfnc_ptr)(void); typedef int (*intfnc_ptr)(void); typedef char (*charfnc_ptr)(uint8_t); typedef void *pointer; /* Define the ProcessT type that is used by the scheduler */ typedef struct {charfnc_ptr on_fptr; charfnc_ptr cycle_fptr; charfnc_ptr off_fptr; char pid; char fRealTime; uint16_t nPeriod; uint32_t nextReady; uint16_t missed; pointer local; } processT; /* Function prototypes for user functions defined in sched.c */ /* --- sbsSpawn() is used to instantiate instances of a module. --- Each spawning of a module is a unique instance of that module. --- init_fp is the name of the module's xxx_init() routine. --- freq is the frequency at which the module is executed. --- fRealTime is a flag. --- a procID is returned as a handle to the module. --- */ char sbsSpawn(charfnc_ptr init_fp, uint16_t freq, char fRealTime); /* --- sbsControl() is used to turn spawned modules on and off. --- procID identifies the modules --- cmd is either "SBS_ON" or "SBS_OFF" --- return value is either I_OK or I_ERROR --- */ int sbsControl(char procID, char cmd); /* --- sched_init() initializes the scheduler. --- it is called in main() before any modules are spawned. --- freq is the heartbeat frequency in Hz and must be greater than or equal to --- the frequency of the fastest module spawned. --- */ uint16_t sched_init(uint16_t freq); /* --- sched() is called in a while() loop */ void sched(void); /* These are internal variables used by the scheduler and should not be referenced by the user. */ extern uint32_t timerTicksG; extern uint8_t onTasksG; extern uint8_t readyHeadG; extern uint8_t readyTailG; extern uint8_t onQueueG[NUM_OF_TASKS]; /* list of task indices (in the spawnQueue) */ extern processT spawnQueueG[NUM_OF_TASKS]; extern uint8_t readyQueueG[NUM_OF_TASKS]; /* list of indices to the spawnQueue (not IDs) */ extern uint8_t spawnTasksG; extern uint16_t heartBeatFreqG; #endif