1 /* -------------------------------- Arctic Core ------------------------------
\r
2 * Arctic Core - the open source AUTOSAR platform http://arccore.com
\r
4 * Copyright (C) 2009 ArcCore AB <contact@arccore.com>
\r
6 * This source code is free software; you can redistribute it and/or modify it
\r
7 * under the terms of the GNU General Public License version 2 as published by the
\r
8 * Free Software Foundation; See <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>.
\r
10 * This program is distributed in the hope that it will be useful, but
\r
11 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
\r
12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
\r
14 * -------------------------------- Arctic Core ------------------------------*/
\r
20 struct timeoutlist_t{
\r
25 static struct timeoutlist_t timeoutlist[OS_TASK_CNT];
\r
27 static uint32_t ticks = 0;
\r
33 for(i=0;i<OS_TASK_CNT;i++)
\r
35 timeoutlist[i].active = FALSE;
\r
39 void Sleep(uint32_t nofTicks, TaskType TaskID, EventMaskType Mask )
\r
46 if(TaskID < OS_TASK_CNT){
\r
47 timeoutlist[TaskID].timeout = ticks + nofTicks;
\r
48 timeoutlist[TaskID].active = TRUE;
\r
49 timeoutlist[TaskID].mask = Mask;
\r
52 ErrorHook(E_OS_LIMIT);
\r
58 void SleepTask(void)
\r
62 // Alarms every tick
\r
63 WaitEvent(EVENT_MASK_SLEEP_ALARM_TASK);
\r
64 ClearEvent(EVENT_MASK_SLEEP_ALARM_TASK);
\r
68 for(i=0;i<OS_TASK_CNT;i++)
\r
70 if((timeoutlist[i].active == TRUE) && (timeoutlist[i].timeout == ticks))
\r
72 timeoutlist[i].active = FALSE;
\r
73 SetEvent(i,timeoutlist[i].mask);
\r