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

📄 zdobject.s51

📁 cc2430应用实例
💻 S51
📖 第 1 页 / 共 5 页
字号:
//  529     {
//  530       // Add a reference to entry
//  531       AddrMgrEntryAddRef( &addrEntry );
//  532     }
//  533     else
//  534     {
//  535       // If we have the extended address
//  536       if ( NLME_GetProtocolVersion() != ZB_PROT_V1_0 )
//  537       {
//  538         osal_cpyExtAddr( addrEntry.extAddr, bindReq->ieeeAddr );
//  539       }
//  540 
//  541       // Not in address manager?
//  542       AddrMgrEntryUpdate( &addrEntry );   // Add it
//  543     }
//  544 
//  545     if ( AddrMgrExtAddrValid( addrEntry.extAddr ) == FALSE )
//  546     {
//  547       ZDP_IEEEAddrReq( bindReq->srcAddr, ZDP_ADDR_REQTYPE_SINGLE, 0, false );
//  548     }
//  549   }
//  550 
//  551   if ( ZDO_EDBind )   // End Device Bind in progress
//  552   {
//  553     Status = ZDP_NO_MATCH;
//  554 
//  555     if ( bindReq->profileID == ZDO_EDBind->ProfileID )
//  556     {
//  557       // Check the first in against the seconds out
//  558       numMatches = ZDO_CompareClusterLists(
//  559                   ZDO_EDBind->numOutClusters, ZDO_EDBind->outClusters,
//  560                   bindReq->numInClusters, bindReq->inClusters, ZDOBuildBuf );
//  561 
//  562       if ( numMatches )
//  563       {
//  564         // if existing bind exists, remove it
//  565         pBind = bindFindExisting( &(ZDO_EDBind->SrcAddr), ZDO_EDBind->epIntf,
//  566                       &SrcAddr, bindReq->endpoint );
//  567         if ( pBind )
//  568         {
//  569           bindRemoveEntry( pBind );
//  570           Status = ZDP_SUCCESS;
//  571         }
//  572         // else add new binding table entry
//  573         else if ( bindAddEntry( &(ZDO_EDBind->SrcAddr), ZDO_EDBind->epIntf,
//  574                       &SrcAddr, bindReq->endpoint, numMatches, ZDOBuildBuf ) )
//  575           Status = ZDP_SUCCESS;
//  576         else
//  577           Status = ZDP_TABLE_FULL;
//  578       }
//  579 
//  580       // Check the second in against the first out
//  581       numMatches = ZDO_CompareClusterLists( bindReq->numOutClusters, bindReq->outClusters,
//  582                       ZDO_EDBind->numInClusters, ZDO_EDBind->inClusters,
//  583                       ZDOBuildBuf );
//  584 
//  585       if ( numMatches )
//  586       {
//  587         // if existing bind exists, remove it
//  588         pBind = bindFindExisting( &SrcAddr, bindReq->endpoint, &(ZDO_EDBind->SrcAddr),
//  589                       ZDO_EDBind->epIntf );
//  590         if ( pBind )
//  591         {
//  592           bindRemoveEntry( pBind );
//  593           Status = ZDP_SUCCESS;
//  594         }
//  595         // else add new binding table entry
//  596         else if ( bindAddEntry( &SrcAddr, bindReq->endpoint, &(ZDO_EDBind->SrcAddr),
//  597                       ZDO_EDBind->epIntf, numMatches, ZDOBuildBuf ) )
//  598           Status = ZDP_SUCCESS;
//  599         else
//  600           Status = ZDP_TABLE_FULL;
//  601       }
//  602     }
//  603 
//  604     if ( Status == ZDP_SUCCESS )
//  605     {
//  606       // We've found a match, so we don't have to wait for the timeout
//  607       APS_SetEndDeviceBindTimeout( 10, ZDO_EndDeviceTimeoutCB );  // psuedo stop end device timeout
//  608 
//  609         // Notify to save info into NV
//  610       osal_start_timerEx( ZDAppTaskID, ZDO_NWK_UPDATE_NV, 250 );
//  611     }
//  612 
//  613     ZDO_EDBind->status = Status;
//  614 
//  615     // Send the response message to the device sending this message
//  616     ZDO_SendEDBindRsp( bindReq->TransSeq, &SrcAddr, Status, bindReq->SecurityUse );
//  617   }
//  618   else  // Start a new End Device Bind
//  619   {
//  620     // Copy the info
//  621     ZDO_EDBind = osal_mem_alloc( sizeof( ZDO_EDBind_t ) );
//  622     if ( ZDO_EDBind )
//  623     {
//  624       osal_memcpy( &(ZDO_EDBind->SrcAddr), &SrcAddr, sizeof( zAddrType_t ) );
//  625       ZDO_EDBind->LocalCoordinator = bindReq->localCoordinator;
//  626       ZDO_EDBind->epIntf = bindReq->endpoint;
//  627       ZDO_EDBind->ProfileID = bindReq->profileID;
//  628       ZDO_EDBind->SrcTransSeq = bindReq->TransSeq;
//  629 
//  630       ZDO_EDBind->numInClusters = bindReq->numInClusters;
//  631       if ( bindReq->numInClusters )
//  632       {
//  633         ZDO_EDBind->inClusters = osal_mem_alloc( (short)(bindReq->numInClusters * sizeof(uint16)) );
//  634         if ( ZDO_EDBind->inClusters )
//  635         {
//  636           osal_memcpy( ZDO_EDBind->inClusters, bindReq->inClusters, (bindReq->numInClusters * sizeof( uint16 )) );
//  637         }
//  638         else
//  639         {
//  640           // Force no clusters
//  641           ZDO_EDBind->numInClusters = 0;
//  642         }
//  643       }
//  644       else
//  645         ZDO_EDBind->inClusters = NULL;
//  646 
//  647       ZDO_EDBind->numOutClusters = bindReq->numOutClusters;
//  648       if ( bindReq->numOutClusters )
//  649       {
//  650         ZDO_EDBind->outClusters = osal_mem_alloc( (short)(bindReq->numOutClusters*sizeof(uint16)) );
//  651         if ( ZDO_EDBind->outClusters )
//  652         {
//  653           osal_memcpy( ZDO_EDBind->outClusters, bindReq->outClusters, (bindReq->numOutClusters * sizeof( uint16 )) );
//  654         }
//  655         else
//  656         {
//  657           ZDO_EDBind->numOutClusters = 0;
//  658         }
//  659       }
//  660       else
//  661         ZDO_EDBind->outClusters = NULL;
//  662 
//  663       ZDO_EDBind->SecurityUse = bindReq->SecurityUse;
//  664       ZDO_EDBind->status = ZDP_TIMEOUT;
//  665 
//  666       // Setup the timer
//  667       APS_SetEndDeviceBindTimeout( AIB_MaxBindingTime, ZDO_EndDeviceTimeoutCB );
//  668     }
//  669   }
//  670 }
//  671 #endif // REFLECTOR
//  672 
//  673 /*********************************************************************
//  674  * Utility functions
//  675  */
//  676 
//  677 /*********************************************************************
//  678  * @fn          ZDO_CreateAlignedUINT16List
//  679  *
//  680  * @brief       Creates a list of cluster IDs that is guaranteed to be aligned.
//  681  *              according to the needs of the target. If thre device is running
//  682  *              Protocol version 1.0 the incoming buffer will have only a single
//  683  *              byte for the cluster ID.
//  684  *
//  685  *              Depends on the malloc taking care of alignment.
//  686  *
//  687  *              When cluster ID went to 16 bits alignment for cluster IDs became
//  688  *              an issue.
//  689  *
//  690  * @param       num  - number of entries in list
//  691  * @param       buf  - pointer to list
//  692  *
//  693  * @return      pointer to aligned list. Null if can't allocate memory.
//  694  *              Caller's responsibility to free memory.
//  695  */

        RSEG BANKED_CODE:CODE:NOROOT(0)
//  696 static uint16 *ZDO_CreateAlignedUINT16List(uint8 num, uint8 *buf)
??ZDO_CreateAlignedUINT16List:
        CFI Block cfiBlock7 Using cfiCommon0
        CFI Function ??ZDO_CreateAlignedUINT16List
//  697 {
        FUNCALL ??ZDO_CreateAlignedUINT16List, osal_mem_alloc
        LOCFRAME XSTACK, 14, STACK
        ARGFRAME XSTACK, 14, STACK
        FUNCALL ??ZDO_CreateAlignedUINT16List, NLME_GetProtocolVersion
        LOCFRAME XSTACK, 14, STACK
        ARGFRAME XSTACK, 14, STACK
        MOV	A,#-0xe
        LCALL	?BANKED_ENTER_XDATA
        CFI DPH0 load(1, XDATA, add(CFA_XSP16, literal(-1)))
        CFI DPL0 load(1, XDATA, add(CFA_XSP16, literal(-2)))
        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)))
        CFI R7 load(1, XDATA, add(CFA_XSP16, literal(-6)))
        CFI V5 load(1, XDATA, add(CFA_XSP16, literal(-7)))
        CFI V4 load(1, XDATA, add(CFA_XSP16, literal(-8)))
        CFI V3 load(1, XDATA, add(CFA_XSP16, literal(-9)))
        CFI V2 load(1, XDATA, add(CFA_XSP16, literal(-10)))
        CFI V1 load(1, XDATA, add(CFA_XSP16, literal(-11)))
        CFI V0 load(1, XDATA, add(CFA_XSP16, literal(-12)))
        CFI VB load(1, XDATA, add(CFA_XSP16, literal(-13)))
        CFI R6 load(1, XDATA, add(CFA_XSP16, literal(-14)))
        CFI CFA_SP SP+0
        CFI CFA_XSP16 add(XSP16, 14)
        ; Saved register size: 14
        ; Auto size: 0
        MOV	?V0 + 2,R1
        MOV	A,R2
        MOV	R6,A
        MOV	A,R3
        MOV	R7,A
//  698   uint16 *ptr;
//  699 
//  700   if ((ptr=osal_mem_alloc((short)(num*sizeof(uint16)))))  {
        ; Setup parameters for call to function osal_mem_alloc
        MOV	A,R1
        CLR	C
        RLC	A
        MOV	R2,A
        CLR	A
        RLC	A
        MOV	R3,A
        MOV	DPTR,#(osal_mem_alloc & 0xffff)
        MOV	A,#((osal_mem_alloc >> 16) & 0xff)
        LCALL	?BCALL               ; Banked call to: DPTR()
        MOV	?V0 + 0,R2
        MOV	?V0 + 1,R3
        MOV	A,R2
        JNZ	??ZDO_CreateAlignedUINT16List_1
        MOV	A,R3
??ZDO_CreateAlignedUINT16List_1:
        JZ	??ZDO_CreateAlignedUINT16List_2
//  701     uint8 i, ubyte, inc;
//  702 
//  703     inc = (ZB_PROT_V1_1 == NLME_GetProtocolVersion()) ? 2 : 1;
        ; Setup parameters for call to function NLME_GetProtocolVersion
        MOV	DPTR,#(NLME_GetProtocolVersion & 0xffff)
        MOV	A,#((NLME_GetProtocolVersion >> 16) & 0xff)
        LCALL	?BCALL               ; Banked call to: DPTR()
        MOV	A,R1
        XRL	A,#0x2
        JNZ	??ZDO_CreateAlignedUINT16List_3
        MOV	R3,#0x2
        SJMP	??ZDO_CreateAlignedUINT16List_4
??ZDO_CreateAlignedUINT16List_3:
        MOV	R3,#0x1
//  704 
//  705     for (i=0; i<num; ++i)  {
??ZDO_CreateAlignedUINT16List_4:
        MOV	R2,#0x0
        SJMP	??ZDO_CreateAlignedUINT16List_5
//  706       // set upper byte to 0 if we're talking Version 1.0. otherwise
//  707       // the buffer contains 16 bit cluster IDs.
//  708       ubyte  = (2 == inc) ? buf[1] : 0;
??ZDO_CreateAlignedUINT16List_6:
        MOV	?V0 + 3,#0x0
//  709       ptr[i] = BUILD_UINT16(buf[0], ubyte);
??ZDO_CreateAlignedUINT16List_7:
        MOV	DPL,R6
        MOV	DPH,R7
        MOVX	A,@DPTR
        MOV	R4,A
        CLR	A
        ADD	A,R4
        MOV	A,?V0 + 3
        ADDC	A,#0x0
        MOV	R5,A
        MOV	A,R2
        CLR	C
        RLC	A
        MOV	R0,A
        CLR	A
        RLC	A
        MOV	R1,A
        MOV	A,?V0 + 0
        ADD	A,R0
        MOV	DPL,A
        MOV	A,?V0 + 1
        ADDC	A,R1
        MOV	DPH,A
        MOV	A,R4
        MOVX	@DPTR,A
        INC	DPTR
        MOV	A,R5
        MOVX	@DPTR,A
//  710       buf    += inc;
        MOV	?V0 + 4,R3
        MOV	A,R6
        ADD	A,?V0 + 4
        MOV	R6,A
        MOV	A,R7
        ADDC	A,#0x0
        MOV	R7,A
        INC	R2
??ZDO_CreateAlignedUINT16List_5:
        MOV	A,R2
        CLR	C
        SUBB	A,?V0 + 2
        JNC	??ZDO_CreateAlignedUINT16List_2
        MOV	A,#0x2
        XRL	A,R3
        JNZ	??ZDO_CreateAlignedUINT16List_6
        MOV	DPL,R6
        MOV	DPH,R7
        INC	DPTR
        MOVX	A,@DPTR
        MOV	?V0 + 3,A
        SJMP	??ZDO_CreateAlignedUINT16List_7
//  711     }
//  712   }
//  713 
//  714   return ptr;
??ZDO_CreateAlignedUINT16List_2:
        MOV	R2,?V0 + 0
        MOV	R3,?V0 + 1
        CFI EndBlock cfiBlock7
        REQUIRE ?Subroutine24
        ; // Fall through to label ?Subroutine24
//  715 }

        RSEG BANKED_CODE:CODE:NOROOT(0)
?Subroutine24:
        CFI Block cfiBlock8 Using cfiCommon0
        CFI NoFunction
        CFI CFA_SP SP+0
        CFI CFA_XSP16 add(XSP16, 14)
        CFI VB load(1, XDATA, add(CFA_XSP16, literal(-13)))
        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(-14)))
        CFI R7 load(1, XDATA, add(CFA_XSP16, literal(-6)))
        CFI V0 load(1, XDATA, add(CFA_XSP16, literal(-12)))
        CFI V1 load(1, XDATA, add(CFA_XSP16, literal(-11)))
        CFI V2 load(1, XDATA, add(CFA_XSP16, literal(-10)))
        CFI V3 load(1, XDATA, add(CFA_XSP16, literal(-9)))
        CFI V4 

⌨️ 快捷键说明

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