demos_source/code_TestHooks.c

Go to the documentation of this file.
00001 /*
00002  * Femto OS v 0.91 - Copyright (C) 2008-2009 Ruud Vlaming
00003  *
00004  * This file is part of the Femto OS distribution.
00005  *
00006  * This program is free software: you can redistribute it and/or modify
00007  * it under the terms of the GNU General Public License as published by
00008  * 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 of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  * GNU General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU General Public License
00016  * 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 this
00019  * 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 dual
00021  * 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 of
00043  * the tasks. Use it to initialize the hardware. */
00044 void appBoot(void)
00045 { devLedDRR    |= 0xFF;
00046   devSwitchDRR &= 0xFE;
00047   devLedPORT   |= 0xFF; }
00048 
00049 /* Global variables */
00050 Tuint08 uiCounter;
00051 Tuint08 uiSelector;
00052 
00053 /* Tick hooks for every tick ( keep you code short!), every 256 ticks and
00054  * every full round of the tick counter (65536 ticks). For example, you can
00055  * use these hooks to extend the size of the tickcounter and keep track of
00056  * time. */
00057 
00058 void appTick00(void)
00059 { if (uiSelector == 0)
00060   { devLedPORT = ~(uiCounter++); } }
00061 
00062 void appTick08(void)
00063 { if (uiSelector == 1)
00064   { devLedPORT = ~(uiCounter++); } }
00065 
00066 void appTick16(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 
00075 void appLoop_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 #endif
00086 

Generated on Fri Oct 16 00:05:21 2009 for FemtoOS by  doxygen 1.5.2