zdapp.lst

来自「TI的基于ZIGBEE2006的协议栈」· LST 代码 · 共 1,223 行 · 第 1/5 页

LST
1,223
字号
   \                     ?Subroutine23:
   \   000000   7402         MOV     A,#0x2
   \                     ??Subroutine23_0:
   \   000002   12....       LCALL   ?DEALLOC_XSTACK8
   \                     ??Subroutine23_1:
   \   000005   7F02         MOV     R7,#0x2
   \   000007   02....       LJMP    ?BANKED_LEAVE_XDATA

   \                                 In segment BANKED_CODE, align 1, keep-with-next
   \                     ?Subroutine4:
   \   000000   7B00         MOV     R3,#0x0
   \   000002   90....       MOV     DPTR,#ZDAppTaskID
   \   000005   E0           MOVX    A,@DPTR
   \   000006   F9           MOV     R1,A
   \   000007   90....       MOV     DPTR,#(osal_set_event & 0xffff)
   \   00000A   74..         MOV     A,#((osal_set_event >> 16) & 0xff)
   \   00000C   22           RET
    477          
    478          /*********************************************************************
    479           * Application Functions
    480           */
    481          
    482          /*********************************************************************
    483           * @fn      ZDOInitDevice
    484           *
    485           * @brief   Start the device in the network.  This function will read
    486           *   ZCD_NV_STARTUP_OPTION (NV item) to determine whether or not to
    487           *   restore the network state of the device.
    488           *
    489           * @param   startDelay - timeDelay to start device (in milliseconds).
    490           *      There is a jitter added to this delay:
    491           *              ((NWK_START_DELAY + startDelay)
    492           *              + (osal_rand() & EXTENDED_JOINING_RANDOM_MASK))
    493           *
    494           * NOTE:    If the application would like to force a "new" join, the
    495           *          application should set the ZCD_STARTOPT_DEFAULT_NETWORK_STATE
    496           *          bit in the ZCD_NV_STARTUP_OPTION NV item before calling
    497           *          this function. "new" join means to not restore the network
    498           *          state of the device. Use zgWriteStartupOptions() to set these
    499           *          options.
    500           *
    501           * @return
    502           *    ZDO_INITDEV_RESTORED_NETWORK_STATE  - The device's network state was
    503           *          restored.
    504           *    ZDO_INITDEV_NEW_NETWORK_STATE - The network state was initialized.
    505           *          This could mean that ZCD_NV_STARTUP_OPTION said to not restore, or
    506           *          it could mean that there was no network state to restore.
    507           *    ZDO_INITDEV_LEAVE_NOT_STARTED - Before the reset, a network leave was issued
    508           *          with the rejoin option set to TRUE.  So, the device was not
    509           *          started in the network (one time only).  The next time this
    510           *          function is called it will start.
    511           */

   \                                 In segment BANKED_CODE, align 1, keep-with-next
    512          uint8 ZDOInitDevice( uint16 startDelay )
   \                     ZDOInitDevice:
    513          {
   \   000000   74F6         MOV     A,#-0xa
   \   000002   12....       LCALL   ?BANKED_ENTER_XDATA
   \   000005                ; Saved register size: 10
   \   000005                ; Auto size: 2
   \   000005   74FE         MOV     A,#-0x2
   \   000007   12....       LCALL   ?ALLOC_XSTACK8
   \   00000A   85..82       MOV     DPL,?XSP + 0
   \   00000D   85..83       MOV     DPH,?XSP + 1
   \   000010   EA           MOV     A,R2
   \   000011   F0           MOVX    @DPTR,A
   \   000012   A3           INC     DPTR
   \   000013   EB           MOV     A,R3
   \   000014   F0           MOVX    @DPTR,A
    514            uint8 networkStateNV = ZDO_INITDEV_NEW_NETWORK_STATE;
    515            uint16 extendedDelay = 0;
    516          
    517            devState = DEV_INIT;    // Remove the Hold state
   \   000015   7401         MOV     A,#0x1
   \   000017   90....       MOV     DPTR,#devState
   \   00001A   F0           MOVX    @DPTR,A
    518          
    519            // Initialize leave control logic
    520            ZDApp_LeaveCtrlInit();
   \   00001B                ; Setup parameters for call to function ZDApp_LeaveCtrlInit
   \   00001B   90....       MOV     DPTR,#(ZDApp_LeaveCtrlInit & 0xffff)
   \   00001E   74..         MOV     A,#((ZDApp_LeaveCtrlInit >> 16) & 0xff)
   \   000020   12....       LCALL   ?BCALL               ; Banked call to: DPTR()
    521          
    522            // Check leave control reset settings
    523            ZDApp_LeaveCtrlStartup( &devState, &startDelay );
   \   000023                ; Setup parameters for call to function ZDApp_LeaveCtrlStartup
   \   000023   85..82       MOV     DPL,?XSP + 0
   \   000026   85..83       MOV     DPH,?XSP + 1
   \   000029   AC82         MOV     R4,DPL
   \   00002B   AD83         MOV     R5,DPH
   \   00002D   7A..         MOV     R2,#(devState & 0xff)
   \   00002F   7B..         MOV     R3,#((devState >> 8) & 0xff)
   \   000031   90....       MOV     DPTR,#(ZDApp_LeaveCtrlStartup & 0xffff)
   \   000034   74..         MOV     A,#((ZDApp_LeaveCtrlStartup >> 16) & 0xff)
   \   000036   12....       LCALL   ?BCALL               ; Banked call to: DPTR()
    524          
    525            // Leave may make the hold state come back
    526            if ( devState == DEV_HOLD )
   \   000039   90....       MOV     DPTR,#devState
   \   00003C   E0           MOVX    A,@DPTR
   \   00003D   7004         JNZ     ??ZDOInitDevice_0
    527              return ( ZDO_INITDEV_LEAVE_NOT_STARTED );   // Don't join - (one time).
   \   00003F   7902         MOV     R1,#0x2
   \   000041   802F         SJMP    ??ZDOInitDevice_1
    528          
    529          #if defined ( NV_RESTORE )
    530            // Get Keypad directly to see if a reset nv is needed.
    531            // Hold down the SW_BYPASS_NV key (defined in OnBoard.h)
    532            // while booting to skip past NV Restore.
    533            if ( HalKeyRead() == SW_BYPASS_NV )
    534              networkStateNV = ZDO_INITDEV_NEW_NETWORK_STATE;
    535            else
    536            {
    537              // Determine if NV should be restored
    538              networkStateNV = ZDApp_ReadNetworkRestoreState();
    539            }
    540          
    541            if ( networkStateNV == ZDO_INITDEV_RESTORED_NETWORK_STATE )
    542            {
    543              networkStateNV = ZDApp_RestoreNetworkState();
    544            }
    545            else
    546            {
    547              // Wipe out the network state in NV
    548              NLME_InitNV();
    549              NLME_SetDefaultNV();
    550              ZDAppSetupProtoVersion();
    551            }
    552          #endif
    553          
    554            if ( networkStateNV == ZDO_INITDEV_NEW_NETWORK_STATE )
    555            {
    556              ZDAppDetermineDeviceType();
    557          
    558              // Only delay if joining network - not restoring network state
    559              extendedDelay = (uint16)((NWK_START_DELAY + startDelay)
    560                        + (osal_rand() & EXTENDED_JOINING_RANDOM_MASK));
   \                     ??ZDOInitDevice_0:
   \   000043                ; Setup parameters for call to function osal_rand
   \   000043   90....       MOV     DPTR,#(osal_rand & 0xffff)
   \   000046   74..         MOV     A,#((osal_rand >> 16) & 0xff)
   \   000048   12....       LCALL   ?BCALL               ; Banked call to: DPTR()
   \   00004B   8A..         MOV     ?V0 + 0,R2
   \   00004D   A8..         MOV     R0,?V0 + 0
   \   00004F   85..82       MOV     DPL,?XSP + 0
   \   000052   85..83       MOV     DPH,?XSP + 1
   \   000055   747F         MOV     A,#0x7f
   \   000057   58           ANL     A,R0
   \   000058   F8           MOV     R0,A
   \   000059   E0           MOVX    A,@DPTR
   \   00005A   28           ADD     A,R0
   \   00005B   F8           MOV     R0,A
   \   00005C   A3           INC     DPTR
   \   00005D   E0           MOVX    A,@DPTR
   \   00005E   3400         ADDC    A,#0x0
   \   000060   F9           MOV     R1,A
   \   000061   7464         MOV     A,#0x64
   \   000063   28           ADD     A,R0
   \   000064   FA           MOV     R2,A
   \   000065   E4           CLR     A
   \   000066   39           ADDC    A,R1
   \   000067   FB           MOV     R3,A
    561            }
    562          
    563            // Trigger the network start
    564            ZDApp_NetworkInit( extendedDelay );
   \   000068                ; Setup parameters for call to function ZDApp_NetworkInit
   \   000068   90....       MOV     DPTR,#(ZDApp_NetworkInit & 0xffff)
   \   00006B   74..         MOV     A,#((ZDApp_NetworkInit >> 16) & 0xff)
   \   00006D   12....       LCALL   ?BCALL               ; Banked call to: DPTR()
    565          
    566            return ( networkStateNV );
   \   000070   7901         MOV     R1,#0x1
   \                     ??ZDOInitDevice_1:
   \   000072   80..         SJMP    ?Subroutine23
    567          }
    568          
    569          /*********************************************************************
    570           * @fn      ZDApp_ReadNetworkRestoreState
    571           *
    572           * @brief   Read the ZCD_NV_STARTUP_OPTION NV Item to state whether
    573           *          or not to restore the network state.
    574           *          If the read value has the ZCD_STARTOPT_DEFAULT_NETWORK_STATE
    575           *          bit set return the ZDO_INITDEV_NEW_NETWORK_STATE.
    576           *
    577           * @param   none
    578           *
    579           * @return  ZDO_INITDEV_NEW_NETWORK_STATE
    580           *          or ZDO_INITDEV_RESTORED_NETWORK_STATE based on whether or
    581           *          not ZCD_STARTOPT_DEFAULT_NETWORK_STATE bit is set in
    582           *          ZCD_NV_STARTUP_OPTION
    583           */

   \                                 In segment BANKED_CODE, align 1, keep-with-next
    584          uint8 ZDApp_ReadNetworkRestoreState( void )
   \                     ZDApp_ReadNetworkRestoreState:
    585          {
   \   000000   74F7         MOV     A,#-0x9
   \   000002   12....       LCALL   ?BANKED_ENTER_XDATA
   \   000005                ; Saved register size: 9
   \   000005                ; Auto size: 0
    586            uint8 networkStateNV = ZDO_INITDEV_RESTORED_NETWORK_STATE;
   \   000005   7E00         MOV     R6,#0x0
    587          
    588            // Look for the New Network State option.
    589            if ( zgReadStartupOptions() & ZCD_STARTOPT_DEFAULT_NETWORK_STATE )
   \   000007                ; Setup parameters for call to function zgReadStartupOptions
   \   000007   90....       MOV     DPTR,#(zgReadStartupOptions & 0xffff)
   \   00000A   74..         MOV     A,#((zgReadStartupOptions >> 16) & 0xff)
   \   00000C   12....       LCALL   ?BCALL               ; Banked call to: DPTR()
   \   00000F   E9           MOV     A,R1
   \   000010   A2E1         MOV     C,0xE0 /* A   */.1
   \   000012   5001         JNC     ??ZDApp_ReadNetworkRestoreState_0
    590            {
    591              networkStateNV = ZDO_INITDEV_NEW_NETWORK_STATE;
   \   000014   0E           INC     R6
    592            }
    593          
    594            return ( networkStateNV );
   \                     ??ZDApp_ReadNetworkRestoreState_0:
   \   000015   EE           MOV     A,R6
   \   000016   F9           MOV     R1,A
   \   000017   80..         SJMP    ??Subroutine24_0
    595          }

   \                                 In segment BANKED_CODE, align 1, keep-with-next
   \                     ?Subroutine24:
   \   000000   12....       LCALL   ?DEALLOC_XSTACK8
   \                     ??Subroutine24_0:
   \   000003   7F01         MOV     R7,#0x1
   \   000005   02....       LJMP    ?BANKED_LEAVE_XDATA
    596          
    597          /*********************************************************************
    598           * @fn      ZDAppDetermineDeviceType()
    599           *
    600           * @brief   Determines the type of device to start.  Right now
    601           *          this only works with the SOFT_START feature.  So it doesn't
    602           *          support the end device type.
    603           *
    604           *          Looks at zgDeviceLogicalType and determines what type of
    605           *          device to start. 

⌨️ 快捷键说明

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