demos_source/code_TestHooks.c

00001 /*00002 * Femto OS v 0.91 - Copyright (C) 2008-2009 Ruud Vlaming00003 *00004 * This file is part of the Femto OS distribution.00005 *00006 * This program is free software: you can redistribute it and/or modify00007 * it under the terms of the GNU General Public License as published by00008 * the Free Software Foundation, version 3 of the License.00009 *00010 * This program is distributed in the hope that it will be useful,00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the00013 * GNU General Public License for more details.00014 *00015 * You should have received a copy of the GNU General Public License00016 * along with this program. If not, see <http://www.gnu.org/licenses/>.00017 *00018 * Please note that, due to the GPLv3 license, for application of this00019 * work and/or combined work in embedded systems special obligations apply.00020 * If these are not to you liking, please know the Femto OS is dual00021 * licensed. A commercial license and support are available.00022 * See http://www.femtoos.org/ for details.00023 */00024
00025
00038 /* This this the only include needed in your code .*/00039 #include "femtoos_code.h"00040
00041
00042 /* This is called once at system boot, and before the creating of any of00043 * the tasks. Use it to initialize the hardware. */00044voidappBoot(void)
00045 { devLedDRR |= 0xFF;
00046 devSwitchDRR &= 0xFE;
00047 devLedPORT |= 0xFF; }
00048
00049 /* Global variables */00050Tuint08uiCounter;
00051Tuint08uiSelector;
00052
00053 /* Tick hooks for every tick ( keep you code short!), every 256 ticks and00054 * every full round of the tick counter (65536 ticks). For example, you can00055 * use these hooks to extend the size of the tickcounter and keep track of00056 * time. */00057
00058voidappTick00(void)
00059 { if (uiSelector == 0)
00060 { devLedPORT = ~(uiCounter++); } }
00061
00062voidappTick08(void)
00063 { if (uiSelector == 1)
00064 { devLedPORT = ~(uiCounter++); } }
00065
00066voidappTick16(void)
00067 { if (uiSelector == 2)
00068 { devLedPORT = ~(uiCounter++); } }
00069
00070
00071 /* Task that reads a button and let you choose which hook is active. */00072
00073 #if (preTaskDefined(Select))00074 00075voidappLoop_Select(void)
00076 { Tuint08 button = devSwitchPIN & 01;
00077 Tuint08 lastbutton = button;
00078 genTraceByteInfo(button);
00079 while (true)
00080 { button = devSwitchPIN & 01;
00081 if (button != lastbutton)
00082 { if ((++uiSelector) == 3) { uiSelector = 0; } }
00083 taskDelayFromNow(100); } }
00084
00085 #endif00086