📄 timer_rev1_7.lst
字号:
154 1 if (Timer0State)
155 1 if ( tmr0 )
156 1 tmr0--;
157 1 else {
158 2 tmr0 = Flash_CNT;
159 2 if ( Flashing )
160 2 Flashing = 0;
161 2 else
162 2 Flashing = 1;
163 2 } // end else
164 1
165 1 if (Timer1State) {
166 2 if (tmr1)
167 2 tmr1--;
168 2 else
169 2 Timer1State = DEACTIVATE;
170 2 } // end
171 1 if (Timer2State) {
172 2 if (tmr2)
173 2 tmr2--;
174 2 else
175 2 Timer2State = DEACTIVATE;
176 2 } // end if
177 1 //The following detects totally 8 keys pressed/released status
178 1 //Sn-4 Sn-3 Sn-2 Sn-1 Sn(current)
179 1 // 0 1 2 3 4 keySTAGE[idxKey]
C51 COMPILER V7.06 TIMER_REV1_7 08/22/2004 21:22:04 PAGE 4
180 1 // 1 0 0 1 1 sensing port of the key
181 1 // |
182 1 // |--> key pressed confirmed
183 1 // with time interval 12ms
184 1 if (keyDetectEnable) {
185 2 if ( keySTAGE[idxKey] < 4 ) {
186 3 keyStatus = keyMask[idxKey] & PanelSW;
187 3 switch ( keySTAGE[idxKey] ) {
188 4 case 0:if (!keyStatus )
189 4 keySTAGE[idxKey] = 1;
190 4 break;
191 4 case 1:if ( !keyStatus )
192 4 keySTAGE[idxKey] = 2;
193 4 else
194 4 keySTAGE[idxKey] = 0;
195 4 break;
196 4 case 2:if ( keyStatus )
197 4 keySTAGE[idxKey] = 3;
198 4 break;
199 4 case 3:if ( keyStatus ) {
200 5 if ( durationBuzzON < 100 ) {
201 6 durationBuzzON = 100;
202 6 Out_Port = output_buf |= 0x20; //buzz on
203 6 } // end if
204 5 keySTAGE[idxKey] = 4;
205 5 } // end if
206 4 break;
207 4 default: keySTAGE[idxKey] = 0;
208 4 break;
209 4 } // end switch
210 3 } // end if
211 2 if ( ++idxKey > 7 ) // TOTALLY 6 Keys
212 2 idxKey = 0;
213 2 } // end if
214 1
215 1 if ( durationBuzzON ) {
216 2 if ( --durationBuzzON)
217 2 Out_Port = output_buf &= 0xdf; // BUZZ OFF
218 2 } // end if
219 1 } // end isr
220
221 //************************************************************************************
222 void flashMODE_update(unsigned char modeFlashing, unsigned int Flash_count)
223 {// Apply on LED : ledTesting only
224 1 // modeFlashing = 1: Flashing at freq. def. by Flash_count
225 1 // 0: No flashing, ON/OFF def. by Flash_count
226 1
227 1 if (modeFlashing) { // Flashing with <Flash count
228 2 Disable_Timer(0);
229 2 Flash_CNT = Flash_count;
230 2 Enable_Timer(0, Flash_CNT);
231 2 } else { // not Flashing, LED ON/OFF determines by Flash_count
232 2 Disable_Timer(0); // 1 = on, 0 = off
233 2 if ( Flash_count ) {
234 3 stFlashing = 1;
235 3 //valCtrlIO &= 0xfe; //Mask to on
236 3 } else {
237 3 stFlashing = 0;
238 3 //valCtrlIO |= 0x01; //Mask to off
239 3 } // end else
240 2 } // end else
241 1 } // end func.
C51 COMPILER V7.06 TIMER_REV1_7 08/22/2004 21:22:04 PAGE 5
242
243
244 //*************************************************************************
245 /*
246 uchar Turn1LEDon(uchar turnon, uchar ledIndex)
247 { // A15=1, A14=0, ctrlIO = PBYTE[0x01]
248 // LE_374 = A15 & !A14 & A1.q & !WR;
249 uchar mask = 1 << ledIndex; //led0 => 0x01,... led3 = 0x08
250 //uchar temp;
251
252 if ( ledIndex > 7 )
253 return ( 0x01 ); //out of range error
254
255 if ( turnon ) // turns on the LED by drive low
256 valCtrlIO &= ~mask;
257 else
258 valCtrlIO |= mask; // turns off the LED
259
260 A14 = 0; A15 = 1;
261 ctrlIO = valCtrlIO;
262 return (0);
263 } // end func.
264 */
265
266 //*********************************************************************
267 uchar STimerStillCounting(uchar idxStimer)
268 { //stmr0,stmr1,stmr2;
269 1
270 1 switch(idxStimer) {
271 2 case 0: return ( (uchar) Timer0State);
272 2 break;
273 2 case 1: return ( (uchar) Timer1State);
274 2 break;
275 2 case 2: return ( (uchar) Timer2State);
276 2 break;
277 2 } // end switch
278 1 return ( False );
279 1 } // end func.
280
281 //*****************************************************************
282 void Mask_Key_Detect(uchar flagClear_nDisable, uchar keyMask)
283 {
284 1 uchar i, keystageval;
285 1 uchar mask = 0x01;
286 1
287 1 if (flagClear_nDisable)
288 1 keystageval = 0x00; // clear keystage to start detect
289 1 else
290 1 keystageval = 0x05; // disable detect
291 1
292 1 for (i=0; i<8; i++) {
293 2 if ( keyMask & mask )
294 2 keySTAGE[i] = keystageval;
295 2 mask <<= 1;
296 2 } // end for
297 1 } // end func.
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 517 ----
CONSTANT SIZE = 8 ----
XDATA SIZE = ---- ----
C51 COMPILER V7.06 TIMER_REV1_7 08/22/2004 21:22:04 PAGE 6
PDATA SIZE = ---- ----
DATA SIZE = 18 ----
IDATA SIZE = ---- ----
BIT SIZE = 5 ----
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -