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

- File List
- Globals

# scheduler.c

Go to the documentation of this file.

    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 "scheduler.h"                      // scheduler definition
    00052
    00053
    00056 #if SCHEDULER_TYPE != SCHEDULER_FREE
    00057
    00058 bit   scheduler_tick_flag;
    00059 #endif
    00060
    00061 #ifdef TOKEN_MODE
    00062
    00063
    00064
    00065
    00066
    00067 Uchar token;
    00068 #endif
    00069
    00079 void scheduler_init (void)
    00080 {
    00081    #ifdef Scheduler_time_init
    00082       Scheduler_time_init();
    00083    #endif
    00084    #ifdef TOKEN_MODE
    00085       token =  TOKEN_FREE;
    00086    #endif
    00087    #ifdef Scheduler_task_1_init
    00088       Scheduler_task_1_init();
    00089       Scheduler_call_next_init();
    00090    #endif
    00091    #ifdef Scheduler_task_2_init
    00092       Scheduler_task_2_init();
    00093       Scheduler_call_next_init();
    00094    #endif
    00095    #ifdef Scheduler_task_3_init
    00096       Scheduler_task_3_init();
    00097       Scheduler_call_next_init();
    00098    #endif
    00099    #ifdef Scheduler_task_4_init
    00100       Scheduler_task_4_init();
    00101       Scheduler_call_next_init();
    00102    #endif
    00103    #ifdef Scheduler_task_5_init
    00104       Scheduler_task_5_init();
    00105       Scheduler_call_next_init();
    00106    #endif
    00107    #ifdef Scheduler_task_6_init
    00108       Scheduler_task_6_init();
    00109       Scheduler_call_next_init();
    00110    #endif
    00111    #ifdef Scheduler_task_7_init
    00112       Scheduler_task_7_init();
    00113       Scheduler_call_next_init();
    00114    #endif
    00115    #ifdef Scheduler_task_8_init
    00116       Scheduler_task_8_init();
    00117       Scheduler_call_next_init();
    00118    #endif
    00119    #ifdef Scheduler_task_9_init
    00120       Scheduler_task_9_init();
    00121       Scheduler_call_next_init();
    00122    #endif
    00123    #ifdef Scheduler_task_10_init
    00124       Scheduler_task_10_init();
    00125       Scheduler_call_next_init();
    00126    #endif
    00127    #ifdef Scheduler_task_11_init
    00128       Scheduler_task_11_init();
    00129       Scheduler_call_next_init();
    00130    #endif
    00131    Scheduler_reset_tick_flag();
    00132 }
    00133
    00140 void scheduler_tasks (void)
    00141 {
    00142    // To avoid uncalled segment warning if the empty function is not used
    00143    scheduler_empty_fct();
    00144
    00145    for(;;)
    00146    {
    00147       Scheduler_new_schedule();
    00148       #ifdef Scheduler_task_1
    00149          Scheduler_task_1();
    00150          Scheduler_call_next_task();
    00151       #endif
    00152       #ifdef Scheduler_task_2
    00153          Scheduler_task_2();
    00154          Scheduler_call_next_task();
    00155       #endif
    00156       #ifdef Scheduler_task_3
    00157          Scheduler_task_3();
    00158          Scheduler_call_next_task();
    00159       #endif
    00160       #ifdef Scheduler_task_4
    00161          Scheduler_task_4();
    00162          Scheduler_call_next_task();
    00163       #endif
    00164       #ifdef Scheduler_task_5
    00165          Scheduler_task_5();
    00166          Scheduler_call_next_task();
    00167       #endif
    00168       #ifdef Scheduler_task_6
    00169          Scheduler_task_6();
    00170          Scheduler_call_next_task();
    00171       #endif
    00172       #ifdef Scheduler_task_7
    00173          Scheduler_task_7();
    00174          Scheduler_call_next_task();
    00175       #endif
    00176       #ifdef Scheduler_task_8
    00177          Scheduler_task_8();
    00178          Scheduler_call_next_task();
    00179       #endif
    00180       #ifdef Scheduler_task_9
    00181          Scheduler_task_9();
    00182          Scheduler_call_next_task();
    00183       #endif
    00184       #ifdef Scheduler_task_10
    00185          Scheduler_task_10();
    00186          Scheduler_call_next_task();
    00187       #endif
    00188       #ifdef Scheduler_task_11
    00189          Scheduler_task_11();
    00190          Scheduler_call_next_task();
    00191       #endif
    00192    }
    00193 }
    00194
    00201 void scheduler (void)
    00202 {
    00203    scheduler_init();
    00204    scheduler_tasks();
    00205 }
    00206
    00207
    00215 void scheduler_empty_fct (void)
    00216 {
    00217 }
    00218