demos_source/code_TestShell.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 
00048 /* This this the only include needed in your code .*/
00049 #include "femtoos_code.h"
00050 
00051 #define defDemoRequestLedState           0x20
00052 #define defDemoRequestLedCycle           0x21
00053 #define defDemoRequestLedSave            0x22
00054 #define defDemoRequestLedLoad            0x23
00055 #define defDemoRequestLedStateOff        0x00
00056 #define defDemoRequestLedStateOn         0x01
00057 #define defDemoRequestLedStateFlash      0x02
00058 #define defDemoRequestLedStateFreeze     0x04
00059 #define defDemoRequestLedStateFollow     0x05
00060 #define defDemoRequestLedStateUndef      0xFF
00061 #define defDemoResponseLedOK             0xA0
00062 #define defDemoResponseLedError          0xA1
00063 
00064 static void initBus(void);
00065 static void startCommunication(void);
00066 
00067 typedef Tuint08 bit;
00068 
00069 /* You get a warning here that crcValue is not used. This is intentional. I have
00070  * not yet decided if i want to implement that functionality and how. Until that
00071  * moment has come, i leave the warning as a reminder.
00072  * Probably i will rewrite the whole implementation of the T4 protocol
00073  */
00074 static Tbyte crcValue;
00075 static Tbool virgin;
00076 static Tbool prevMaster;
00077 static Tbool crcCheckResult;
00078 static Tuint08 uptime[3];
00079 
00080 #define Maxtry 9
00081 
00082 #define SETBIT(Reg,Pos,val) if (val) { (Reg|=(1<<Pos)); } else { (Reg&=~(1<<Pos)); }
00083 #define GETBIT(Reg,Pos)     ((Reg>>Pos) & 0x01)
00084 
00085 #define SetDebugLed(nr) SETBIT(PORTB,(nr+4),false);
00086 #define ClrDebugLed(nr) SETBIT(PORTB,(nr+4),true);
00087 
00088 /*  These methods must be ported */
00089 
00090 static bit getSCLin()         __attribute__ ( ( always_inline ) );
00091 static bit getSDA()           __attribute__ ( ( always_inline ) );
00092 static bit getACK()           __attribute__ ( ( always_inline ) );
00093 static void setSCLout(bit b)  __attribute__ ( ( always_inline ) );
00094 static void setSDA(bit b)     __attribute__ ( ( always_inline ) );
00095 static void setACK(bit b)     __attribute__ ( ( always_inline ) );
00096 
00097 
00098 static bit getSCLin()        { return GETBIT(PINB,PB2); }
00099 static bit getSDA()          { return GETBIT(PINB,PB3); }
00100 static bit getACK()          { return GETBIT(PINB,PB3); }
00101 
00102 static void setSCLout(bit b) { SETBIT(PORTB,PB0,b); }
00103 static void setSDA(bit b)    { SETBIT(PORTB,PB1,b); }
00104 static void setACK(bit b)    { SETBIT(PORTB,PB1,b); }
00105 
00106 
00107 static void propDelay() { asm("nop"); asm("nop"); }
00108 
00109 static void calcCRC(Tbyte b)    {}
00110 static void clearCRC()          {}
00111 static Tbyte getCRC()           { return 0; }
00112 static Tbool checkCRC(Tbyte b)  { return true; }
00113 
00114 /*
00115  * SCLout=output   : PB0
00116  * SDAout=output   : PB1
00117  * SCLin=input     : PB2
00118  * SDAin=input     : PB3
00119  */
00120 
00121 static void initPins()
00122 { /* Switch off the pull up resistors on inputs, write 0 to output SCLout */
00123   PORTB &= 0xF0;    /* When GCC 4.3.0 is out change to 0b11110000 */
00124   /* set bit 0,1 to output, bit 2,3 to input, leave first 4 bits alone (PB7-PB4) */
00125   DDRB = (DDRB & 0xF0) | 0x03; }
00126 
00127 /*  These methods are chip independent */
00128 
00129 static void writeByte(Tbyte b)
00130 { Tuint08 bitCnt = 8;
00131   while (bitCnt--)
00132   { setSDA(b & 0x80);
00133     while(getACK());
00134     setSCLout(1);
00135     while(!getACK());
00136     b<<=1;
00137     setSCLout(0);} }
00138 
00139 static Tbyte readByte()
00140 { Tbyte result = 0;
00141   Tuint08 bitCnt = 8;
00142   while (bitCnt--)
00143   { while(getSCLin());
00144     setACK(0);
00145     while(!getSCLin());
00146     result<<=1;
00147     result|=getSDA();
00148     setACK(1); }
00149   return result; }
00150 
00151 static void startRead()
00152 { clearCRC();
00153   setACK(1);
00154   Tbyte payloadLength = readByte()-2;
00155   if (payloadLength>QueuSize_ReadQueuT4) { payloadLength=QueuSize_ReadQueuT4; }
00156   taskQueuWriteRequestOnName(ReadQueuT4,payloadLength);
00157   while (payloadLength--)
00158   { Tbyte byte = readByte();
00159     genQueuWriteOnName(ReadQueuT4,byte);
00160     calcCRC(byte);
00161     }
00162   taskQueuReleaseOnName(ReadQueuT4);
00163   /* This result is not used yet */
00164   crcCheckResult = checkCRC(readByte());
00165   while(getSCLin());
00166   setACK(0);
00167   virgin = false;
00168   prevMaster = true; }
00169 
00170 static void startWrite()
00171 { clearCRC();
00172   setSCLout(0);
00173   taskQueuReadRequestOnName(WriteQueuT4,1);
00174   Tbyte payloadLength = genQueuReadableOnName(WriteQueuT4);
00175   writeByte(payloadLength+2);
00176   while (payloadLength--)
00177   { Tbyte byte = genQueuReadOnName(WriteQueuT4);
00178     writeByte(byte);
00179     calcCRC(byte);
00180     }
00181   taskQueuReleaseOnName(WriteQueuT4);
00182   writeByte(getCRC());
00183   setSDA(0);
00184   while (getACK());
00185   virgin = false;
00186   prevMaster = false; }
00187 
00188 static void initBus(void)
00189 { initPins();
00190   virgin=true;
00191   prevMaster=false; }
00192 
00193 static void startCommunication()
00194 { while (true)
00195   { if (!genQueuEmptyOnName(WriteQueuT4))
00196     { setSCLout(1);
00197       while (true)
00198       { if (getACK())
00199         { startWrite();
00200           break; }
00201         if (!prevMaster && getSCLin())
00202         { setSCLout(0);
00203           propDelay();
00204           Tuint08 cnt = 0;
00205           while (!virgin | (cnt++ < Maxtry))
00206           { if (getSCLin())
00207             { startRead();
00208               break; } }
00209           break; } } }
00210     else
00211     { if (!getSCLin()) break;
00212       if (!genQueuEmptyOnName(ReadQueuT4)) break;
00213       startRead(); } } }
00214 
00215 
00216 static void WriteQueuPipe(Tchar c) { genQueuWriteOnName(WriteQueuT4,c); }
00217 static Tchar ReadQueuPipe()        { return genQueuReadOnName(ReadQueuT4); }
00218 
00219 const Tchar FemtoOSid[] PROGMEM = SystemID;
00220 
00221 static void SendID()
00222 { taskQueuWriteRequestOnName(WriteQueuT4,13);
00223   genQueuWriteOnName(WriteQueuT4,defResponseFemtoOs);
00224   genPassFlashString((Taddress) FemtoOSid,0,' ', WriteQueuPipe);
00225   taskQueuReleaseOnName(WriteQueuT4); }
00226 
00227 static void SendTickCount()
00228 { taskQueuWriteRequestOnName(WriteQueuT4,3);
00229   genQueuWriteOnName(WriteQueuT4,defResponseTickCount);
00230   genPipeInt16(genGetTickCount(),WriteQueuPipe);
00231   taskQueuReleaseOnName(WriteQueuT4); }
00232 
00233 static void SendUptime()
00234 { taskQueuWriteRequestOnName(WriteQueuT4,6);
00235   genQueuWriteOnName(WriteQueuT4,defResponseUptime);
00236   genQueuWriteOnName(WriteQueuT4,uptime[2]);
00237   genQueuWriteOnName(WriteQueuT4,uptime[1]);
00238   genQueuWriteOnName(WriteQueuT4,uptime[0]);
00239   genPipeInt16(genGetTickCount(),WriteQueuPipe);
00240   taskQueuReleaseOnName(WriteQueuT4); }
00241 
00242 static void SendProcessList()
00243 { taskQueuWriteRequestOnName(WriteQueuT4,11);
00244   genLogOs(WriteQueuPipe);
00245   taskQueuReleaseOnName(WriteQueuT4);
00246   Tuint08 uiTaskNumber;
00247   for (uiTaskNumber=0; uiTaskNumber<defNumberOfTasks; uiTaskNumber++)
00248   { taskQueuWriteRequestOnName(WriteQueuT4,22);
00249     genLogTask(uiTaskNumber,WriteQueuPipe);
00250     taskQueuReleaseOnName(WriteQueuT4); } }
00251 
00252 static void SendSingleResponse(Tuint08 uiResponse)
00253 { taskQueuWriteRequestOnName(WriteQueuT4,1);
00254   genQueuWriteOnName(WriteQueuT4,uiResponse);
00255   taskQueuReleaseOnName(WriteQueuT4); }
00256 
00257 static Tuint08 getSingleValue()
00258 { taskQueuReadRequestOnName(ReadQueuT4,1);
00259   Tuint08 Result = genQueuReadOnName(ReadQueuT4);
00260   taskQueuReleaseOnName(ReadQueuT4);
00261   return Result; }
00262 
00263 static void HandleReboot()
00264 { SendSingleResponse(defResponseOK);
00265   taskDelayFromNow(200);
00266   genReboot(); }
00267 
00268 static void HandleRecreate()
00269 { Tuint08 uiTaskNumber = getSingleValue();
00270   if (uiTaskNumber<defNumberOfTasks)
00271   { SendSingleResponse(defResponseOK);
00272     taskDelayFromNow(200);
00273     taskRecreate(uiTaskNumber); }
00274   else
00275   { SendSingleResponse(defResponseInvalidTask); } }
00276 
00277 static void HandleCommand(void (*pCommand)(Tuint08 uiTN))
00278 { Tuint08 uiTaskNumber = getSingleValue();
00279   if (uiTaskNumber<defNumberOfTasks)
00280   { pCommand(uiTaskNumber);
00281     SendSingleResponse(defResponseOK); }
00282   else
00283   { SendSingleResponse(defResponseInvalidTask); } }
00284 
00285 static void HandlePriority()
00286 { Tuint08 uiTaskNumber = getSingleValue();
00287   Tuint08 uiNewPrio = getSingleValue();
00288   if (uiTaskNumber>=defNumberOfTasks) { SendSingleResponse(defResponseInvalidTask); }
00289   else if (uiNewPrio>7) { SendSingleResponse(defResponseInvalidPriority); }
00290   else
00291   { genSetPriority(uiTaskNumber,uiNewPrio);
00292     SendSingleResponse(defResponseOK); } }
00293 
00294 
00295 static void HandleDump()
00296 { taskQueuReadRequestOnName(ReadQueuT4,4);
00297   Tuint08 uiControl = genQueuReadOnName(ReadQueuT4);
00298   Tuint08 uiHighByte = genQueuReadOnName(ReadQueuT4);
00299   Tuint08 uiLowByte = genQueuReadOnName(ReadQueuT4);
00300   Tuint08 uiLength = genQueuReadOnName(ReadQueuT4);
00301   taskQueuReleaseOnName(ReadQueuT4);
00302   Taddress pStart = (Taddress) ((((Tuint16) uiHighByte) << 8) | (uiLowByte & 0xF0));
00303   /* blocks of 16 bytes */
00304   Tuint08 uiLengthBlocks = ((uiLength-1) >> 4);
00305   Tuint08 uiCount;
00306   if (uiControl == defDumpEEPROM) { taskFileOpen(); }
00307   do
00308   { taskQueuWriteRequestOnName(WriteQueuT4,19);
00309     genQueuWriteOnName(WriteQueuT4,defResponseDump);
00310     genQueuWriteOnName(WriteQueuT4,((Tuint08) (((Tuint16) pStart)>>8)));
00311     genQueuWriteOnName(WriteQueuT4,((Tuint08) ((Tuint16) (pStart))));
00312     for (uiCount=0; uiCount<16; uiCount++)
00313     { Tbyte bVal = 0;
00314       if (uiControl == defDumpRAM)
00315       { bVal = *(pStart); }
00316       else if (uiControl == defDumpEEPROM)
00317       { bVal = portFSReadByte(pStart); }
00318       else if (uiControl == defDumpFLASH)
00319       { bVal = pgm_read_byte(pStart);  }
00320       genQueuWriteOnName(WriteQueuT4,bVal);
00321       pStart++; }
00322     taskQueuReleaseOnName(WriteQueuT4); }
00323   while (uiLengthBlocks--);
00324   if (uiControl == defDumpEEPROM) { taskFileClose(); } }
00325 
00326 
00327 #define BlockLength 16
00328 static void HandleStore()
00329 { taskQueuReadRequestOnName(ReadQueuT4,2);
00330   Tuint08 uiFileNumber = genQueuReadOnName(ReadQueuT4);
00331   Tuint08 uiFileLength = genQueuReadOnName(ReadQueuT4);
00332   taskQueuReleaseOnName(ReadQueuT4);
00333   if (uiFileNumber>=defFsNumberOfAllFiles)
00334   { SendSingleResponse(defResponseInvalidFileNumber);
00335     /* TODO: must we flush here? */
00336     }
00337   else
00338   { /* blocks of 16 bytes */
00339     Tuint08 uiOffset = 0;
00340     Tuint08 uiReadLength;
00341     taskFileOpen();
00342     while (uiFileLength>0)
00343     { if (uiFileLength>BlockLength) { uiReadLength = BlockLength; } else { uiReadLength = uiFileLength; }
00344       taskQueuReadRequestOnName(ReadQueuT4,uiReadLength);
00345       taskFileWritePipe(uiFileNumber,uiOffset,uiReadLength,ReadQueuPipe);
00346       uiOffset += uiReadLength;
00347       uiFileLength -= uiReadLength;
00348       taskQueuReleaseOnName(ReadQueuT4); }
00349     taskFileClose();
00350     SendSingleResponse(defResponseOK); } }
00351 
00352 static void HandleRecall()
00353 { Tuint08 uiFileNumber = getSingleValue();
00354   /* blocks of 16 bytes */
00355   taskFileOpen();
00356   Tuint08 uiFileLength = taskFileGetSize(uiFileNumber);
00357   if (uiFileNumber>=defFsNumberOfAllFiles)
00358   {  SendSingleResponse(defResponseInvalidFileNumber); }
00359   else
00360   { taskQueuWriteRequestOnName(WriteQueuT4,2);
00361     genQueuWriteOnName(WriteQueuT4,defResponseFile);
00362     genQueuWriteOnName(WriteQueuT4,uiFileLength);
00363     taskQueuReleaseOnName(WriteQueuT4);
00364     Tuint08 uiOffset = 0;
00365     Tuint08 uiWriteLength;
00366     while (uiFileLength>0)
00367     { if (uiFileLength>BlockLength) { uiWriteLength = BlockLength; } else { uiWriteLength = uiFileLength; }
00368       taskQueuWriteRequestOnName(WriteQueuT4,uiWriteLength);
00369       taskFileReadPipe(uiFileNumber,uiOffset,uiWriteLength,WriteQueuPipe);
00370       uiOffset += uiWriteLength;
00371       uiFileLength -= uiWriteLength;
00372       taskQueuReleaseOnName(WriteQueuT4); } }
00373   taskFileClose(); }
00374 
00375 
00376 static void HandleTest()
00377 { SendSingleResponse(defResponseOK); }
00378 
00379 
00380 static Tuint08 volatile uiLedState[8];
00381 static Tuint08 volatile uiPeriodOff[8];
00382 static Tuint08 volatile uiPeriodOn[8];
00383 
00384 static void ExeLedState()
00385 { taskQueuReadRequestOnName(ReadQueuT4,2);
00386   Tuint08 uiNumber = genQueuReadOnName(ReadQueuT4);
00387   Tuint08 uiState = genQueuReadOnName(ReadQueuT4);
00388   taskQueuReleaseOnName(ReadQueuT4);
00389   Tuint08 Result;
00390   if ((uiNumber>8) || (uiState>defDemoRequestLedStateFollow))
00391   { Result = defDemoResponseLedError; }
00392   else
00393   { taskEnterGlobalCritical();
00394     if (uiNumber==8)
00395     { for (uiNumber=0; uiNumber<8; uiNumber++) { uiLedState[uiNumber] = uiState; } }
00396     else { uiLedState[uiNumber] = uiState; }
00397     Result = defDemoResponseLedOK; }
00398     taskExitGlobalCritical();
00399   SendSingleResponse(Result); }
00400 
00401 static void ExeLedCycle()
00402 { taskQueuReadRequestOnName(ReadQueuT4,3);
00403   Tuint08 uiNumber = genQueuReadOnName(ReadQueuT4);
00404   Tuint08 uiOn = genQueuReadOnName(ReadQueuT4);
00405   Tuint08 uiOff = genQueuReadOnName(ReadQueuT4);
00406   taskQueuReleaseOnName(ReadQueuT4);
00407   Tuint08 Result;
00408   if (uiNumber>8)
00409   { Result = defDemoResponseLedError; }
00410   else
00411   { if (uiNumber==8)
00412     { for (uiNumber=0; uiNumber<8; uiNumber++)
00413       { uiPeriodOn[uiNumber] = uiOn;
00414         uiPeriodOff[uiNumber] = uiOff; } }
00415     else
00416     { uiPeriodOn[uiNumber] = uiOn;
00417       uiPeriodOff[uiNumber] = uiOff; }
00418     Result = defDemoResponseLedOK; }
00419   SendSingleResponse(Result); }
00420 
00421 static void ExeLedSave()
00422 { Tuint08 uiFileNumber = getSingleValue();
00423   taskFileOpen();
00424   if (uiFileNumber>=defFsNumberOfAllFiles)
00425   {  SendSingleResponse(defResponseInvalidFileNumber); }
00426   else
00427   { taskFileWriteBuffer(uiFileNumber,0,8,(Taddress) uiLedState);
00428     taskFileWriteBuffer(uiFileNumber,8,8,(Taddress) uiPeriodOff);
00429     taskFileWriteBuffer(uiFileNumber,16,8,(Taddress) uiPeriodOn);
00430     SendSingleResponse(defResponseOK); }
00431   taskFileClose(); }
00432 
00433 
00434 static void ExeLedLoad()
00435 { Tuint08 uiFileNumber = getSingleValue();
00436   taskFileOpen();
00437   if (uiFileNumber>=defFsNumberOfAllFiles)
00438   {  SendSingleResponse(defResponseInvalidFileNumber); }
00439   else
00440   { taskFileReadBuffer(uiFileNumber,0,8,(Taddress) uiLedState);
00441     taskFileReadBuffer(uiFileNumber,8,8, (Taddress) uiPeriodOff);
00442     taskFileReadBuffer(uiFileNumber,16,8,(Taddress)uiPeriodOn);
00443     SendSingleResponse(defResponseOK); }
00444   taskFileClose(); }
00445 
00446 
00447 static void ExecuteShell()
00448 { Tuint08 uiCommand = getSingleValue();
00449   if      (uiCommand == defRequestFemtoOs)      SendID();
00450   else if (uiCommand == defRequestTickCount)    SendTickCount();
00451   else if (uiCommand == defRequestUptime)       SendUptime();
00452   else if (uiCommand == defRequestReboot)       HandleReboot();
00453   else if (uiCommand == defRequestProcessList)  SendProcessList();
00454   else if (uiCommand == defRequestSuspend)      HandleCommand(genSuspend);
00455   else if (uiCommand == defRequestResume)       HandleCommand(genResume);
00456   else if (uiCommand == defRequestTerminate)    HandleCommand(taskTerminate);
00457   else if (uiCommand == defRequestRecreate)     HandleRecreate();
00458   else if (uiCommand == defRequestPriority)     HandlePriority();
00459   else if (uiCommand == defRequestDump)         HandleDump();
00460   else if (uiCommand == defRequestStore)        HandleStore();
00461   else if (uiCommand == defRequestRecall)       HandleRecall();
00462   else if (uiCommand == defRequestTest)         HandleTest();
00463   else if (uiCommand == defDemoRequestLedState) ExeLedState();
00464   else if (uiCommand == defDemoRequestLedCycle) ExeLedCycle();
00465   else if (uiCommand == defDemoRequestLedSave)  ExeLedSave();
00466   else if (uiCommand == defDemoRequestLedLoad)  ExeLedLoad();
00467   else SendSingleResponse(defResponseUnknownCommand);
00468   }
00469 
00470 static void clearQueus()
00471 { taskQueuWriteRequestOnName(WriteQueuT4,0);
00472   genQueuClearOnName(WriteQueuT4);
00473   taskQueuReleaseOnName(WriteQueuT4);
00474   taskQueuWriteRequestOnName(ReadQueuT4,0);
00475   genQueuClearOnName(ReadQueuT4);
00476   taskQueuReleaseOnName(ReadQueuT4); }
00477 
00478 /* This is called once at system boot, and before the creating of any of
00479  * the tasks. Use it to initialize the hardware. */
00480 void appBoot(void)
00481 { DDRA  = 0xFF;
00482   PORTA = 0xFF;
00483   #if (cfgCheckTrace == cfgFalse)
00484     DDRB  = 0x30;   /* debug leds 0 and 1 */
00485     PORTB = 0x30;
00486   #endif
00487   GIMSK = 0x20;   /* set PCIE0 bit (enable interrupts on ports 8..11  */
00488   PCMSK0 = 0x00;  /* only allow for an interrupt on port PB6.            */
00489   PCMSK1 = 0x40;  /* only allow for an interrupt on port PB6.            */
00490   Tuint08 i;
00491   for (i=0; i<8; i++)
00492   { uiLedState[i]  = defDemoRequestLedStateFlash;
00493     uiPeriodOff[i] = 8;
00494     uiPeriodOn[i]  = 8; } }
00495 
00496 
00497 #if (preTaskDefined(T4Bus))
00498 
00499 void appLoop_T4Bus(void)
00500 { clearQueus();
00501   initBus();
00502   while (true)
00503   {
00504     #if (cfgUseTaskWatchdog == cfgTrue)
00505       taskFeedWatchdog();
00506     #endif
00507     startCommunication();
00508     taskDelayFromNow(50);   } }
00509 
00510 #endif
00511 
00512 
00513 #if (preTaskDefined(Shell))
00514 
00515 void appLoop_Shell(void)
00516 { clearQueus();
00517   while (true)
00518   { ExecuteShell();
00519     taskDelayFromNow(50);   } }
00520 
00521 #endif
00522 
00523 /* 40 bits uptime counter */
00524 void appTick16(void)
00525 { if (++uptime[0] == 0)
00526   {  if (++uptime[1] == 0)
00527      { uptime[2]++; } } }
00528 
00529 /* This does only compile to an atomic instruction for fixed lednr! */
00530 
00531 #define ledOff(bits)  { PORTA |= (bits); }
00532 #define ledOn(bits)   { PORTA &=  ~(bits); }
00533 #define ledInv(bits)  { PINA = (bits); }
00534 #define getLed(bits)  (PORTA & (bits))
00535 
00536 
00537 static void wait(Tuint08 uiLed) __attribute__((noreturn));
00538 static void wait(Tuint08 uiLed)
00539 { Tuint08 uiPerOff = uiPeriodOff[uiLed];
00540   Tuint08 uiPerOn = uiPeriodOn[uiLed];
00541   Tuint08 uiState = uiLedState[uiLed];
00542   Tuint08 uiBits  = (1 << uiLed);
00543   Tuint16 uiDelay = 100;
00544   if (uiState == defDemoRequestLedStateFollow)
00545   { }
00546   else if (uiState == defDemoRequestLedStateOff)
00547   { ledOff(uiBits); }
00548   else if (uiState == defDemoRequestLedStateOn)
00549   { ledOn(uiBits); }
00550   else if (uiState == defDemoRequestLedStateFlash)
00551   { ledInv(uiBits);
00552     if (getLed(uiBits) == 0x00)
00553     { uiDelay = (((Tuint16) uiPerOff)<<5); }
00554     else
00555     { uiDelay = (((Tuint16) uiPerOn)<<5); } }
00556   else if (uiState == defDemoRequestLedStateFreeze)
00557   { while(true); }
00558   taskRestart(defRestartDefault,uiDelay); }
00559 
00560 #if (cfgIntTickTrack == cfgTrue)
00561 
00562 void SIG_PIN_CHANGE(void) __attribute__ ( ( signal, naked, used, externally_visible ) );
00563 void SIG_PIN_CHANGE(void) { asm ("reti"); }
00564 
00565 #else
00566 
00567 void SIG_PIN_CHANGE(void) __attribute__ ( ( signal, naked, used, externally_visible ) );
00568 void SIG_PIN_CHANGE(void)
00569 { isrEnter();
00570   Tuint08 uiLed;
00571   for (uiLed=0; uiLed<8; uiLed++)
00572   { if ( uiLedState[uiLed]==defDemoRequestLedStateFollow )
00573     { ledInv(1 << uiLed); } }
00574   isrExit(); }
00575 
00576 #endif
00577 
00578 #if (preTaskDefined(LEDtask0))
00579   void appLoop_LEDtask0(void)  { wait(0); }
00580 #endif
00581 
00582 #if (preTaskDefined(LEDtask1))
00583   void appLoop_LEDtask1(void)  { wait(1); }
00584   #endif
00585 
00586 #if (preTaskDefined(LEDtask2))
00587   void appLoop_LEDtask2(void)  { wait(2); }
00588 #endif
00589 
00590 #if (preTaskDefined(LEDtask3))
00591   void appLoop_LEDtask3(void)  { wait(3); }
00592 #endif
00593 
00594 #if (preTaskDefined(LEDtask4))
00595   void appLoop_LEDtask4(void)  { wait(4); }
00596 #endif
00597 
00598 #if (preTaskDefined(LEDtask5))
00599   void appLoop_LEDtask5(void)  { wait(5); }
00600 #endif
00601 
00602 #if (preTaskDefined(LEDtask6))
00603   void appLoop_LEDtask6(void)  { wait(6); }
00604 #endif
00605 
00606 #if (preTaskDefined(LEDtask7))
00607   void appLoop_LEDtask7(void)  { wait(7); }
00608 #endif
00609 

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