📄 hal_key.lst
字号:
252
253 /*
254 Work around for CC2430DB when interrupt is enabled and SW5 (center joystick)
255 is used. This SW5 uses P2 which also has debug lines connected to it. This
256 causes contant interruption on P2INT_VECTOR. Disable the usage of P2 interrupt
257 will stop this problem.
258 */
259 #if defined (HAL_BOARD_CC2430DB)
260 #undef HAL_KEY_SW_5_ENABLE /* Dis-allow SW5 when key interrupt is enable */
261 #endif
262
263 #if defined (HAL_KEY_SW_5_ENABLE)
264 PICTL &= ~(HAL_KEY_SW_5_EDGEBIT); /* Set rising or falling edge */
\ 000023 538CFB ANL 0x8c,#0xfb
265 #if (HAL_KEY_SW_5_EDGE == HAL_KEY_FALLING_EDGE)
266 PICTL |= HAL_KEY_SW_5_EDGEBIT;
267 #endif
268 HAL_KEY_SW_5_ICTL |= HAL_KEY_SW_5_ICTLBIT; /* Set interrupt enable bit */
\ 000026 438C10 ORL 0x8c,#0x10
269 HAL_KEY_SW_5_IEN |= HAL_KEY_SW_5_IENBIT;
\ 000029 D2BD SETB 0xb8.5
270 HAL_KEY_SW_5_PXIFG = ~(HAL_KEY_SW_5_BIT); /* Clear any pending interrupts */
\ 00002B 7589DF MOV 0x89,#-0x21
271 #endif
272
273 #if defined (HAL_KEY_SW_6_ENABLE)
274 PICTL &= ~(HAL_KEY_SW_6_EDGEBIT); /* Set rising or falling edge */
\ 00002E 538CFE ANL 0x8c,#0xfe
275 #if (HAL_KEY_SW_6_EDGE == HAL_KEY_FALLING_EDGE)
276 PICTL |= HAL_KEY_SW_6_EDGEBIT;
277 #endif
278 HAL_KEY_SW_6_ICTL |= HAL_KEY_SW_6_ICTLBIT; /* Set interrupt enable bit */
\ 000031 438C08 ORL 0x8c,#0x8
279 HAL_KEY_SW_6_IEN |= HAL_KEY_SW_6_IENBIT;
\ 000034 D2BD SETB 0xb8.5
280 HAL_KEY_SW_6_PXIFG = ~(HAL_KEY_SW_6_BIT); /* Clear any pending interrupts */
\ 000036 7589FD MOV 0x89,#-0x3
281 #endif
282
283 /* Do this only after the hal_key is configured - to work with sleep stuff */
284 if (HalKeyConfigured == TRUE)
\ 000039 90.... MOV DPTR,#??HalKeyConfigured
\ 00003C E0 MOVX A,@DPTR
\ 00003D 6401 XRL A,#0x1
\ 00003F 702F JNZ ??HalKeyConfig_1
285 {
286 osal_stop_timerEx( Hal_TaskID, HAL_KEY_EVENT); /* Cancel polling if active */
\ 000041 ; Setup parameters for call to function osal_stop_timerEx
\ 000041 7A01 MOV R2,#0x1
\ 000043 7B00 MOV R3,#0x0
\ 000045 90.... MOV DPTR,#Hal_TaskID
\ 000048 E0 MOVX A,@DPTR
\ 000049 F9 MOV R1,A
\ 00004A 90.... MOV DPTR,#(osal_stop_timerEx & 0xffff)
\ 00004D 74.. MOV A,#((osal_stop_timerEx >> 16) & 0xff)
\ 00004F 801C SJMP ??HalKeyConfig_2
287 }
288 }
289 else /* Interrupts NOT enabled */
290 {
291
292 /*
293 Work around for CC2430DB when interrupt is enabled and SW5 (center joystick)
294 is used. This SW5 uses P2 which also has debug lines connected to it. This
295 causes contant interruption on P2INT_VECTOR. Disable the usage of P2 interrupt
296 will stop this problem.
297 */
298 #if defined (HAL_BOARD_CC2430DB)
299 #define HAL_KEY_SW_5_ENABLE /* Allow SW5 only when key interrupt is disable */
300 #endif
301
302 #if defined (HAL_KEY_SW_6_ENABLE)
303 HAL_KEY_SW_6_ICTL &= ~(HAL_KEY_SW_6_ICTLBIT); /* Clear interrupt enable bit */
\ ??HalKeyConfig_0:
\ 000051 538CF7 ANL 0x8c,#0xf7
304 HAL_KEY_SW_6_IEN &= ~(HAL_KEY_SW_6_IENBIT);
\ 000054 C2BD CLR 0xb8.5
305 #endif
306
307 #if defined (HAL_KEY_SW_5_ENABLE)
308 HAL_KEY_SW_5_ICTL &= ~(HAL_KEY_SW_5_ICTLBIT); /* Clear interrupt enable bit */
\ 000056 538CEF ANL 0x8c,#0xef
309 HAL_KEY_SW_5_IEN &= ~(HAL_KEY_SW_5_IENBIT);
\ 000059 C2BD CLR 0xb8.5
310 #endif
311 osal_start_timerEx (Hal_TaskID, HAL_KEY_EVENT, HAL_KEY_POLLING_VALUE); /* Kick off polling */
\ 00005B ; Setup parameters for call to function osal_start_timerEx
\ 00005B 7C64 MOV R4,#0x64
\ 00005D 7D00 MOV R5,#0x0
\ 00005F 7A01 MOV R2,#0x1
\ 000061 7B00 MOV R3,#0x0
\ 000063 90.... MOV DPTR,#Hal_TaskID
\ 000066 E0 MOVX A,@DPTR
\ 000067 F9 MOV R1,A
\ 000068 90.... MOV DPTR,#(osal_start_timerEx & 0xffff)
\ 00006B 74.. MOV A,#((osal_start_timerEx >> 16) & 0xff)
\ ??HalKeyConfig_2:
\ 00006D 12.... LCALL ?BCALL ; Banked call to: DPTR()
312 }
313
314 /* Key now is configured */
315 HalKeyConfigured = TRUE;
\ ??HalKeyConfig_1:
\ 000070 7401 MOV A,#0x1
\ 000072 90.... MOV DPTR,#??HalKeyConfigured
\ 000075 F0 MOVX @DPTR,A
316 #endif /* HAL_KEY */
317 }
\ 000076 FF MOV R7,A
\ 000077 02.... LJMP ?BANKED_LEAVE_XDATA
\ In segment BANKED_CODE, align 1, keep-with-next
\ ?Subroutine0:
\ 000000 E0 MOVX A,@DPTR
\ 000001 FC MOV R4,A
\ 000002 A3 INC DPTR
\ 000003 E0 MOVX A,@DPTR
\ 000004 FD MOV R5,A
\ 000005 A3 INC DPTR
\ 000006 E0 MOVX A,@DPTR
\ 000007 FE MOV R6,A
\ 000008 22 RET
318
319 /**************************************************************************************************
320 * @fn HalKeyRead
321 *
322 * @brief Read the current value of a key
323 *
324 * @param None
325 *
326 * @return keys - current keys status
327 **************************************************************************************************/
328
\ In segment BANKED_CODE, align 1, keep-with-next
329 uint8 HalKeyRead ( void )
\ HalKeyRead:
330 {
\ 000000 74F7 MOV A,#-0x9
\ 000002 12.... LCALL ?BANKED_ENTER_XDATA
\ 000005 ; Saved register size: 9
\ 000005 ; Auto size: 0
331
332 uint8 keys = 0;
\ 000005 7E00 MOV R6,#0x0
333
334 #if (HAL_KEY == TRUE)
335
336 #if defined (HAL_KEY_JOYSTICK_ENABLE)
337 uint8 ksave0 = 0;
\ 000007 7F00 MOV R7,#0x0
338 uint8 ksave1;
339 uint8 adc;
340 #endif
341
342 #if defined (HAL_KEY_SW_6_ENABLE)
343 if (!(HAL_KEY_SW_6_PORT & HAL_KEY_SW_6_BIT)) /* Key is active low */
\ 000009 A281 MOV C,0x80.1
\ 00000B 4002 JC ??HalKeyRead_0
344 {
345 keys |= HAL_KEY_SW_6;
\ 00000D 7E20 MOV R6,#0x20
346 }
347 #endif
348 #if defined (HAL_KEY_SW_5_ENABLE)
349 if (HAL_KEY_SW_5_PORT & HAL_KEY_SW_5_BIT) /* Key is active high */
\ ??HalKeyRead_0:
\ 00000F A285 MOV C,0x80.5
\ 000011 5004 JNC ??HalKeyRead_1
350 {
351 keys |= HAL_KEY_SW_5;
\ 000013 EE MOV A,R6
\ 000014 D2E2 SETB 0xE0 /* A */.2
\ 000016 FE MOV R6,A
352 }
353 #endif
354
355 #if defined (HAL_KEY_JOYSTICK_ENABLE)
356 /*
357 * The joystick control is encoded as an analog voltage. Keep on reading
358 * the ADC until two consecutive key decisions are the same.
359 */
360
361 do
362 {
363 ksave1 = ksave0; /* save previouse key reading */
\ ??HalKeyRead_1:
\ 000017 8F.. MOV ?V0 + 0,R7
364
365 adc = HalAdcRead (HAL_KEY_JOY_CHN, HAL_ADC_RESOLUTION_8);
\ 000019 ; Setup parameters for call to function HalAdcRead
\ 000019 7A01 MOV R2,#0x1
\ 00001B 7906 MOV R1,#0x6
\ 00001D 90.... MOV DPTR,#(HalAdcRead & 0xffff)
\ 000020 74.. MOV A,#((HalAdcRead >> 16) & 0xff)
\ 000022 12.... LCALL ?BCALL ; Banked call to: DPTR()
366
367 if (CHVER == 0x01)
\ 000025 90DF60 MOV DPTR,#-0x20a0
\ 000028 E0 MOVX A,@DPTR
\ 000029 6401 XRL A,#0x1
\ 00002B 703D JNZ ??HalKeyRead_2
368 {
369 /* Rev B */
370 if ((adc >= 90) && (adc <= 100))
\ 00002D EA MOV A,R2
\ 00002E C3 CLR C
\ 00002F 945A SUBB A,#0x5a
\ 000031 EA MOV A,R2
\ 000032 400B JC ??HalKeyRead_3
\ 000034 C3 CLR C
\ 000035 9465 SUBB A,#0x65
\ 000037 5050 JNC ??HalKeyRead_4
371 {
372 ksave0 |= HAL_KEY_UP;
\ ??HalKeyRead_5:
\ 000039 EF MOV A,R7
\ 00003A D2E0 SETB 0xE0 /* A */.0
\ ??HalKeyRead_6:
\ 00003C FF MOV R7,A
\ 00003D 804A SJMP ??HalKeyRead_4
373 }
374 else if ((adc >= 75) && (adc <= 85))
\ ??HalKeyRead_3:
\ 00003F C3 CLR C
\ 000040 944B SUBB A,#0x4b
\ 000042 EA MOV A,R2
\ 000043 400A JC ??HalKeyRead_7
\ 000045 C3 CLR C
\ 000046 9456 SUBB A,#0x56
\ 000048 503F JNC ??HalKeyRead_4
375 {
376 ksave0 |= HAL_KEY_RIGHT;
\ ??HalKeyRead_8:
\ 00004A EF MOV A,R7
\ 00004B D2E1 SETB 0xE0 /* A */.1
\ 00004D 80ED SJMP ??HalKeyRead_6
377 }
378 else if ((adc >= 45) && (adc <= 55))
\ ??HalKeyRead_7:
\ 00004F C3 CLR C
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -