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

# scheduler.h

Go to the documentation of this file.

    00001 /*This file has been prepared for Doxygen automatic documentation generation.*/
    00018
    00019 /* Copyright (c) 2007, 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  * THIS SOFTWARE IS PROVIDED BY ATMEL ``AS IS'' AND ANY EXPRESS OR IMPLIED
    00035  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
    00036  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE EXPRESSLY AND
    00037  * SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT,
    00038  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
    00039  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
    00040  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
    00041  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
    00042  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
    00043  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    00044  */
    00045
    00046 #ifndef _SCHEDULER_H_
    00047 #define _SCHEDULER_H_
    00048
    00050 #ifdef KEIL
    00051 #include <intrins.h>
    00052 #define Wait_semaphore(a) while(!_testbit_(a))
    00053 #else
    00054 #define Wait_semaphore(a) while(!(a)) (a) = FALSE
    00055 #endif
    00056
    00063 #define TASK_DUMMY   0x00           // This define is mandatory
    00064 #define TASK_0       0x01
    00065 #define TASK_1       0x02
    00066 #define TASK_2       0x04
    00067 #define TASK_3       0x08
    00068 #define TASK_4       0x10
    00069 #define TASK_5       0x20
    00070 #define TASK_6       0x40
    00071 #define TASK_7       0x80
    00072
    00073 // This define is mandatory
    00074 #define ALL_TASK     (TASK_0|TASK_1|TASK_2|TASK_3|TASK_4|TASK_5|TASK_6|TASK_7)
    00076
    00078 #define SCHEDULER_CUSTOM      0
    00079 #define SCHEDULER_TIMED       1
    00080 #define SCHEDULER_TASK        2
    00081 #define SCHEDULER_FREE        3
    00082
    00083
    00084
    00085 #ifdef Scheduler_time_init
    00086   extern  void Scheduler_time_init   (void);
    00087 #endif
    00088
    00089 #ifdef Scheduler_task_1_init
    00090   extern  void Scheduler_task_1_init (void);
    00091 #else
    00092   // if you do not want init at all, do:
    00093   // #define Scheduler_task_1_init scheduler_empty_fct
    00094   #error Scheduler_task_1_init must be defined in config.h file
    00095 #endif
    00096 #ifdef Scheduler_task_2_init
    00097   extern  void Scheduler_task_2_init (void);
    00098 #endif
    00099 #ifdef Scheduler_task_3_init
    00100   extern  void Scheduler_task_3_init (void);
    00101 #endif
    00102 #ifdef Scheduler_task_4_init
    00103   extern  void Scheduler_task_4_init (void);
    00104 #endif
    00105 #ifdef Scheduler_task_5_init
    00106   extern  void Scheduler_task_5_init (void);
    00107 #endif
    00108 #ifdef Scheduler_task_6_init
    00109   extern  void Scheduler_task_6_init (void);
    00110 #endif
    00111 #ifdef Scheduler_task_7_init
    00112   extern  void Scheduler_task_7_init (void);
    00113 #endif
    00114 #ifdef Scheduler_task_8_init
    00115   extern  void Scheduler_task_8_init (void);
    00116 #endif
    00117 #ifdef Scheduler_task_9_init
    00118   extern  void Scheduler_task_9_init (void);
    00119 #endif
    00120 #ifdef Scheduler_task_10_init
    00121   extern  void Scheduler_task_10_init (void);
    00122 #endif
    00123 #ifdef Scheduler_task_11_init
    00124   extern  void Scheduler_task_11_init (void);
    00125 #endif
    00126
    00127
    00128 #ifdef Scheduler_task_1
    00129   extern  void Scheduler_task_1 (void);
    00130 #else
    00131   // if you do not want task at all, do:
    00132   // #define Scheduler_task_1 scheduler_empty_fct
    00133   #error Scheduler_task_1 must be defined in config.h file
    00134 #endif
    00135 #ifdef Scheduler_task_2
    00136   extern  void Scheduler_task_2 (void);
    00137 #endif
    00138 #ifdef Scheduler_task_3
    00139   extern  void Scheduler_task_3 (void);
    00140 #endif
    00141 #ifdef Scheduler_task_4
    00142   extern  void Scheduler_task_4 (void);
    00143 #endif
    00144 #ifdef Scheduler_task_5
    00145   extern  void Scheduler_task_5 (void);
    00146 #endif
    00147 #ifdef Scheduler_task_6
    00148   extern  void Scheduler_task_6 (void);
    00149 #endif
    00150 #ifdef Scheduler_task_7
    00151   extern  void Scheduler_task_7 (void);
    00152 #endif
    00153 #ifdef Scheduler_task_8
    00154   extern  void Scheduler_task_8 (void);
    00155 #endif
    00156 #ifdef Scheduler_task_9
    00157   extern  void Scheduler_task_9 (void);
    00158 #endif
    00159 #ifdef Scheduler_task_10
    00160   extern  void Scheduler_task_10 (void);
    00161 #endif
    00162 #ifdef Scheduler_task_11
    00163   extern  void Scheduler_task_11 (void);
    00164 #endif
    00165
    00167 #if SCHEDULER_TYPE != SCHEDULER_FREE
    00168 extern  bit   scheduler_tick_flag;
    00169 #endif
    00170
    00171 #ifdef TOKEN_MODE
    00172 extern Uchar token;
    00173 #define TOKEN_FREE      0
    00174 #endif
    00175
    00177 void scheduler_init         (void);
    00178 void scheduler_tasks        (void);
    00179 void scheduler              (void);
    00180 void scheduler_empty_fct    (void);
    00181
    00182 #ifndef SCHEDULER_TYPE
    00183   #error You must define SCHEDULER_TYPE in config.h file
    00184 #elif SCHEDULER_TYPE == SCHEDULER_FREE
    00185   #define Scheduler_set_tick_flag()
    00186   #define Scheduler_reset_tick_flag()
    00187 #elif SCHEDULER_TYPE == SCHEDULER_TIMED
    00188   #define Scheduler_new_schedule()      Wait_semaphore(scheduler_tick_flag)
    00189   #define Scheduler_set_tick_flag()     (scheduler_tick_flag = TRUE)
    00190   #define Scheduler_reset_tick_flag()   (scheduler_tick_flag = FALSE)
    00191 #elif SCHEDULER_TYPE == SCHEDULER_TASK
    00192   #define Scheduler_call_next_task()    Wait_semaphore(scheduler_tick_flag)
    00193   #define Scheduler_set_tick_flag()     (scheduler_tick_flag = TRUE)
    00194   #define Scheduler_reset_tick_flag()   (scheduler_tick_flag = FALSE)
    00195 #elif SCHEDULER_TYPE == SCHEDULER_CUSTOM
    00196   #error Make sure you have setup macro/fct Scheduler_new_schedule & Scheduler_call_next_task
    00197   #define Scheduler_set_tick_flag()     (scheduler_tick_flag = TRUE)
    00198   #define Scheduler_reset_tick_flag()   (scheduler_tick_flag = FALSE)
    00199 #endif
    00200
    00201 #ifndef Scheduler_call_next_task
    00202   #define Scheduler_call_next_task()
    00203 #endif
    00204 #ifndef Scheduler_new_schedule
    00205   #define Scheduler_new_schedule()
    00206 #endif
    00207 #ifndef Scheduler_call_next_init
    00208   #define Scheduler_call_next_init()
    00209 #endif
    00210
    00211 #endif
    00212