00001 /* 00002 * Copyright Droids Corporation, Microb Technology, Eirbot (2005) 00003 * 00004 * This program is free software; you can redistribute it and/or modify 00005 * it under the terms of the GNU General Public License as published by 00006 * the Free Software Foundation; either version 2 of the License, or 00007 * (at your option) any later version. 00008 * 00009 * This program is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU General Public License 00015 * along with this program; if not, write to the Free Software 00016 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00017 * 00018 * Revision : $Id: scheduler.c,v 1.13 2009-03-15 21:51:16 zer0 Exp $ 00019 * 00020 */ 00021 00022 #include <string.h> 00023 00024 #include <aversive/parts.h> 00025 #include <aversive.h> 00026 00027 #include <scheduler.h> 00028 #include <scheduler_private.h> 00029 #include <scheduler_config.h> 00030 00031 00032 /* this file is compiled for AVR version only */ 00033 00035 struct event_t g_tab_event[SCHEDULER_NB_MAX_EVENT]; 00036 00037 00038 void scheduler_init(void) 00039 { 00040 memset(g_tab_event, 0, sizeof(g_tab_event)); 00041 00042 #ifdef CONFIG_MODULE_SCHEDULER_USE_TIMERS 00043 SCHEDULER_TIMER_REGISTER(); 00044 #endif 00045 00046 #ifdef CONFIG_MODULE_SCHEDULER_TIMER0 00047 /* activation of corresponding interrupt */ 00048 TOIE0_REG |= (1<<TOIE0); /* TIMSK */ 00049 00050 TCNT0 = 0; 00051 CS00_REG = SCHEDULER_CK; /* TCCR0 */ 00052 #endif 00053 } 00054 00055 00056 #ifdef CONFIG_MODULE_SCHEDULER_TIMER0 00057 SIGNAL(SIG_OVERFLOW0) 00058 { 00059 scheduler_interrupt(); 00060 } 00061 #endif /* CONFIG_MODULE_SCHEDULER_USE_TIMERS */