zdapp.s51

来自「CC2430上开关控制灯和温度传感器采集两个例子」· S51 代码 · 共 1,698 行 · 第 1/5 页

S51
1,698
字号
        MOV	R7,A
//  340   uint8 *msg_ptr;
//  341 
//  342   if ( events & SYS_EVENT_MSG )
        MOV	A,#-0x80
        ANL	A,R7
        MOV	R1,A
        CLR	A
        JNZ	??ZDApp_event_loop_0
        MOV	A,R1
??ZDApp_event_loop_0:
        JNZ	??ZDApp_event_loop_1
//  343   {
//  344     while ( (msg_ptr = osal_msg_receive( ZDAppTaskID )) )
//  345     {
//  346       ZDApp_ProcessOSALMsg( (osal_event_hdr_t *)msg_ptr );
//  347 
//  348       // Release the memory
//  349       osal_msg_deallocate( msg_ptr );
//  350     }
//  351 
//  352     // Return unprocessed events
//  353     return (events ^ SYS_EVENT_MSG);
//  354   }
//  355 
//  356   if ( events & ZDO_NETWORK_INIT )
        MOV	A,R6
        MOV	C,0xE0 /* A   */.0
        JNC	??ZDApp_event_loop_2
//  357   {
//  358     // Initialize apps and start the network
//  359     devState = DEV_INIT;
        MOV	A,#0x1
        MOV	DPTR,#devState
        MOVX	@DPTR,A
//  360     ZDO_StartDevice( (uint8)ZDO_Config_Node_Descriptor.LogicalType, devStartMode,
//  361                      DEFAULT_BEACON_ORDER, DEFAULT_SUPERFRAME_ORDER );
        ; Setup parameters for call to function ZDO_StartDevice
        MOV	R4,#0xf
        MOV	R3,#0xf
        MOV	DPTR,#devStartMode
        MOVX	A,@DPTR
        MOV	R2,A
        MOV	DPTR,#ZDO_Config_Node_Descriptor
        MOVX	A,@DPTR
        ANL	A,#0x7
        MOV	R1,A
        MOV	DPTR,#(ZDO_StartDevice & 0xffff)
        MOV	A,#((ZDO_StartDevice >> 16) & 0xff)
        LCALL	?BCALL               ; Banked call to: DPTR()
//  362 
//  363     // Return unprocessed events
//  364     return (events ^ ZDO_NETWORK_INIT);
        MOV	A,#0x1
??ZDApp_event_loop_3:
        XRL	A,R6
        MOV	R2,A
        MOV	A,R7
??ZDApp_event_loop_4:
        MOV	R3,A
        LJMP	??ZDApp_event_loop_5 & 0xFFFF
//  365   }
??ZDApp_event_loop_6:
        ; Setup parameters for call to function ZDApp_ProcessOSALMsg
        MOV	DPTR,#(ZDApp_ProcessOSALMsg & 0xffff)
        MOV	A,#((ZDApp_ProcessOSALMsg >> 16) & 0xff)
        LCALL	?BCALL               ; Banked call to: DPTR()
        ; Setup parameters for call to function osal_msg_deallocate
        MOV	R2,?V0 + 0
        MOV	R3,?V0 + 1
        MOV	DPTR,#(osal_msg_deallocate & 0xffff)
        MOV	A,#((osal_msg_deallocate >> 16) & 0xff)
        LCALL	?BCALL               ; Banked call to: DPTR()
??ZDApp_event_loop_1:
        ; Setup parameters for call to function osal_msg_receive
        MOV	DPTR,#ZDAppTaskID
        MOVX	A,@DPTR
        MOV	R1,A
        MOV	DPTR,#(osal_msg_receive & 0xffff)
        MOV	A,#((osal_msg_receive >> 16) & 0xff)
        LCALL	?BCALL               ; Banked call to: DPTR()
        MOV	?V0 + 0,R2
        MOV	?V0 + 1,R3
        MOV	A,R2
        JNZ	??ZDApp_event_loop_7
        MOV	A,R3
??ZDApp_event_loop_7:
        JNZ	??ZDApp_event_loop_6
        MOV	A,R6
        MOV	R2,A
        MOV	A,#-0x80
??ZDApp_event_loop_8:
        XRL	A,R7
        SJMP	??ZDApp_event_loop_4
//  366 
//  367 #if defined (RTR_NWK)
//  368   if ( events & ZDO_NETWORK_START )
??ZDApp_event_loop_2:
        ANL	A,#0x2
        JZ	??ZDApp_event_loop_9
//  369   {
//  370     ZDApp_NetworkStartEvt();
        ; Setup parameters for call to function ZDApp_NetworkStartEvt
        MOV	DPTR,#(ZDApp_NetworkStartEvt & 0xffff)
        MOV	A,#((ZDApp_NetworkStartEvt >> 16) & 0xff)
        LCALL	?BCALL               ; Banked call to: DPTR()
//  371 
//  372     // Return unprocessed events
//  373     return (events ^ ZDO_NETWORK_START);
        MOV	A,#0x2
??ZDApp_event_loop_10:
        SJMP	??ZDApp_event_loop_3
//  374   }
//  375 #endif  //RTR_NWK
//  376 
//  377 #if defined ( RTR_NWK )
//  378   if ( events & ZDO_ROUTER_START )
??ZDApp_event_loop_9:
        MOV	A,R6
        ANL	A,#0x20
        JZ	??ZDApp_event_loop_11
//  379   {
//  380     if ( nwkStatus == ZSuccess )
        MOV	DPTR,#nwkStatus
        MOVX	A,@DPTR
        JNZ	??ZDApp_event_loop_12
//  381     {
//  382       if ( devState == DEV_END_DEVICE )
        MOV	DPTR,#devState
        MOVX	A,@DPTR
        XRL	A,#0x6
        JNZ	??ZDApp_event_loop_13
//  383         devState = DEV_ROUTER;
        MOV	A,#0x7
        MOVX	@DPTR,A
//  384 
//  385       osal_pwrmgr_device( PWRMGR_ALWAYS_ON );
??ZDApp_event_loop_13:
        ; Setup parameters for call to function osal_pwrmgr_device
        MOV	R1,#0x0
        MOV	DPTR,#(osal_pwrmgr_device & 0xffff)
        MOV	A,#((osal_pwrmgr_device >> 16) & 0xff)
        LCALL	?BCALL               ; Banked call to: DPTR()
//  386     }
//  387     else
//  388     {
//  389       // remain as end device!!
//  390     }
//  391     osal_set_event( ZDAppTaskID, ZDO_STATE_CHANGE_EVT );
??ZDApp_event_loop_12:
        ; Setup parameters for call to function osal_set_event
        LCALL	?Subroutine9 & 0xFFFF
??CrossCallReturnLabel_94:
        LCALL	?BCALL               ; Banked call to: DPTR()
//  392 
//  393     // Return unprocessed events
//  394     return (events ^ ZDO_ROUTER_START);
        MOV	A,#0x20
        SJMP	??ZDApp_event_loop_3
//  395   }
//  396 #endif  // RTR
//  397 
//  398   if ( events & ZDO_STATE_CHANGE_EVT )
??ZDApp_event_loop_11:
        MOV	A,R6
        ANL	A,#0x10
        JZ	??ZDApp_event_loop_14
//  399   {
//  400     ZDO_UpdateNwkStatus( devState );
        ; Setup parameters for call to function ZDO_UpdateNwkStatus
        MOV	DPTR,#devState
        MOVX	A,@DPTR
        MOV	R1,A
        MOV	DPTR,#(ZDO_UpdateNwkStatus & 0xffff)
        MOV	A,#((ZDO_UpdateNwkStatus >> 16) & 0xff)
        LCALL	?BCALL               ; Banked call to: DPTR()
//  401 
//  402     // Return unprocessed events
//  403     return (events ^ ZDO_STATE_CHANGE_EVT);
        MOV	A,#0x10
        SJMP	??ZDApp_event_loop_10
//  404   }
//  405 
//  406   if ( events & ZDO_COMMAND_CNF )
??ZDApp_event_loop_14:
        MOV	A,R6
        ANL	A,#0x8
        JZ	??ZDApp_event_loop_15
//  407   {
//  408     // User defined logic
//  409 
//  410     // Return unprocessed events
//  411     return (events ^ ZDO_COMMAND_CNF);
        MOV	A,#0x8
        XRL	A,R6
        MOV	R2,A
        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_15:
        MOV	A,#0x2
        ANL	A,R7
        MOV	R1,A
        CLR	A
        JNZ	??ZDApp_event_loop_16
        MOV	A,R1
??ZDApp_event_loop_16:
        JZ	??ZDApp_event_loop_17
//  449   {
//  450     ZDApp_SaveNetworkStateEvt();
//  451 
//  452     // Return unprocessed events
//  453     return (events ^ ZDO_NWK_UPDATE_NV);
        MOV	A,#0x2
        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_17:
        MOV	A,R6
        ANL	A,#0x4
        JZ	??ZDApp_event_loop_18
//  468   {
//  469     // The device has been in the UNAUTH state, so reset
//  470     // Note: there will be no return from this call
//  471     SystemReset();
        CLR	0xa8.7
        MOV	0xc9,#-0x55
        MOV	0xc9,#0x5b
??ZDApp_event_loop_19:
        NOP
        SJMP	??ZDApp_event_loop_19
//  472   }
//  473 
//  474   // Discard or make more handlers
//  475   return 0;
??ZDApp_event_loop_18:
        MOV	R2,#0x0
        MOV	R3,#0x0
??ZDApp_event_loop_5:
        SJMP	??Subroutine35_1
        CFI EndBlock cfiBlock1
//  476 }

        RSEG BANKED_CODE:CODE:NOROOT(0)
?Subroutine35:
        CFI Block cfiBlock2 Using cfiCommon0
        CFI NoFunction
        CFI CFA_SP SP+0
        CFI CFA_XSP16 add(XSP16, 12)
        CFI VB load(1, XDATA, add(CFA_XSP16, literal(-9)))
        CFI DPL0 load(1, XDATA, add(CFA_XSP16, literal(-2)))
        CFI DPH0 load(1, XDATA, add(CFA_XSP16, literal(-1)))
        CFI R6 load(1, XDATA, add(CFA_XSP16, literal(-10)))
        CFI R7 load(1, XDATA, add(CFA_XSP16, literal(-6)))
        CFI V0 load(1, XDATA, add(CFA_XSP16, literal(-8)))
        CFI V1 load(1, XDATA, add(CFA_XSP16, literal(-7)))
        CFI ?BRET_EXT load(1, XDATA, add(CFA_XSP16, literal(-3)))
        CFI ?RET_HIGH load(1, XDATA, add(CFA_XSP16, literal(-4)))
        CFI ?RET_LOW load(1, XDATA, add(CFA_XSP16, literal(-5)))
        MOV	A,#0x2
??Subroutine35_0:
        LCALL	?DEALLOC_XSTACK8
        CFI CFA_XSP16 add(XSP16, 10)
??Subroutine35_1:
        MOV	R7,#0x2
        LJMP	?BANKED_LEAVE_XDATA
        CFI EndBlock cfiBlock2
//  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.
//

⌨️ 快捷键说明

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