📄 zdapp.lst
字号:
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 02.... LJMP ?Subroutine24 & 0xFFFF
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
642 /*********************************************************************
643 * @fn ZDApp_NetworkStartEvt()
644 *
645 * @brief Process the Network Start Event
646 *
647 * @param none
648 *
649 * @return none
650 */
\ In segment BANKED_CODE, align 1, keep-with-next
651 void ZDApp_NetworkStartEvt( void )
\ ZDApp_NetworkStartEvt:
652 {
\ 000000 C082 PUSH DPL
\ 000002 C083 PUSH DPH
\ 000004 ; Saved register size: 2
\ 000004 ; Auto size: 0
653 if ( nwkStatus == ZSuccess )
\ 000004 90.... MOV DPTR,#nwkStatus
\ 000007 E0 MOVX A,@DPTR
\ 000008 7017 JNZ ??ZDApp_NetworkStartEvt_0
654 {
655 // Successfully started a ZigBee network
656 if ( devState == DEV_COORD_STARTING )
\ 00000A 90.... MOV DPTR,#devState
\ 00000D E0 MOVX A,@DPTR
\ 00000E 6408 XRL A,#0x8
\ 000010 7003 JNZ ??ZDApp_NetworkStartEvt_1
657 {
658 devState = DEV_ZB_COORD;
\ 000012 7409 MOV A,#0x9
\ 000014 F0 MOVX @DPTR,A
659
660 #if ( SECURE != 0 )
661 // Initialize keys
662 SSP_UpdateNwkKey( (byte*)zgPreConfigKey, 0 );
663 SSP_SwitchNwkKey( 0 );
664 #endif
665 }
666
667 osal_pwrmgr_device( PWRMGR_ALWAYS_ON );
\ ??ZDApp_NetworkStartEvt_1:
\ 000015 ; Setup parameters for call to function osal_pwrmgr_device
\ 000015 7900 MOV R1,#0x0
\ 000017 90.... MOV DPTR,#(osal_pwrmgr_device & 0xffff)
\ 00001A 74.. MOV A,#((osal_pwrmgr_device >> 16) & 0xff)
\ 00001C 12.... LCALL ?BCALL ; Banked call to: DPTR()
668 osal_set_event( ZDAppTaskID, ZDO_STATE_CHANGE_EVT );
\ 00001F ; Setup parameters for call to function osal_set_event
\ 00001F 8039 SJMP ??ZDApp_NetworkStartEvt_2
669 }
670 else
671 {
672 // Try again with a higher energy threshold !!
673 if ( ( NLME_GetEnergyThreshold() + ENERGY_SCAN_INCREMENT ) < 0xff )
\ ??ZDApp_NetworkStartEvt_0:
\ 000021 ; Setup parameters for call to function NLME_GetEnergyThreshold
\ 000021 90.... MOV DPTR,#(NLME_GetEnergyThreshold & 0xffff)
\ 000024 74.. MOV A,#((NLME_GetEnergyThreshold >> 16) & 0xff)
\ 000026 12.... LCALL ?BCALL ; Banked call to: DPTR()
\ 000029 E9 MOV A,R1
\ 00002A F8 MOV R0,A
\ 00002B 7410 MOV A,#0x10
\ 00002D 28 ADD A,R0
\ 00002E F8 MOV R0,A
\ 00002F E4 CLR A
\ 000030 3400 ADDC A,#0x0
\ 000032 F9 MOV R1,A
\ 0000
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -