00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00046
00047 #include "femtoos_code.h"
00048
00049
00050
00051 #define delay07 1600U
00052 #define delay06 800U
00053 #define delay05 400U
00054 #define delay04 200U
00055 #define delay03 1600U
00056 #define delay02 800U
00057 #define delay01 400U
00058 #define delay00 200U
00059
00060 static Tbool bSync = false;
00061
00062
00063
00064 void appBoot(void)
00065 { devLedDRR |= 0xFF;
00066 devSwitchDRR &= 0xFC;
00067 devLedPORT |= 0xFF; }
00068
00069
00070
00071 #define setLed(lednr,state) if (state) { devLedPORT |= (1 << lednr); } else { devLedPORT &= ~(1 << lednr); }
00072
00073
00074
00075
00076
00077 #if (preTaskDefined(LEDtask0))
00078
00079 void appLoop_LEDtask0(void)
00080 { Tuint08 led = 0;
00081 Tuint08 count = 32;
00082 while (count--)
00083 { taskFeedWatchdog();
00084 led = 1 - led;
00085 setLed(0,led);
00086 taskDelayFromNow(delay00); }
00087 while (1); }
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101 void appBark_LEDtask0(void)
00102 { devLedPORT |= 0x01;
00103 Tuint08 lastPrio = genGetPriorityOnName(LEDtask0);
00104 if(lastPrio>0)
00105 { --lastPrio;
00106 genSetPriorityOnName(LEDtask0,lastPrio); }
00107 else
00108 { genSuspendOnName(LEDtask0); } }
00109
00110 #endif
00111
00112
00113
00114
00115 #if (preTaskDefined(LEDtask1))
00116
00117 void appLoop_LEDtask1(void)
00118 { Tuint08 led = false;
00119 while (true)
00120 { led = !led;
00121 setLed(1,led);
00122 taskDelayFromNow(delay01);
00123 led = !led;
00124 setLed(1,led);
00125 taskDelayFromNow(delay01); } }
00126
00127 #endif
00128
00129
00130 #if (preTaskDefined(LEDtask2))
00131
00132 void appLoop_LEDtask2(void)
00133 { Tuint08 led = false;
00134 while (true)
00135 { led = !led;
00136 setLed(2,led);
00137 taskDelayFromNow(delay02);
00138 led = !led;
00139 setLed(2,led);
00140 taskDelayFromNow(delay02); } }
00141
00142 #endif
00143
00144
00145
00146
00147
00148
00149
00150 #if (preTaskDefined(LEDtask3))
00151
00152 void appLoop_LEDtask3(void)
00153 { Tuint08 led = false;
00154 while (true)
00155 { led = !led;
00156 setLed(3,led);
00157 taskDelayFromNow(delay03);
00158 led = !led;
00159 setLed(3,led);
00160 taskDelayFromNow(delay03);
00161 if (bSync)
00162 { taskWaitForOtherTaskOnName(TrefPunt);
00163 bSync = false; } } }
00164
00165 #endif
00166
00167
00168 #if (preTaskDefined(LEDtask4))
00169
00170 void appLoop_LEDtask4(void)
00171 { Tuint08 led = false;
00172 while (true)
00173 { led = !led;
00174 setLed(4,led);
00175 taskDelayFromNow(delay04);
00176 led = !led;
00177 setLed(4,led);
00178 taskDelayFromNow(delay04); } }
00179
00180 #endif
00181
00182
00183 #if (preTaskDefined(LEDtask5))
00184
00185 void appLoop_LEDtask5(void)
00186 { Tuint08 led = false;
00187 while (true)
00188 { led = !led;
00189 setLed(5,led);
00190 taskDelayFromNow(delay05);
00191 led = !led;
00192 setLed(5,led);
00193 taskDelayFromNow(delay05); } }
00194
00195 #endif
00196
00197
00198 #if (preTaskDefined(LEDtask6))
00199
00200 void appLoop_LEDtask6(void)
00201 { Tuint08 led = false;
00202 while (true)
00203 { led = !led;
00204 setLed(6,led);
00205 taskDelayFromNow(delay06);
00206 led = !led;
00207 setLed(6,led);
00208 taskDelayFromNow(delay06); } }
00209
00210 #endif
00211
00212
00213
00214
00215
00216
00217
00218 #if (preTaskDefined(LEDtask7))
00219
00220 void appLoop_LEDtask7(void)
00221 { Tuint08 led = false;
00222 while (true)
00223 { led = !led;
00224 setLed(7,led);
00225 taskDelayFromNow(delay07);
00226 led = !led;
00227 setLed(7,led);
00228 taskDelayFromNow(delay07);
00229 if (bSync)
00230 { taskWaitForOtherTaskOnName(TrefPunt);
00231 bSync = false; }
00232 } }
00233
00234 #endif
00235
00236
00237
00238
00239
00240
00241 #if (preTaskDefined(Synchronize))
00242
00243 void appLoop_Synchronize(void)
00244 { Tuint08 button = devSwitchPIN & 01;
00245 Tuint08 lastbutton = button;
00246 while (true)
00247 { button = devSwitchPIN & 01;
00248 if (button != lastbutton) { bSync = true; }
00249 taskDelayFromNow(100); } }
00250
00251 #endif
00252
00253
00254
00255
00256
00257
00258
00259 #if (preTaskDefined(Release))
00260
00261 void appLoop_Release(void)
00262 { Tuint08 button = devSwitchPIN & 02;
00263 Tuint08 lastbutton = button;
00264 while (true)
00265 { button = devSwitchPIN & 02;
00266 if (button != lastbutton)
00267 { genSetPriorityOnName(LEDtask0,3);
00268 genResumeOnName(LEDtask0); }
00269 taskDelayFromNow(100); } }
00270
00271 #endif
00272