scheduler.h

Go to the documentation of this file.
00001 /*This file is prepared for Doxygen automatic documentation generation.*/
00018 
00019 /* Copyright (c) 2009 Atmel Corporation. All rights reserved.
00020  *
00021  * Redistribution and use in source and binary forms, with or without
00022  * modification, are permitted provided that the following conditions are met:
00023  *
00024  * 1. Redistributions of source code must retain the above copyright notice,
00025  * this list of conditions and the following disclaimer.
00026  *
00027  * 2. Redistributions in binary form must reproduce the above copyright notice,
00028  * this list of conditions and the following disclaimer in the documentation
00029  * and/or other materials provided with the distribution.
00030  *
00031  * 3. The name of Atmel may not be used to endorse or promote products derived
00032  * from this software without specific prior written permission.
00033  *
00034  * 4. This software may only be redistributed and used in connection with an Atmel
00035  * AVR product.
00036  *
00037  * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
00038  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
00039  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE EXPRESSLY AND
00040  * SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT,
00041  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
00042  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00043  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
00044  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00045  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
00046  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00047  */
00048 
00049 #ifndef _SCHEDULER_H_
00050 #define _SCHEDULER_H_
00051 
00053 #ifdef KEIL
00054 #include <intrins.h>
00055 #define Wait_semaphore(a) while(!_testbit_(a))
00056 #else
00057 #define Wait_semaphore(a) while(!(a)) (a) = FALSE
00058 #endif
00059 
00066 #define TASK_DUMMY   0x00           // This define is mandatory
00067 #define TASK_0       0x01
00068 #define TASK_1       0x02
00069 #define TASK_2       0x04
00070 #define TASK_3       0x08
00071 #define TASK_4       0x10
00072 #define TASK_5       0x20
00073 #define TASK_6       0x40
00074 #define TASK_7       0x80
00075 
00076 // This define is mandatory
00077 #define ALL_TASK     (TASK_0|TASK_1|TASK_2|TASK_3|TASK_4|TASK_5|TASK_6|TASK_7)
00079 
00081 #define SCHEDULER_CUSTOM      0
00082 #define SCHEDULER_TIMED       1
00083 #define SCHEDULER_TASK        2
00084 #define SCHEDULER_FREE        3
00085 
00086 
00087 
00088 #ifdef Scheduler_time_init
00089   extern  void Scheduler_time_init   (void);
00090 #endif
00091 
00092 #ifdef Scheduler_task_1_init
00093   extern  void Scheduler_task_1_init (void);
00094 #else
00095   // if you do not want init at all, do:
00096   // #define Scheduler_task_1_init scheduler_empty_fct
00097   #error Scheduler_task_1_init must be defined in config.h file
00098 #endif
00099 #ifdef Scheduler_task_2_init
00100   extern  void Scheduler_task_2_init (void);
00101 #endif
00102 #ifdef Scheduler_task_3_init
00103   extern  void Scheduler_task_3_init (void);
00104 #endif
00105 #ifdef Scheduler_task_4_init
00106   extern  void Scheduler_task_4_init (void);
00107 #endif
00108 #ifdef Scheduler_task_5_init
00109   extern  void Scheduler_task_5_init (void);
00110 #endif
00111 #ifdef Scheduler_task_6_init
00112   extern  void Scheduler_task_6_init (void);
00113 #endif
00114 #ifdef Scheduler_task_7_init
00115   extern  void Scheduler_task_7_init (void);
00116 #endif
00117 #ifdef Scheduler_task_8_init
00118   extern  void Scheduler_task_8_init (void);
00119 #endif
00120 #ifdef Scheduler_task_9_init
00121   extern  void Scheduler_task_9_init (void);
00122 #endif
00123 #ifdef Scheduler_task_10_init
00124   extern  void Scheduler_task_10_init (void);
00125 #endif
00126 #ifdef Scheduler_task_11_init
00127   extern  void Scheduler_task_11_init (void);
00128 #endif
00129 
00130 
00131 #ifdef Scheduler_task_1
00132   extern  void Scheduler_task_1 (void);
00133 #else
00134   // if you do not want task at all, do:
00135   // #define Scheduler_task_1 scheduler_empty_fct
00136   #error Scheduler_task_1 must be defined in config.h file
00137 #endif
00138 #ifdef Scheduler_task_2
00139   extern  void Scheduler_task_2 (void);
00140 #endif
00141 #ifdef Scheduler_task_3
00142   extern  void Scheduler_task_3 (void);
00143 #endif
00144 #ifdef Scheduler_task_4
00145   extern  void Scheduler_task_4 (void);
00146 #endif
00147 #ifdef Scheduler_task_5
00148   extern  void Scheduler_task_5 (void);
00149 #endif
00150 #ifdef Scheduler_task_6
00151   extern  void Scheduler_task_6 (void);
00152 #endif
00153 #ifdef Scheduler_task_7
00154   extern  void Scheduler_task_7 (void);
00155 #endif
00156 #ifdef Scheduler_task_8
00157   extern  void Scheduler_task_8 (void);
00158 #endif
00159 #ifdef Scheduler_task_9
00160   extern  void Scheduler_task_9 (void);
00161 #endif
00162 #ifdef Scheduler_task_10
00163   extern  void Scheduler_task_10 (void);
00164 #endif
00165 #ifdef Scheduler_task_11
00166   extern  void Scheduler_task_11 (void);
00167 #endif
00168 
00170 #if SCHEDULER_TYPE != SCHEDULER_FREE
00171 extern  bit   scheduler_tick_flag;
00172 #endif
00173 
00174 #ifdef TOKEN_MODE
00175 extern Uchar token;
00176 #define TOKEN_FREE      0
00177 #endif
00178 
00180 void scheduler_init         (void);
00181 void scheduler_tasks        (void);
00182 void scheduler              (void);
00183 void scheduler_empty_fct    (void);
00184 
00185 #ifndef SCHEDULER_TYPE
00186   #error You must define SCHEDULER_TYPE in config.h file
00187 #elif SCHEDULER_TYPE == SCHEDULER_FREE
00188   #define Scheduler_set_tick_flag()
00189   #define Scheduler_reset_tick_flag()
00190 #elif SCHEDULER_TYPE == SCHEDULER_TIMED
00191   #define Scheduler_new_schedule()      Wait_semaphore(scheduler_tick_flag)
00192   #define Scheduler_set_tick_flag()     (scheduler_tick_flag = TRUE)
00193   #define Scheduler_reset_tick_flag()   (scheduler_tick_flag = FALSE)
00194 #elif SCHEDULER_TYPE == SCHEDULER_TASK
00195   #define Scheduler_call_next_task()    Wait_semaphore(scheduler_tick_flag)
00196   #define Scheduler_set_tick_flag()     (scheduler_tick_flag = TRUE)
00197   #define Scheduler_reset_tick_flag()   (scheduler_tick_flag = FALSE)
00198 #elif SCHEDULER_TYPE == SCHEDULER_CUSTOM
00199   #error Make sure you have setup macro/fct Scheduler_new_schedule & Scheduler_call_next_task
00200   #define Scheduler_set_tick_flag()     (scheduler_tick_flag = TRUE)
00201   #define Scheduler_reset_tick_flag()   (scheduler_tick_flag = FALSE)
00202 #endif
00203 
00204 #ifndef Scheduler_call_next_task
00205   #define Scheduler_call_next_task()
00206 #endif
00207 #ifndef Scheduler_new_schedule
00208   #define Scheduler_new_schedule()
00209 #endif
00210 #ifndef Scheduler_call_next_init
00211   #define Scheduler_call_next_init()
00212 #endif
00213 
00214 #endif 
00215 

Generated on Fri Sep 11 14:46:05 2009 for ATMEL by  doxygen 1.5.3