zdapp.lst

来自「cc2430应用实例」· LST 代码 · 共 1,256 行 · 第 1/5 页

LST
1,256
字号
    370              ZDApp_NetworkStartEvt();
    371          
    372              // Return unprocessed events
    373              return (events ^ ZDO_NETWORK_START);
    374            }
    375          #endif  //RTR_NWK
    376          
    377          #if defined ( RTR_NWK )
    378            if ( events & ZDO_ROUTER_START )
    379            {
    380              if ( nwkStatus == ZSuccess )
    381              {
    382                if ( devState == DEV_END_DEVICE )
    383                  devState = DEV_ROUTER;
    384          
    385                osal_pwrmgr_device( PWRMGR_ALWAYS_ON );
    386              }
    387              else
    388              {
    389                // remain as end device!!
    390              }
    391              osal_set_event( ZDAppTaskID, ZDO_STATE_CHANGE_EVT );
    392          
    393              // Return unprocessed events
    394              return (events ^ ZDO_ROUTER_START);
    395            }
    396          #endif  // RTR
    397          
    398            if ( events & ZDO_STATE_CHANGE_EVT )
   \                     ??ZDApp_event_loop_2:
   \   000070   5410         ANL     A,#0x10
   \   000072   6011         JZ      ??ZDApp_event_loop_9
    399            {
    400              ZDO_UpdateNwkStatus( devState );
   \   000074                ; Setup parameters for call to function ZDO_UpdateNwkStatus
   \   000074   90....       MOV     DPTR,#devState
   \   000077   E0           MOVX    A,@DPTR
   \   000078   F9           MOV     R1,A
   \   000079   90....       MOV     DPTR,#(ZDO_UpdateNwkStatus & 0xffff)
   \   00007C   74..         MOV     A,#((ZDO_UpdateNwkStatus >> 16) & 0xff)
   \   00007E   12....       LCALL   ?BCALL               ; Banked call to: DPTR()
    401          
    402              // Return unprocessed events
    403              return (events ^ ZDO_STATE_CHANGE_EVT);
   \   000081   7410         MOV     A,#0x10
   \   000083   80B3         SJMP    ??ZDApp_event_loop_3
    404            }
    405          
    406            if ( events & ZDO_COMMAND_CNF )
   \                     ??ZDApp_event_loop_9:
   \   000085   EE           MOV     A,R6
   \   000086   5408         ANL     A,#0x8
   \   000088   6006         JZ      ??ZDApp_event_loop_10
    407            {
    408              // User defined logic
    409          
    410              // Return unprocessed events
    411              return (events ^ ZDO_COMMAND_CNF);
   \   00008A   7408         MOV     A,#0x8
   \   00008C   6E           XRL     A,R6
   \   00008D   FA           MOV     R2,A
   \   00008E   8022         SJMP    ??ZDApp_event_loop_5
    412            }
    413          
    414          #if defined( ZDSECMGR_SECURE ) && defined( RTR_NWK )
    415            if ( events & ZDO_NEW_DEVICE )
    416            {
    417              // process the new device event
    418              if ( ZDSecMgrNewDeviceEvent() == TRUE )
    419              {
    420                osal_start_timerEx( ZDAppTaskID, ZDO_NEW_DEVICE, 1000 );
    421              }
    422          
    423              // Return unprocessed events
    424              return (events ^ ZDO_NEW_DEVICE);
    425            }
    426          #endif  // ZDSECMGR_SECURE && RTR
    427          
    428          #if defined ( ZDSECMGR_COMMERCIAL )
    429            if ( events & ZDO_SECMGR_EVENT )
    430            {
    431              ZDSecMgrEvent();
    432          
    433              // Return unprocessed events
    434              return (events ^ ZDO_SECMGR_EVENT);
    435            }
    436          #endif // defined( ZDSECMGR_COMMERCIAL )
    437          
    438          #if   ( SECURE != 0  )
    439            if ( events & ZDO_DEVICE_AUTH )
    440            {
    441              ZDApp_DeviceAuthEvt();
    442          
    443              // Return unprocessed events
    444              return (events ^ ZDO_DEVICE_AUTH);
    445            }
    446          #endif  // SECURE
    447          
    448            if ( events & ZDO_NWK_UPDATE_NV )
   \                     ??ZDApp_event_loop_10:
   \   000090   7402         MOV     A,#0x2
   \   000092   5F           ANL     A,R7
   \   000093   F9           MOV     R1,A
   \   000094   E4           CLR     A
   \   000095   7001         JNZ     ??ZDApp_event_loop_11
   \   000097   E9           MOV     A,R1
   \                     ??ZDApp_event_loop_11:
   \   000098   6004         JZ      ??ZDApp_event_loop_12
    449            {
    450              ZDApp_SaveNetworkStateEvt();
    451          
    452              // Return unprocessed events
    453              return (events ^ ZDO_NWK_UPDATE_NV);
   \   00009A   7402         MOV     A,#0x2
   \   00009C   80CF         SJMP    ??ZDApp_event_loop_8
    454            }
    455          
    456          #if ( SECURE != 0  )
    457            if ( events & ZDO_FRAMECOUNTER_CHANGE )
    458            {
    459              if ( nwkFrameCounterChanges++ > MAX_NWK_FRAMECOUNTER_CHANGES )
    460                ZDApp_SaveNwkKey();
    461          
    462              // Return unprocessed events
    463              return (events ^ ZDO_FRAMECOUNTER_CHANGE);
    464            }
    465          #endif
    466          
    467            if ( events & ZDO_DEVICE_RESET )
   \                     ??ZDApp_event_loop_12:
   \   00009E   EE           MOV     A,R6
   \   00009F   5404         ANL     A,#0x4
   \   0000A1   600B         JZ      ??ZDApp_event_loop_13
    468            {
    469              // The device has been in the UNAUTH state, so reset
    470              // Note: there will be no return from this call
    471              SystemReset();
   \   0000A3   C2AF         CLR     0xa8.7
   \   0000A5   75C9AB       MOV     0xc9,#-0x55
   \   0000A8   75C95B       MOV     0xc9,#0x5b
   \                     ??ZDApp_event_loop_14:
   \   0000AB   00           NOP
   \   0000AC   80FD         SJMP    ??ZDApp_event_loop_14
    472            }
    473          
    474            // Discard or make more handlers
    475            return 0;
   \                     ??ZDApp_event_loop_13:
   \   0000AE   7A00         MOV     R2,#0x0
   \   0000B0   7B00         MOV     R3,#0x0
   \                     ??ZDApp_event_loop_5:
   \   0000B2   02....       LJMP    ??Subroutine24_1 & 0xFFFF
    476          }

   \                                 In segment BANKED_CODE, align 1, keep-with-next
   \                     ?Subroutine24:
   \   000000   7402         MOV     A,#0x2
   \                     ??Subroutine24_0:
   \   000002   12....       LCALL   ?DEALLOC_XSTACK8
   \                     ??Subroutine24_1:
   \   000005   7F02         MOV     R7,#0x2
   \   000007   02....       LJMP    ?BANKED_LEAVE_XDATA
    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          

⌨️ 快捷键说明

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