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
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046 #include "femtoos_code.h"
00047
00048
00049 #define delay03 2229U
00050 #define delay02 1218U
00051 #define delay01 666U
00052 #define delay00 364U
00053
00054
00055
00056 void appBoot(void)
00057 { devLedDRR = 0xFF;
00058 devLedPORT = 0x0F;
00059 devSwitchDRR = 0x00;
00060 devEIR = preBitSet1(0x00,devINT); }
00061
00062
00063
00064
00065 #define smallISR cfgTrue
00066
00067
00068 static void setLed(Tuint08 lednr, Tbool state)
00069 { taskEnterGlobalCritical();
00070 if (state) { devLedPORT |= (1 << lednr); } else { devLedPORT &= ~(1 << lednr); }
00071 taskExitGlobalCritical(); }
00072
00073
00074
00075
00076 void appLoop_LEDtask0(void)
00077 { Tuint08 led = false;
00078 while (true)
00079 { led = !led;
00080 setLed(0,led);
00081 taskDelayFromNow(delay00);
00082 taskSuspend(defSuspendCheck); } }
00083
00084 void appLoop_LEDtask1(void)
00085 { Tuint08 led = false;
00086 while (true)
00087 { led = !led;
00088 setLed(1,led);
00089 taskDelayFromNow(delay01);
00090 taskSuspend(defSuspendCheck); } }
00091
00092 void appLoop_LEDtask2(void)
00093 { Tuint08 led = false;
00094 while (true)
00095 { led = !led;
00096 setLed(2,led);
00097 taskDelayFromNow(delay02);
00098 taskSuspend(defSuspendCheck); } }
00099
00100 void appLoop_LEDtask3(void)
00101 { Tuint08 led = false;
00102 while (true)
00103 { led = !led;
00104 setLed(3,led);
00105 taskDelayFromNow(delay03);
00106 taskSuspend(defSuspendCheck); } }
00107
00108
00109
00110
00111 #if (cfgIntOsProtected == cfgTrue)
00112
00113 #if (smallISR == cfgTrue)
00114
00115 void devSigExternalInt(void) __attribute__ ( ( signal, naked, used, externally_visible ) );
00116 void devSigExternalInt(void)
00117 { isrEnter();
00118 Tuint08 uiRunMask = (~devLedPORT + 0x10);
00119 devLedPORT = ~(uiRunMask);
00120 isrStackCheck(2);
00121
00122 if (preBitIsSet(devAuxSysReg,devAuxSysRegBit)) { devLedPORT=~0xA5; while(true); }
00123 if ((uiRunMask & 0x10) == 0) { genSuspendOnName(LEDtask0); } else { genResumeOnName(LEDtask0); }
00124 if ((uiRunMask & 0x20) == 0) { genSuspendOnName(LEDtask1); } else { genResumeOnName(LEDtask1); }
00125 if ((uiRunMask & 0x40) == 0) { genSuspendOnName(LEDtask2); } else { genResumeOnName(LEDtask2); }
00126 if ((uiRunMask & 0x80) == 0) { genSuspendOnName(LEDtask3); } else { genResumeOnName(LEDtask3); }
00127 isrExit(); }
00128
00129 #else
00130
00131
00132 void HandlePinChange(void) __attribute__ ( ( signal ) );
00133 void HandlePinChange(void)
00134 { isrStackCheck(2);
00135 Tuint08 uiRunMask = (~devLedPORT + 0x10);
00136 if ((uiRunMask & 0x10) == 0) { genSuspend(preTaskNumberOf(LEDtask0)); } else { genResume(preTaskNumberOf(LEDtask0)); }
00137 if ((uiRunMask & 0x20) == 0) { genSuspend(preTaskNumberOf(LEDtask1)); } else { genResume(preTaskNumberOf(LEDtask1)); }
00138 if ((uiRunMask & 0x40) == 0) { genSuspend(preTaskNumberOf(LEDtask2)); } else { genResume(preTaskNumberOf(LEDtask2)); }
00139 if ((uiRunMask & 0x80) == 0) { genSuspend(preTaskNumberOf(LEDtask3)); } else { genResume(preTaskNumberOf(LEDtask3)); }
00140 devLedPORT = ~uiRunMask; }
00141
00142 void devSigExternalInt(void) __attribute__ ( ( signal, naked, used, externally_visible ) );
00143 void devSigExternalInt(void)
00144 { isrBegin();
00145 HandlePinChange();
00146
00147
00148 taskDisableGlobalInterrupts();
00149 isrEndYield(); }
00150
00151 #endif
00152
00153
00154 #else
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164 void HandlePinChange(void) __attribute__ ( ( signal ) );
00165 void HandlePinChange(void)
00166 { devLedPORT = ~(~devLedPORT + 0x10); }
00167
00168 void devSigExternalInt(void) __attribute__ ( ( signal, naked, used, externally_visible ) );
00169 void devSigExternalInt(void)
00170 { isrBegin();
00171
00172
00173 HandlePinChange();
00174 taskDisableGlobalInterrupts();
00175 isrEndReturn(); }
00176
00177 #endif
00178