⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 hal_key.lst

📁 cc2430应用实例
💻 LST
📖 第 1 页 / 共 5 页
字号:
   \   000005   7409         MOV     A,#0x9
   \   000007   12....       LCALL   ?XSTACK_DISP0_8
   \   00000A   12....       LCALL   ?Subroutine0 & 0xFFFF
    242          #if (HAL_KEY == TRUE)
    243            /* Enable/Disable Interrupt or */
    244            Hal_KeyIntEnable = interruptEnable;
   \                     ??CrossCallReturnLabel_0:
   \   00000D   E9           MOV     A,R1
   \   00000E   90....       MOV     DPTR,#Hal_KeyIntEnable
   \   000011   F0           MOVX    @DPTR,A
    245          
    246            /* Register the callback fucntion */
    247            pHalKeyProcessFunction = cback;
   \   000012   90....       MOV     DPTR,#??pHalKeyProcessFunction
   \   000015   EC           MOV     A,R4
   \   000016   F0           MOVX    @DPTR,A
   \   000017   A3           INC     DPTR
   \   000018   ED           MOV     A,R5
   \   000019   F0           MOVX    @DPTR,A
   \   00001A   A3           INC     DPTR
   \   00001B   EE           MOV     A,R6
   \   00001C   F0           MOVX    @DPTR,A
    248          
    249            /* Determine if interrupt is enable or not */
    250            if (Hal_KeyIntEnable)
   \   00001D   90....       MOV     DPTR,#Hal_KeyIntEnable
   \   000020   E0           MOVX    A,@DPTR
   \   000021   6023         JZ      ??HalKeyConfig_0
    251            {
    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 */
    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 */
    269              HAL_KEY_SW_5_IEN |= HAL_KEY_SW_5_IENBIT;
    270              HAL_KEY_SW_5_PXIFG = ~(HAL_KEY_SW_5_BIT);        /* Clear any pending interrupts */
    271          #endif
    272          
    273          #if defined (HAL_KEY_SW_6_ENABLE)
    274              PICTL &= ~(HAL_KEY_SW_6_EDGEBIT);                 /* Set rising or falling edge */
   \   000023   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 */
   \   000026   438C08       ORL     0x8c,#0x8
    279              HAL_KEY_SW_6_IEN |= HAL_KEY_SW_6_IENBIT;
   \   000029   D2BD         SETB    0xb8.5
    280              HAL_KEY_SW_6_PXIFG = ~(HAL_KEY_SW_6_BIT);        /* Clear any pending interrupts */
   \   00002B   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)
   \   00002E   90....       MOV     DPTR,#??HalKeyConfigured
   \   000031   E0           MOVX    A,@DPTR
   \   000032   6401         XRL     A,#0x1
   \   000034   7030         JNZ     ??HalKeyConfig_1
    285              {
    286                osal_stop_timerEx( Hal_TaskID, HAL_KEY_EVENT);  /* Cancel polling if active */
   \   000036                ; Setup parameters for call to function osal_stop_timerEx
   \   000036   7A01         MOV     R2,#0x1
   \   000038   7B00         MOV     R3,#0x0
   \   00003A   90....       MOV     DPTR,#Hal_TaskID
   \   00003D   E0           MOVX    A,@DPTR
   \   00003E   F9           MOV     R1,A
   \   00003F   90....       MOV     DPTR,#(osal_stop_timerEx & 0xffff)
   \   000042   74..         MOV     A,#((osal_stop_timerEx >> 16) & 0xff)
   \   000044   801D         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:
   \   000046   538CF7       ANL     0x8c,#0xf7
    304              HAL_KEY_SW_6_IEN &= ~(HAL_KEY_SW_6_IENBIT);
   \   000049   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 */
   \   00004B   538CDF       ANL     0x8c,#0xdf
    309              HAL_KEY_SW_5_IEN &= ~(HAL_KEY_SW_5_IENBIT);
   \   00004E   539AFD       ANL     0x9a,#0xfd
    310          #endif
    311              osal_start_timerEx (Hal_TaskID, HAL_KEY_EVENT, HAL_KEY_POLLING_VALUE);    /* Kick off polling */
   \   000051                ; Setup parameters for call to function osal_start_timerEx
   \   000051   7C64         MOV     R4,#0x64
   \   000053   7D00         MOV     R5,#0x0
   \   000055   7A01         MOV     R2,#0x1
   \   000057   7B00         MOV     R3,#0x0
   \   000059   90....       MOV     DPTR,#Hal_TaskID
   \   00005C   E0           MOVX    A,@DPTR
   \   00005D   F9           MOV     R1,A
   \   00005E   90....       MOV     DPTR,#(osal_start_timerEx & 0xffff)
   \   000061   74..         MOV     A,#((osal_start_timerEx >> 16) & 0xff)
   \                     ??HalKeyConfig_2:
   \   000063   12....       LCALL   ?BCALL               ; Banked call to: DPTR()
    312            }
    313          
    314            /* Key now is configured */
    315            HalKeyConfigured = TRUE;
   \                     ??HalKeyConfig_1:
   \   000066   7401         MOV     A,#0x1
   \   000068   90....       MOV     DPTR,#??HalKeyConfigured
   \   00006B   F0           MOVX    @DPTR,A
    316          #endif /* HAL_KEY */
    317          }
   \   00006C   FF           MOV     R7,A
   \   00006D   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   A2A0         MOV     C,0xa0.0
   \   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:

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -