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

📄 zdcache.s51

📁 用IAR开发的ZIGBEE网络路由例子
💻 S51
📖 第 1 页 / 共 4 页
字号:
//////////////////////////////////////////////////////////////////////////////
//                                                                           /
// IAR 8051 C/C++ Compiler V7.20H/W32                  06/Nov/2008  11:13:14 /
// Copyright 2004-2006 IAR Systems. All rights reserved.                     /
//                                                                           /
//    Core               =  plain                                            /
//    Code model         =  banked                                           /
//    Data model         =  large                                            /
//    Calling convention =  xdata reentrant                                  /
//    Constant location  =  data                                             /
//    Dptr setup         =  1,16                                             /
//    Source file        =  E:\解决\路由\Components\stack\zdo\ZDCache.c      /
//    Command line       =  -f E:\解决\路由\Projects\zstack\Samples\SampleAp /
//                          p\CC2430DB\..\..\..\Tools\CC2430DB\f8wCoord.cfg  /
//                          (-DCPU32MHZ -DFORCE_MAC_NEAR -DROOT=__near_func  /
//                          -DMAC_CFG_APP_PENDING_QUEUE=TRUE                 /
//                          -DZDO_COORDINATOR -DRTR_NWK -DBLINK_LEDS         /
//                          "-DCONST=const __code" -DGENERIC=__generic) -f   /
//                          E:\解决\路由\Projects\zstack\Samples\SampleApp\C /
//                          C2430DB\..\..\..\Tools\CC2430DB\f8wConfig.cfg    /
//                          (-DSECURE=0 -DDEFAULT_CHANLIST=0x00000800        /
//                          -DZDAPP_CONFIG_PAN_ID=0xFFFF                     /
//                          -DNWK_START_DELAY=100 -DEXTENDED_JOINING_RANDOM_ /
//                          MASK=0x007F -DBEACON_REQUEST_DELAY=100           /
//                          -DBEACON_REQ_DELAY_MASK=0x00FF                   /
//                          -DROUTE_EXPIRY_TIME=30 -DAPSC_ACK_WAIT_DURATION_ /
//                          POLLED=3000 -DNWK_INDIRECT_MSG_TIMEOUT=7         /
//                          -DMAX_RREQ_ENTRIES=10 -DAPSC_MAX_FRAME_RETRIES=3 /
//                           -DNWK_MAX_DATA_RETRIES=2                        /
//                          -DMAX_POLL_FAILURE_RETRIES=2 -DMAX_BCAST=9       /
//                          -DAPS_MAX_GROUPS=16 -DMAX_RTG_ENTRIES=20         /
//                          -DNWK_MAX_BINDING_ENTRIES=10                     /
//                          -DMAX_BINDING_CLUSTER_IDS=5                      /
//                          "-DDEFAULT_KEY={0x01, 0x03, 0x05, 0x07, 0x09,    /
//                          0x0B, 0x0D, 0x0F, 0x00, 0x02, 0x04, 0x06, 0x08,  /
//                          0x0A, 0x0C, 0x0D}" -DRFD_RCVC_ALWAYS_ON=FALSE    /
//                          -DPOLL_RATE=1000 -DQUEUED_POLL_RATE=100          /
//                          -DRESPONSE_POLL_RATE=100 -DREJOIN_POLL_RATE=440  /
//                          -DTOP_BOOT_PAGES=0) -I "D:\Program Files\IAR     /
//                          Systems\Embedded Workbench 4.05 Evaluation       /
//                          version\8051\inc\" -I "D:\Program Files\IAR      /
//                          Systems\Embedded Workbench 4.05 Evaluation       /
//                          version\8051\inc\clib\" -I                       /
//                          E:\解决\路由\Projects\zstack\Samples\SampleApp\C /
//                          C2430DB\ -I E:\解决\路由\Projects\zstack\Samples /
//                          \SampleApp\CC2430DB\..\Source\ -I                /
//                          E:\解决\路由\Projects\zstack\Samples\SampleApp\C /
//                          C2430DB\..\..\..\ZMain\TI2430DB\ -I              /
//                          E:\解决\路由\Projects\zstack\Samples\SampleApp\C /
//                          C2430DB\..\..\..\..\..\Components\mt\ -I         /
//                          E:\解决\路由\Projects\zstack\Samples\SampleApp\C /
//                          C2430DB\..\..\..\..\..\Components\hal\include\   /
//                          -I E:\解决\路由\Projects\zstack\Samples\SampleAp /
//                          p\CC2430DB\..\..\..\..\..\Components\hal\target\ /
//                          CC2430DB\ -I E:\解决\路由\Projects\zstack\Sample /
//                          s\SampleApp\CC2430DB\..\..\..\..\..\Components\o /
//                          sal\mcu\ccsoc\ -I E:\解决\路由\Projects\zstack\S /
//                          amples\SampleApp\CC2430DB\..\..\..\..\..\Compone /
//                          nts\osal\include\ -I E:\解决\路由\Projects\zstac /
//                          k\Samples\SampleApp\CC2430DB\..\..\..\..\..\Comp /
//                          onents\stack\af\ -I E:\解决\路由\Projects\zstack /
//                          \Samples\SampleApp\CC2430DB\..\..\..\..\..\Compo /
//                          nents\stack\nwk\ -I E:\解决\路由\Projects\zstack /
//                          \Samples\SampleApp\CC2430DB\..\..\..\..\..\Compo /
//                          nents\stack\sec\ -I E:\解决\路由\Projects\zstack /
//                          \Samples\SampleApp\CC2430DB\..\..\..\..\..\Compo /
//                          nents\stack\sys\ -I E:\解决\路由\Projects\zstack /
//                          \Samples\SampleApp\CC2430DB\..\..\..\..\..\Compo /
//                          nents\stack\zdo\ -I E:\解决\路由\Projects\zstack /
//                          \Samples\SampleApp\CC2430DB\..\..\..\..\..\Compo /
//                          nents\zmac\f8w\ -I E:\解决\路由\Projects\zstack\ /
//                          Samples\SampleApp\CC2430DB\..\..\..\..\..\Compon /
//                          ents\zmac\ -I E:\解决\路由\Projects\zstack\Sampl /
//                          es\SampleApp\CC2430DB\..\..\..\..\..\Components\ /
//                          services\saddr\ -I E:\解决\路由\Projects\zstack\ /
//                          Samples\SampleApp\CC2430DB\..\..\..\..\..\Compon /
//                          ents\services\sdata\ -I                          /
//                          E:\解决\路由\Projects\zstack\Samples\SampleApp\C /
//                          C2430DB\..\..\..\..\..\Components\mac\include\   /
//                          -I E:\解决\路由\Projects\zstack\Samples\SampleAp /
//                          p\CC2430DB\..\..\..\..\..\Components\mac\high_le /
//                          vel\ -I E:\解决\路由\Projects\zstack\Samples\Sam /
//                          pleApp\CC2430DB\..\..\..\..\..\Components\mac\lo /
//                          w_level\srf03\ -I E:\解决\路由\Projects\zstack\S /
//                          amples\SampleApp\CC2430DB\..\..\..\..\..\Compone /
//                          nts\mac\low_level\srf03\single_chip\ -D          /
//                          CC2430DB -lC E:\解决\路由\Projects\zstack\Sample /
//                          s\SampleApp\CC2430DB\CoordinatorDB\List\ -lA     /
//                          E:\解决\路由\Projects\zstack\Samples\SampleApp\C /
//                          C2430DB\CoordinatorDB\List\ --diag_suppress      /
//                          Pe001,Pa010 --diag_remark pe550 -o               /
//                          E:\解决\路由\Projects\zstack\Samples\SampleApp\C /
//                          C2430DB\CoordinatorDB\Obj\ -e                    /
//                          --require_prototypes -z9 --no_code_motion        /
//                          --debug --core=plain --dptr=16,1                 /
//                          --data_model=large --code_model=banked           /
//                          --calling_convention=xdata_reentrant             /
//                          --place_constants=data --nr_virtual_regs 8       /
//                          E:\解决\路由\Components\stack\zdo\ZDCache.c      /
//    List file          =  E:\解决\路由\Projects\zstack\Samples\SampleApp\C /
//                          C2430DB\CoordinatorDB\List\ZDCache.s51           /
//                                                                           /
//                                                                           /
//////////////////////////////////////////////////////////////////////////////

        NAME ZDCache

        RTMODEL "__calling_convention", "xdata_reentrant"
        RTMODEL "__code_model", "banked"
        RTMODEL "__core", "plain"
        RTMODEL "__data_model", "large"
        RTMODEL "__dptr_size", "16"
        RTMODEL "__extended_stack", "disabled"
        RTMODEL "__location_for_constants", "data"
        RTMODEL "__number_of_dptrs", "1"
        RTMODEL "__rt_version", "1"

        RSEG DOVERLAY:DATA:NOROOT(0)
        RSEG IOVERLAY:IDATA:NOROOT(0)
        RSEG ISTACK:IDATA:NOROOT(0)
        RSEG PSTACK:XDATA:NOROOT(0)
        RSEG XSTACK:XDATA:NOROOT(0)


        END
// E:\解决\路由\Components\stack\zdo\ZDCache.c
//    1 /*********************************************************************
//    2     Filename:       ZDCache.c
//    3     Revised:        $Date: 2007-02-15 15:11:28 -0800 (Thu, 15 Feb 2007) $
//    4     Revision:       $Revision: 13481 $
//    5 
//    6     Description: Implementation of the ZDO Discovery Cache functionality.
//    7 
//    8     Notes:
//    9 
//   10     Copyright (c) 2006 by Texas Instruments, Inc.
//   11     All Rights Reserved.  Permission to use, reproduce, copy, prepare
//   12     derivative works, modify, distribute, perform, display or sell this
//   13     software and/or its documentation for any purpose is prohibited
//   14     without the express written consent of Texas Instruments, Inc.
//   15 *********************************************************************/
//   16 #if defined( ZDO_CACHE )
//   17 
//   18 /*********************************************************************
//   19  * INCLUDES
//   20  */
//   21 #include "AF.h"
//   22 #include "nwk_globals.h"
//   23 #include "nwk_util.h"
//   24 #include "OSAL.h"
//   25 #include "ZDCache.h"
//   26 #include "ZDConfig.h"
//   27 #include "ZDObject.h"
//   28 
//   29 
//   30 /*********************************************************************
//   31  * MACROS
//   32  */
//   33 
//   34 /*********************************************************************
//   35  * CONSTANTS
//   36  */
//   37 
//   38 #define MAX_PKT_LEN  (MAX_DATA_PACKET_LEN - NWK_HDR_LEN)
//   39 
//   40 #if ( CACHE_DEV_MAX == 0 )
//   41   #define WAIT_ON_RESP_CACHE  5
//   42 
//   43   #define FIND_RSP_MAX  16
//   44 #endif
//   45 
//   46 #define SendMsg( CMD, LEN, DATA ) \ 
//   47   afAddOrSendMessage(   &msgAddr,             /* *DestAddr         */\ 
//   48                         ZDO_EP,               /*  Endpoint         */\ 
//   49                         (CMD),                /*  ClusterId        */\ 
//   50                         SEND_MESSAGE,         /*  TransCount       */\ 
//   51                         FRAMETYPE_MSG,        /*  FrameType        */\ 
//   52                         &tranSeq,             /* *TransSeqNumber   */\ 
//   53                         NULL,                 /*  CommandType      */\ 
//   54                         NULL,                 /*  AttribDataType   */\ 
//   55                         NULL,                 /*  AttribId         */\ 
//   56                         NULL,                 /*  ErrorCode        */\ 
//   57                         (LEN),                /*  DataLength       */\ 
//   58                         (DATA),               /* *Data             */\ 
//   59                         AF_TX_OPTIONS_NONE,   \ 
//   60                         FALSE,                /*  Discover route   */\ 
//   61                         radius )
//   62 
//   63 /*********************************************************************
//   64  * TYPEDEFS
//   65  */
//   66 
//   67 #if ( CACHE_DEV_MAX == 0 )
//   68 typedef enum {
//   69   eCacheWait,
//   70   eCacheClean,
//   71   eCacheFind,
//   72   eCacheRequest,
//   73   eNodeDescStore,
//   74   ePwrDescStore,
//   75   eActiveEPStore,
//   76   eSimpDescStore,
//   77   eCacheDone
//   78 } eCacheState;
//   79 #endif
//   80 
//   81 /*********************************************************************
//   82  * GLOBAL VARIABLES
//   83  */
//   84 
//   85 /*********************************************************************
//   86  * EXTERNAL VARIABLES
//   87  */
//   88 
//   89 /*********************************************************************
//   90  * EXTERNAL FUNCTIONS
//   91  */
//   92 
//   93 /*********************************************************************
//   94  * LOCAL FUNCTIONS
//   95  */
//   96 
//   97 #if ( CACHE_DEV_MAX > 0 )
//   98 static byte processDiscoveryStoreReq  ( byte *data );
//   99 static byte processSimpleDescStoreReq ( byte *data, byte idx );
//  100 static void processFindNodeCacheReq   ( byte *data );
//  101 
//  102 static byte getCnt    ( void );
//  103 static byte getIdx    ( uint16 addr );
//  104 static byte getNth    ( byte Nth );
//  105 static byte getIdxExt ( byte *ieee );
//  106 static byte getIdxEP  ( byte idx, byte ep );
//  107 static byte purgeAddr ( uint16 addr );
//  108 static byte purgeIEEE ( byte *ieee );
//  109 #endif
//  110 
//  111 /*********************************************************************
//  112  * LOCAL VARIABLES
//  113  */
//  114 
//  115 static afAddrType_t msgAddr;
//  116 static byte radius;
//  117 static byte tranSeq;
//  118 static byte secUse;
//  119 
//  120 #if ( CACHE_DEV_MAX > 0 )
//  121 static uint16                      NwkAddr[CACHE_DEV_MAX];
//  122 static byte                        ExtAddr[CACHE_DEV_MAX][Z_EXTADDR_LEN];
//  123 static uint32                       Expiry[CACHE_DEV_MAX];
//  124 static NodeDescriptorFormat_t     NodeDesc[CACHE_DEV_MAX];
//  125 static NodePowerDescriptorFormat_t NodePwr[CACHE_DEV_MAX];
//  126 static byte                          EPCnt[CACHE_DEV_MAX];
//  127 static byte                          EPArr[CACHE_DEV_MAX][CACHE_EP_MAX];
//  128 static SimpleDescriptionFormat_t  SimpDesc[CACHE_DEV_MAX][CACHE_EP_MAX];
//  129 static uint16               InClusters[CACHE_DEV_MAX][CACHE_EP_MAX][CACHE_CR_MAX];
//  130 static uint16              OutClusters[CACHE_DEV_MAX][CACHE_EP_MAX][CACHE_CR_MAX];
//  131 #elif ( CACHE_DEV_MAX == 0 )
//  132 static uint16 cacheFindAddr[FIND_RSP_MAX];
//  133 static byte EPArr[CACHE_EP_MAX];
//  134 static byte EPCnt;
//  135 static byte cacheCnt;  // Count of responding cache devices.
//  136 static byte cacheRsp;  // Results of last discovery cache request.
//  137 #endif
//  138 
//  139 
//  140 
//  141 #if ( CACHE_DEV_MAX > 0 )
//  142 /*********************************************************************
//  143  * @fn          processDiscoveryStoreReq
//  144  *
//  145  * @brief       Process a Discovery_store_req
//  146  *
//  147  * @return      none
//  148  */
//  149 static byte processDiscoveryStoreReq( byte *data )
//  150 {
//  151   uint16 aoi = BUILD_UINT16( data[0], data[1] );
//  152   byte rtrn = ZDP_INSUFFICIENT_SPACE;
//  153   byte idx;
//  154 
//  155   data += 2;
//  156   // First purge any outdated cache with this network address or IEEE.
//  157   purgeAddr( aoi );
//  158   purgeIEEE( data );
//  159 
//  160   // If an invalid addr cannot be found, the cache arrays are full.
//  161   if ( (idx = getIdx( INVALID_NODE_ADDR )) != CACHE_DEV_MAX )
//  162   {
//  163     osal_cpyExtAddr( ExtAddr[idx], data );
//  164     data += Z_EXTADDR_LEN;
//  165 
//  166     if ( (*data++ == sizeof( NodeDescriptorFormat_t )) &&
//  167          (*data++ == sizeof( NodePowerDescriptorFormat_t )) &&
//  168          (*data++ <= CACHE_EP_MAX) &&
//  169          (*data   < CACHE_EP_MAX) )
//  170     {
//  171       rtrn = ZDP_SUCCESS;
//  172       NwkAddr[idx] = aoi;
//  173       Expiry[idx] = 0;  //TBD - what value & how to keep alive?
//  174       EPCnt[idx] = 0;
//  175     }
//  176   }
//  177 
//  178   return rtrn;
//  179 }
//  180 
//  181 /*********************************************************************
//  182  * @fn          processSimpleDescStoreReq
//  183  *
//  184  * @brief       Process a Simple_Desc_store_req
//  185  *
//  186  * @return      none
//  187  */
//  188 static byte processSimpleDescStoreReq( byte *data, byte idx )
//  189 {
//  190   byte rtrn = ZDP_INSUFFICIENT_SPACE;
//  191   SimpleDescriptionFormat_t desc;
//  192 
//  193   // Skip first byte == total length of descriptor.
//  194   if (ZDO_ParseSimpleDescBuf( data+1, &desc ))  {
//  195     // malloc failed -- we can't do this...
//  196     return ZDP_NOT_PERMITTED;
//  197   }
//  198 
//  199   if ( (desc.AppNumInClusters <= CACHE_CR_MAX) &&
//  200        (desc.AppNumOutClusters <= CACHE_CR_MAX) )
//  201   {
//  202     byte epIdx = getIdxEP( idx, desc.EndPoint );
//  203 
//  204     if ( epIdx == CACHE_EP_MAX )
//  205     {
//  206       rtrn = ZDP_NOT_PERMITTED;

⌨️ 快捷键说明

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