00001 /*This file is prepared for Doxygen automatic documentation generation.*/ 00017 00018 /* Copyright (c) 2009 Atmel Corporation. All rights reserved. 00019 * 00020 * Redistribution and use in source and binary forms, with or without 00021 * modification, are permitted provided that the following conditions are met: 00022 * 00023 * 1. Redistributions of source code must retain the above copyright notice, 00024 * this list of conditions and the following disclaimer. 00025 * 00026 * 2. Redistributions in binary form must reproduce the above copyright notice, 00027 * this list of conditions and the following disclaimer in the documentation 00028 * and/or other materials provided with the distribution. 00029 * 00030 * 3. The name of Atmel may not be used to endorse or promote products derived 00031 * from this software without specific prior written permission. 00032 * 00033 * 4. This software may only be redistributed and used in connection with an Atmel 00034 * AVR product. 00035 * 00036 * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED 00037 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 00038 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE EXPRESSLY AND 00039 * SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, 00040 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 00041 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 00042 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 00043 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00044 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 00045 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00046 */ 00047 00049 #define _SCHEDULER_C_ 00050 #include "config.h" // system definition 00051 #include "conf/conf_scheduler.h" // Configuration for the scheduler 00052 #include "scheduler.h" // scheduler definition 00053 00054 00057 #if SCHEDULER_TYPE != SCHEDULER_FREE 00059 bit scheduler_tick_flag; 00060 #endif 00061 00062 #ifdef TOKEN_MODE 00068 Uchar token; 00069 #endif 00070 00080 void scheduler_init (void) 00081 { 00082 #ifdef Scheduler_time_init 00083 Scheduler_time_init(); 00084 #endif 00085 #ifdef TOKEN_MODE 00086 token = TOKEN_FREE; 00087 #endif 00088 #ifdef Scheduler_task_1_init 00089 Scheduler_task_1_init(); 00090 Scheduler_call_next_init(); 00091 #endif 00092 #ifdef Scheduler_task_2_init 00093 Scheduler_task_2_init(); 00094 Scheduler_call_next_init(); 00095 #endif 00096 #ifdef Scheduler_task_3_init 00097 Scheduler_task_3_init(); 00098 Scheduler_call_next_init(); 00099 #endif 00100 #ifdef Scheduler_task_4_init 00101 Scheduler_task_4_init(); 00102 Scheduler_call_next_init(); 00103 #endif 00104 #ifdef Scheduler_task_5_init 00105 Scheduler_task_5_init(); 00106 Scheduler_call_next_init(); 00107 #endif 00108 #ifdef Scheduler_task_6_init 00109 Scheduler_task_6_init(); 00110 Scheduler_call_next_init(); 00111 #endif 00112 #ifdef Scheduler_task_7_init 00113 Scheduler_task_7_init(); 00114 Scheduler_call_next_init(); 00115 #endif 00116 #ifdef Scheduler_task_8_init 00117 Scheduler_task_8_init(); 00118 Scheduler_call_next_init(); 00119 #endif 00120 #ifdef Scheduler_task_9_init 00121 Scheduler_task_9_init(); 00122 Scheduler_call_next_init(); 00123 #endif 00124 #ifdef Scheduler_task_10_init 00125 Scheduler_task_10_init(); 00126 Scheduler_call_next_init(); 00127 #endif 00128 #ifdef Scheduler_task_11_init 00129 Scheduler_task_11_init(); 00130 Scheduler_call_next_init(); 00131 #endif 00132 Scheduler_reset_tick_flag(); 00133 } 00134 00141 void scheduler_tasks (void) 00142 { 00143 // To avoid uncalled segment warning if the empty function is not used 00144 scheduler_empty_fct(); 00145 00146 for(;;) 00147 { 00148 Scheduler_new_schedule(); 00149 #ifdef Scheduler_task_1 00150 Scheduler_task_1(); 00151 Scheduler_call_next_task(); 00152 #endif 00153 #ifdef Scheduler_task_2 00154 Scheduler_task_2(); 00155 Scheduler_call_next_task(); 00156 #endif 00157 #ifdef Scheduler_task_3 00158 Scheduler_task_3(); 00159 Scheduler_call_next_task(); 00160 #endif 00161 #ifdef Scheduler_task_4 00162 Scheduler_task_4(); 00163 Scheduler_call_next_task(); 00164 #endif 00165 #ifdef Scheduler_task_5 00166 Scheduler_task_5(); 00167 Scheduler_call_next_task(); 00168 #endif 00169 #ifdef Scheduler_task_6 00170 Scheduler_task_6(); 00171 Scheduler_call_next_task(); 00172 #endif 00173 #ifdef Scheduler_task_7 00174 Scheduler_task_7(); 00175 Scheduler_call_next_task(); 00176 #endif 00177 #ifdef Scheduler_task_8 00178 Scheduler_task_8(); 00179 Scheduler_call_next_task(); 00180 #endif 00181 #ifdef Scheduler_task_9 00182 Scheduler_task_9(); 00183 Scheduler_call_next_task(); 00184 #endif 00185 #ifdef Scheduler_task_10 00186 Scheduler_task_10(); 00187 Scheduler_call_next_task(); 00188 #endif 00189 #ifdef Scheduler_task_11 00190 Scheduler_task_11(); 00191 Scheduler_call_next_task(); 00192 #endif 00193 } 00194 } 00195 00202 void scheduler (void) 00203 { 00204 scheduler_init(); 00205 scheduler_tasks(); 00206 } 00207 00208 00216 void scheduler_empty_fct (void) 00217 { 00218 } 00219