📄 zdapp.lst
字号:
523 ZDApp_LeaveCtrlStartup( &devState, &startDelay );
\ 000027 ; Setup parameters for call to function ZDApp_LeaveCtrlStartup
\ 000027 85..82 MOV DPL,?XSP + 0
\ 00002A 85..83 MOV DPH,?XSP + 1
\ 00002D AC82 MOV R4,DPL
\ 00002F AD83 MOV R5,DPH
\ 000031 7A.. MOV R2,#(devState & 0xff)
\ 000033 7B.. MOV R3,#((devState >> 8) & 0xff)
\ 000035 90.... MOV DPTR,#(ZDApp_LeaveCtrlStartup & 0xffff)
\ 000038 74.. MOV A,#((ZDApp_LeaveCtrlStartup >> 16) & 0xff)
\ 00003A 12.... LCALL ?BCALL ; Banked call to: DPTR()
524
525 // Leave may make the hold state come back
526 if ( devState == DEV_HOLD )
\ 00003D 90.... MOV DPTR,#devState
\ 000040 E0 MOVX A,@DPTR
\ 000041 7004 JNZ ??ZDOInitDevice_0
527 return ( ZDO_INITDEV_LEAVE_NOT_STARTED ); // Don't join - (one time).
\ 000043 7902 MOV R1,#0x2
\ 000045 8061 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 )
\ ??ZDOInitDevice_0:
\ 000047 ; Setup parameters for call to function HalKeyRead
\ 000047 90.... MOV DPTR,#(HalKeyRead & 0xffff)
\ 00004A 74.. MOV A,#((HalKeyRead >> 16) & 0xff)
\ 00004C 12.... LCALL ?BCALL ; Banked call to: DPTR()
\ 00004F E9 MOV A,R1
\ 000050 6404 XRL A,#0x4
\ 000052 705E JNZ ??ZDOInitDevice_2
534 networkStateNV = ZDO_INITDEV_NEW_NETWORK_STATE;
\ 000054 75..01 MOV ?V0 + 0,#0x1
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();
\ ??ZDOInitDevice_3:
\ 000057 ; Setup parameters for call to function NLME_InitNV
\ 000057 90.... MOV DPTR,#(NLME_InitNV & 0xffff)
\ 00005A 74.. MOV A,#((NLME_InitNV >> 16) & 0xff)
\ 00005C 12.... LCALL ?BCALL ; Banked call to: DPTR()
549 NLME_SetDefaultNV();
\ 00005F ; Setup parameters for call to function NLME_SetDefaultNV
\ 00005F 90.... MOV DPTR,#(NLME_SetDefaultNV & 0xffff)
\ 000062 74.. MOV A,#((NLME_SetDefaultNV >> 16) & 0xff)
\ 000064 12.... LCALL ?BCALL ; Banked call to: DPTR()
550 ZDAppSetupProtoVersion();
\ 000067 ; Setup parameters for call to function ZDAppSetupProtoVersion
\ 000067 90.... MOV DPTR,#(ZDAppSetupProtoVersion & 0xffff)
\ 00006A 74.. MOV A,#((ZDAppSetupProtoVersion >> 16) & 0xff)
\ 00006C 12.... LCALL ?BCALL ; Banked call to: DPTR()
551 }
552 #endif
553
554 if ( networkStateNV == ZDO_INITDEV_NEW_NETWORK_STATE )
\ ??ZDOInitDevice_4:
\ 00006F 7401 MOV A,#0x1
\ 000071 65.. XRL A,?V0 + 0
\ 000073 7025 JNZ ??ZDOInitDevice_5
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));
\ 000075 ; Setup parameters for call to function osal_rand
\ 000075 90.... MOV DPTR,#(osal_rand & 0xffff)
\ 000078 74.. MOV A,#((osal_rand >> 16) & 0xff)
\ 00007A 12.... LCALL ?BCALL ; Banked call to: DPTR()
\ 00007D 8A.. MOV ?V0 + 2,R2
\ 00007F A8.. MOV R0,?V0 + 2
\ 000081 85..82 MOV DPL,?XSP + 0
\ 000084 85..83 MOV DPH,?XSP + 1
\ 000087 747F MOV A,#0x7f
\ 000089 58 ANL A,R0
\ 00008A F8 MOV R0,A
\ 00008B E0 MOVX A,@DPTR
\ 00008C 28 ADD A,R0
\ 00008D F8 MOV R0,A
\ 00008E A3 INC DPTR
\ 00008F E0 MOVX A,@DPTR
\ 000090 3400 ADDC A,#0x0
\ 000092 F9 MOV R1,A
\ 000093 7464 MOV A,#0x64
\ 000095 28 ADD A,R0
\ 000096 FE MOV R6,A
\ 000097 E4 CLR A
\ 000098 39 ADDC A,R1
\ 000099 FF MOV R7,A
561 }
562
563 // Trigger the network start
564 ZDApp_NetworkInit( extendedDelay );
\ ??ZDOInitDevice_5:
\ 00009A ; Setup parameters for call to function ZDApp_NetworkInit
\ 00009A EE MOV A,R6
\ 00009B FA MOV R2,A
\ 00009C EF MOV A,R7
\ 00009D FB MOV R3,A
\ 00009E 90.... MOV DPTR,#(ZDApp_NetworkInit & 0xffff)
\ 0000A1 74.. MOV A,#((ZDApp_NetworkInit >> 16) & 0xff)
\ 0000A3 12.... LCALL ?BCALL ; Banked call to: DPTR()
565
566 return ( networkStateNV );
\ 0000A6 A9.. MOV R1,?V0 + 0
\ ??ZDOInitDevice_1:
\ 0000A8 7402 MOV A,#0x2
\ 0000AA 12.... LCALL ?DEALLOC_XSTACK8
\ 0000AD 7F04 MOV R7,#0x4
\ 0000AF 02.... LJMP ?BANKED_LEAVE_XDATA
\ ??ZDOInitDevice_2:
\ 0000B2 ; Setup parameters for call to function ZDApp_ReadNetworkRestoreState
\ 0000B2 90.... MOV DPTR,#(ZDApp_ReadNetworkRestoreState & 0xffff)
\ 0000B5 74.. MOV A,#((ZDApp_ReadNetworkRestoreState >> 16) & 0xff)
\ 0000B7 12.... LCALL ?BCALL ; Banked call to: DPTR()
\ 0000BA E9 MOV A,R1
\ 0000BB F5.. MOV ?V0 + 0,A
\ 0000BD 7098 JNZ ??ZDOInitDevice_3
\ 0000BF ; Setup parameters for call to function ZDApp_RestoreNetworkState
\ 0000BF 90.... MOV DPTR,#(ZDApp_RestoreNetworkState & 0xffff)
\ 0000C2 74.. MOV A,#((ZDApp_RestoreNetworkState >> 16) & 0xff)
\ 0000C4 12.... LCALL ?BCALL ; Banked call to: DPTR()
\ 0000C7 E9 MOV A,R1
\ 0000C8 F5.. MOV ?V0 + 0,A
\ 0000CA 80A3 SJMP ??ZDOInitDevice_4
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 ??Subroutine25_0
595 }
\ In segment BANKED_CODE, align 1, keep-with-next
\ ?Subroutine25:
\ 000000 12.... LCALL ?DEALLOC_XSTACK8
\ ??Subroutine25_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. 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
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -