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

📄 zdapp.lst

📁 cc2430应用实例
💻 LST
📖 第 1 页 / 共 5 页
字号:
    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   12....       LCALL   ?Subroutine6 & 0xFFFF
    514            uint8 networkStateNV = ZDO_INITDEV_NEW_NETWORK_STATE;
    515            uint16 extendedDelay = 0;
    516          
    517            devState = DEV_INIT;    // Remove the Hold state
   \                     ??CrossCallReturnLabel_11:
   \   00000D   7401         MOV     A,#0x1
   \   00000F   90....       MOV     DPTR,#devState
   \   000012   F0           MOVX    @DPTR,A
    518          
    519            // Initialize leave control logic
    520            ZDApp_LeaveCtrlInit();
   \   000013                ; Setup parameters for call to function ZDApp_LeaveCtrlInit
   \   000013   90....       MOV     DPTR,#(ZDApp_LeaveCtrlInit & 0xffff)
   \   000016   74..         MOV     A,#((ZDApp_LeaveCtrlInit >> 16) & 0xff)
   \   000018   12....       LCALL   ?BCALL               ; Banked call to: DPTR()
    521          
    522            // Check leave control reset settings
    523            ZDApp_LeaveCtrlStartup( &devState, &startDelay );
   \   00001B                ; Setup parameters for call to function ZDApp_LeaveCtrlStartup
   \   00001B   85..82       MOV     DPL,?XSP + 0
   \   00001E   85..83       MOV     DPH,?XSP + 1
   \   000021   AC82         MOV     R4,DPL
   \   000023   AD83         MOV     R5,DPH
   \   000025   7A..         MOV     R2,#(devState & 0xff)
   \   000027   7B..         MOV     R3,#((devState >> 8) & 0xff)
   \   000029   90....       MOV     DPTR,#(ZDApp_LeaveCtrlStartup & 0xffff)
   \   00002C   74..         MOV     A,#((ZDApp_LeaveCtrlStartup >> 16) & 0xff)
   \   00002E   12....       LCALL   ?BCALL               ; Banked call to: DPTR()
    524          
    525            // Leave may make the hold state come back
    526            if ( devState == DEV_HOLD )
   \   000031   90....       MOV     DPTR,#devState
   \   000034   E0           MOVX    A,@DPTR
   \   000035   7004         JNZ     ??ZDOInitDevice_0
    527              return ( ZDO_INITDEV_LEAVE_NOT_STARTED );   // Don't join - (one time).
   \   000037   7902         MOV     R1,#0x2
   \   000039   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:
   \   00003B                ; Setup parameters for call to function osal_rand
   \   00003B   90....       MOV     DPTR,#(osal_rand & 0xffff)
   \   00003E   74..         MOV     A,#((osal_rand >> 16) & 0xff)
   \   000040   12....       LCALL   ?BCALL               ; Banked call to: DPTR()
   \   000043   8A..         MOV     ?V0 + 0,R2
   \   000045   A8..         MOV     R0,?V0 + 0
   \   000047   85..82       MOV     DPL,?XSP + 0
   \   00004A   85..83       MOV     DPH,?XSP + 1
   \   00004D   747F         MOV     A,#0x7f
   \   00004F   58           ANL     A,R0
   \   000050   F8           MOV     R0,A
   \   000051   E0           MOVX    A,@DPTR
   \   000052   28           ADD     A,R0
   \   000053   F8           MOV     R0,A
   \   000054   A3           INC     DPTR
   \   000055   E0           MOVX    A,@DPTR
   \   000056   3400         ADDC    A,#0x0
   \   000058   F9           MOV     R1,A
   \   000059   7464         MOV     A,#0x64
   \   00005B   28           ADD     A,R0
   \   00005C   FA           MOV     R2,A
   \   00005D   E4           CLR     A
   \   00005E   39           ADDC    A,R1
   \   00005F   FB           MOV     R3,A
    561            }
    562          
    563            // Trigger the network start
    564            ZDApp_NetworkInit( extendedDelay );
   \   000060                ; Setup parameters for call to function ZDApp_NetworkInit
   \   000060   90....       MOV     DPTR,#(ZDApp_NetworkInit & 0xffff)
   \   000063   74..         MOV     A,#((ZDApp_NetworkInit >> 16) & 0xff)
   \   000065   12....       LCALL   ?BCALL               ; Banked call to: DPTR()
    565          
    566            return ( networkStateNV );
   \   000068   7901         MOV     R1,#0x1
   \                     ??ZDOInitDevice_1:
   \   00006A   80..         SJMP    ?Subroutine31
    567          }

   \                                 In segment BANKED_CODE, align 1, keep-with-next
   \                     ?Subroutine6:
   \   000000   85..82       MOV     DPL,?XSP + 0
   \   000003   85..83       MOV     DPH,?XSP + 1
   \                     ??Subroutine6_0:
   \   000006   EA           MOV     A,R2
   \   000007   F0           MOVX    @DPTR,A
   \   000008   A3           INC     DPTR
   \   000009   EB           MOV     A,R3
   \   00000A   F0           MOVX    @DPTR,A
   \   00000B   22           RET
    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   02....       LJMP    ?Subroutine32 & 0xFFFF
    595          }

   \                                 In segment BANKED_CODE, align 1, keep-with-next
   \                     ?Subroutine32:
   \   000000   7F01         MOV     R7,#0x1
   \   000002   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.  The types are:
    606           *            ZG_DEVICETYPE_COORDINATOR
    607           *            ZG_DEVICETYPE_ROUTER
    608           *            ZG_DEVICETYPE_ENDDEVICE - not supported yet.
    609           *            ZG_DEVICETYPE_SOFT - looks for coordinator, if one doesn't
    610           *               exist, becomes one.  This option is should only be used
    611           *               if the system is manually configured and you are insured
    612           *               that the first device is started before all the other
    613           *               devices are started.
    614           *
    615           * @param   none
    616           *
    617           * @return  none
    618           */

   \                                 In segment BANKED_CODE, align 1, keep-with-next
    619          void ZDAppDetermineDeviceType( void )
   \                     ZDAppDetermineDeviceType:
    620          {
   \   000000                ; Saved register size: 0
   \   000000                ; Auto size: 0
    621            if ( zgDeviceLogicalType == ZG_DEVICETYPE_ENDDEVICE )
   \   000000   02....       LJMP    ?BRET
    622              return;
    623          
    624          #if defined ( SOFT_START )
    625            if ( zgDeviceLogicalType == ZG_DEVICETYPE_COORDINATOR )
    626            {
    627              devStartMode = MODE_HARD;     // Start as a coordinator
    628              ZDO_Config_Node_Descriptor.LogicalType = NODETYPE_COORDINATOR;
    629            }
    630            else
    631            {
    632              if ( zgDeviceLogicalType == ZG_DEVICETYPE_ROUTER )
    633              {
    634                softStartAllowCoord = FALSE;  // Don't allow coord to start
    635                continueJoining = TRUE;
    636              }
    637              devStartMode = MODE_JOIN;     // Assume joining
    638            }
    639          #endif // SOFT_START
    640          }
    641          
    642          /*********************************************************************
    643           * @f

⌨️ 快捷键说明

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