- Main Page
- Modules
- Data Structures
- Files
- Related Pages

- File List
- Globals

# scheduler.h

Go to the documentation of this file.

    00001
    00002
    00003
    00004
    00005
    00006
    00007
    00008
    00009
    00010
    00011
    00012
    00013
    00014
    00015
    00016
    00017
    00018
    00019
    00020
    00021 #ifndef _SCHEDULER_H_
    00022 #define _SCHEDULER_H_
    00023
    00025 #ifdef KEIL
    00026 #include <intrins.h>
    00027 #define Wait_semaphore(a) while(!_testbit_(a))
    00028 #else
    00029 #define Wait_semaphore(a) while(!(a)) (a) = FALSE
    00030 #endif
    00031
    00038 #define TASK_DUMMY   0x00           // This define is mandatory
    00039 #define TASK_0       0x01
    00040 #define TASK_1       0x02
    00041 #define TASK_2       0x04
    00042 #define TASK_3       0x08
    00043 #define TASK_4       0x10
    00044 #define TASK_5       0x20
    00045 #define TASK_6       0x40
    00046 #define TASK_7       0x80
    00047
    00048 // This define is mandatory
    00049 #define ALL_TASK     (TASK_0|TASK_1|TASK_2|TASK_3|TASK_4|TASK_5|TASK_6|TASK_7)
    00051
    00053 #define SCHEDULER_CUSTOM      0
    00054 #define SCHEDULER_TIMED       1
    00055 #define SCHEDULER_TASK        2
    00056 #define SCHEDULER_FREE        3
    00057
    00058
    00059
    00060 #ifdef Scheduler_time_init
    00061   extern  void Scheduler_time_init   (void);
    00062 #endif
    00063
    00064 #ifdef Scheduler_task_1_init
    00065   extern  void Scheduler_task_1_init (void);
    00066 #else
    00067   // if you do not want init at all, do:
    00068   // #define Scheduler_task_1_init scheduler_empty_fct
    00069   #error Scheduler_task_1_init must be defined in config.h file
    00070 #endif
    00071 #ifdef Scheduler_task_2_init
    00072   extern  void Scheduler_task_2_init (void);
    00073 #endif
    00074 #ifdef Scheduler_task_3_init
    00075   extern  void Scheduler_task_3_init (void);
    00076 #endif
    00077 #ifdef Scheduler_task_4_init
    00078   extern  void Scheduler_task_4_init (void);
    00079 #endif
    00080 #ifdef Scheduler_task_5_init
    00081   extern  void Scheduler_task_5_init (void);
    00082 #endif
    00083 #ifdef Scheduler_task_6_init
    00084   extern  void Scheduler_task_6_init (void);
    00085 #endif
    00086 #ifdef Scheduler_task_7_init
    00087   extern  void Scheduler_task_7_init (void);
    00088 #endif
    00089 #ifdef Scheduler_task_8_init
    00090   extern  void Scheduler_task_8_init (void);
    00091 #endif
    00092 #ifdef Scheduler_task_9_init
    00093   extern  void Scheduler_task_9_init (void);
    00094 #endif
    00095 #ifdef Scheduler_task_10_init
    00096   extern  void Scheduler_task_10_init (void);
    00097 #endif
    00098 #ifdef Scheduler_task_11_init
    00099   extern  void Scheduler_task_11_init (void);
    00100 #endif
    00101
    00102
    00103 #ifdef Scheduler_task_1
    00104   extern  void Scheduler_task_1 (void);
    00105 #else
    00106   // if you do not want task at all, do:
    00107   // #define Scheduler_task_1 scheduler_empty_fct
    00108   #error Scheduler_task_1 must be defined in config.h file
    00109 #endif
    00110 #ifdef Scheduler_task_2
    00111   extern  void Scheduler_task_2 (void);
    00112 #endif
    00113 #ifdef Scheduler_task_3
    00114   extern  void Scheduler_task_3 (void);
    00115 #endif
    00116 #ifdef Scheduler_task_4
    00117   extern  void Scheduler_task_4 (void);
    00118 #endif
    00119 #ifdef Scheduler_task_5
    00120   extern  void Scheduler_task_5 (void);
    00121 #endif
    00122 #ifdef Scheduler_task_6
    00123   extern  void Scheduler_task_6 (void);
    00124 #endif
    00125 #ifdef Scheduler_task_7
    00126   extern  void Scheduler_task_7 (void);
    00127 #endif
    00128 #ifdef Scheduler_task_8
    00129   extern  void Scheduler_task_8 (void);
    00130 #endif
    00131 #ifdef Scheduler_task_9
    00132   extern  void Scheduler_task_9 (void);
    00133 #endif
    00134 #ifdef Scheduler_task_10
    00135   extern  void Scheduler_task_10 (void);
    00136 #endif
    00137 #ifdef Scheduler_task_11
    00138   extern  void Scheduler_task_11 (void);
    00139 #endif
    00140
    00142 #if SCHEDULER_TYPE != SCHEDULER_FREE
    00143 extern  bit   scheduler_tick_flag;
    00144 #endif
    00145
    00146 #ifdef TOKEN_MODE
    00147 extern Uchar token;
    00148 #define TOKEN_FREE      0
    00149 #endif
    00150
    00152 void scheduler_init         (void);
    00153 void scheduler_tasks        (void);
    00154 void scheduler              (void);
    00155 void scheduler_empty_fct    (void);
    00156
    00157 #ifndef SCHEDULER_TYPE
    00158   #error You must define SCHEDULER_TYPE in config.h file
    00159 #elif SCHEDULER_TYPE == SCHEDULER_FREE
    00160   #define Scheduler_set_tick_flag()
    00161   #define Scheduler_reset_tick_flag()
    00162 #elif SCHEDULER_TYPE == SCHEDULER_TIMED
    00163   #define Scheduler_new_schedule()      Wait_semaphore(scheduler_tick_flag)
    00164   #define Scheduler_set_tick_flag()     (scheduler_tick_flag = TRUE)
    00165   #define Scheduler_reset_tick_flag()   (scheduler_tick_flag = FALSE)
    00166 #elif SCHEDULER_TYPE == SCHEDULER_TASK
    00167   #define Scheduler_call_next_task()    Wait_semaphore(scheduler_tick_flag)
    00168   #define Scheduler_set_tick_flag()     (scheduler_tick_flag = TRUE)
    00169   #define Scheduler_reset_tick_flag()   (scheduler_tick_flag = FALSE)
    00170 #elif SCHEDULER_TYPE == SCHEDULER_CUSTOM
    00171   #error Make sure you have setup macro/fct Scheduler_new_schedule & Scheduler_call_next_task
    00172   #define Scheduler_set_tick_flag()     (scheduler_tick_flag = TRUE)
    00173   #define Scheduler_reset_tick_flag()   (scheduler_tick_flag = FALSE)
    00174 #endif
    00175
    00176 #ifndef Scheduler_call_next_task
    00177   #define Scheduler_call_next_task()
    00178 #endif
    00179 #ifndef Scheduler_new_schedule
    00180   #define Scheduler_new_schedule()
    00181 #endif
    00182 #ifndef Scheduler_call_next_init
    00183   #define Scheduler_call_next_init()
    00184 #endif
    00185
    00186 #endif
    00187