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

📄 zglobals.lst

📁 cc2430应用实例
💻 LST
📖 第 1 页 / 共 5 页
字号:
    200              ZCD_NV_EXTENDED_PAN_ID, Z_EXTADDR_LEN, &zgExtendedPANID
    201            },
    202            {
    203              ZCD_NV_BCAST_RETRIES, sizeof(zgMaxBcastRetires), &zgMaxBcastRetires
    204            },
    205            {
    206              ZCD_NV_PASSIVE_ACK_TIMEOUT, sizeof(zgPassiveAckTimeout), &zgPassiveAckTimeout
    207            },
    208            {
    209              ZCD_NV_BCAST_DELIVERY_TIME, sizeof(zgBcastDeliveryTime), &zgBcastDeliveryTime
    210            },
    211            {
    212              ZCD_NV_NWK_MODE, sizeof(zgNwkMode), &zgNwkMode
    213            },
    214            {
    215              ZCD_NV_CONCENTRATOR_ENABLE, sizeof(zgConcentratorEnable), &zgConcentratorEnable
    216            },
    217            {
    218              ZCD_NV_CONCENTRATOR_DISCOVERY, sizeof(zgConcentratorDiscoveryTime), &zgConcentratorDiscoveryTime
    219            },
    220            {
    221              ZCD_NV_CONCENTRATOR_RADIUS, sizeof(zgConcentratorRadius), &zgConcentratorRadius
    222            },
    223            {
    224              ZCD_NV_MAX_SOURCE_ROUTE, sizeof(zgMaxSourceRoute), &zgMaxSourceRoute
    225            },
    226          #ifndef NONWK
    227            {
    228              ZCD_NV_PANID, sizeof(zgConfigPANID), &zgConfigPANID
    229            },
    230            {
    231              ZCD_NV_PRECFGKEY, SEC_KEY_LEN, &zgPreConfigKey
    232            },
    233            {
    234              ZCD_NV_PRECFGKEYS_ENABLE, sizeof(zgPreConfigKeys), &zgPreConfigKeys
    235            },
    236            {
    237              ZCD_NV_SECURITY_LEVEL, sizeof(zgSecurityLevel), &zgSecurityLevel
    238            },
    239          #endif // NONWK
    240            {
    241              ZCD_NV_APS_FRAME_RETRIES, sizeof(zgApscMaxFrameRetries), &zgApscMaxFrameRetries 
    242            },
    243            {
    244              ZCD_NV_APS_ACK_WAIT_DURATION, sizeof(zgApscAckWaitDurationPolled), &zgApscAckWaitDurationPolled
    245            },
    246            {
    247              ZCD_NV_APS_ACK_WAIT_MULTIPLIER, sizeof(zgApsAckWaitMultiplier), &zgApsAckWaitMultiplier
    248            },
    249            {
    250              ZCD_NV_BINDING_TIME, sizeof(zgApsDefaultMaxBindingTime), &zgApsDefaultMaxBindingTime
    251            },
    252            {
    253              ZCD_NV_START_DELAY, sizeof(zgStartDelay), &zgStartDelay
    254            },
    255            {
    256              ZCD_NV_SAPI_ENDPOINT, sizeof(zgSapiEndpoint), &zgSapiEndpoint
    257            },
    258          #endif // NV_INIT  
    259            // Last item -- DO NOT MOVE IT!
    260            {
    261              0x00, 0, NULL
    262            }
    263          };
    264          
    265          /*********************************************************************
    266           * LOCAL FUNCTIONS
    267           */ 
    268          
    269          static uint8 zgItemInit( uint16 id, uint16 len, void *buf, uint8 setDefault );
    270          
    271          
    272          /*********************************************************************
    273           * @fn       zgItemInit()
    274           *
    275           * @brief
    276           *
    277           *   Initialize a global item. If the item doesn't exist in NV memory,
    278           *   write the system default (value passed in) into NV memory. But if
    279           *   it exists, set the item to the value stored in NV memory.
    280           *
    281           *   Also, if setDefault is TRUE and the item exists, we will write 
    282           *   the default value to NV space.
    283           *
    284           * @param   id - item id
    285           * @param   len - item len
    286           * @param   buf - pointer to the item
    287           * @param   setDefault - TRUE to set default, not read
    288           *
    289           * @return  ZSUCCESS if successful, NV_ITEM_UNINIT if item did not
    290           *          exist in NV, NV_OPER_FAILED if failure.
    291           */
    292          static uint8 zgItemInit( uint16 id, uint16 len, void *buf, uint8 setDefault )
    293          {
    294          
    295            uint8 status;
    296            
    297            // If the item doesn't exist in NV memory, create and initialize
    298            // it with the value passed in.
    299            status = osal_nv_item_init( id, len, buf );
    300            if ( status == ZSUCCESS )
    301            {
    302              if ( setDefault )
    303              {
    304                // Write the default value back to NV
    305                status =  osal_nv_write( id, 0, len, buf );
    306              }
    307              else
    308              {
    309                // The item exists in NV memory, read it from NV memory
    310                status = osal_nv_read( id, 0, len, buf );
    311              }
    312            }
    313           
    314            return (status);
    315          }
    316          
    317          /*********************************************************************
    318           * API FUNCTIONS
    319           */
    320          
    321          
    322          /*********************************************************************
    323           * @fn          zgInit
    324           *
    325           * @brief
    326           *
    327           *   Initialize the Z-Stack Globals. If an item doesn't exist in 
    328           *   NV memory, write the system default into NV memory. But if
    329           *   it exists, set the item to the value stored in NV memory.
    330           *
    331           * NOTE: The Startup Options (ZCD_NV_STARTUP_OPTION) indicate
    332           *       that the Config state items (zgItemTable) need to be 
    333           *       set to defaults (ZCD_STARTOPT_DEFAULT_CONFIG_STATE). The
    334           * 
    335           *
    336           * @param       none
    337           *
    338           * @return      ZSUCCESS if successful, NV_ITEM_UNINIT if item did not
    339           *              exist in NV, NV_OPER_FAILED if failure.
    340           */

   \                                 In segment BANKED_CODE, align 1, keep-with-next
    341          uint8 zgInit( void )
   \                     zgInit:
    342          {
   \   000000   74F1         MOV     A,#-0xf
   \   000002   12....       LCALL   ?BANKED_ENTER_XDATA
   \   000005                ; Saved register size: 15
   \   000005                ; Auto size: 0
    343            uint8  i = 0;
   \   000005   75..00       MOV     ?V0 + 3,#0x0
    344            uint8  setDefault = FALSE;
   \   000008   75..00       MOV     ?V0 + 2,#0x0
    345            
    346            // Do we want to default the Config state values  
    347            if ( zgReadStartupOptions() & ZCD_STARTOPT_DEFAULT_CONFIG_STATE )
   \   00000B                ; Setup parameters for call to function zgReadStartupOptions
   \   00000B   90....       MOV     DPTR,#(zgReadStartupOptions & 0xffff)
   \   00000E   74..         MOV     A,#((zgReadStartupOptions >> 16) & 0xff)
   \   000010   12....       LCALL   ?BCALL               ; Banked call to: DPTR()
   \   000013   E9           MOV     A,R1
   \   000014   A2E0         MOV     C,0xE0 /* A   */.0
   \   000016   5003         JNC     ??zgInit_0
    348            {
    349              setDefault = TRUE;
   \   000018   75..01       MOV     ?V0 + 2,#0x1
    350            }
    351          
    352          #if 0 
    353            // Enable this section if you need to track the number of resets
    354            // This section is normally disabled to minimize "wear" on NV memory
    355            uint16 bootCnt = 0;
    356              
    357            // Update the Boot Counter
    358            if ( osal_nv_item_init( ZCD_NV_BOOTCOUNTER, sizeof(bootCnt), &bootCnt ) == ZSUCCESS )
    359            {
    360              // Get the old value from NV memory
    361              osal_nv_read( ZCD_NV_BOOTCOUNTER, 0, sizeof(bootCnt), &bootCnt );
    362            }
    363            
    364            // Increment the Boot Counter and store it into NV memory
    365            if ( setDefault )
    366              bootCnt = 0;
    367            else
    368              bootCnt++;
    369            osal_nv_write( ZCD_NV_BOOTCOUNTER, 0, sizeof(bootCnt), &bootCnt );
    370          #endif
    371            
    372            // Initialize the Extended PAN ID as my own extended address
    373            ZMacGetReq( ZMacExtAddr, zgExtendedPANID );
   \                     ??zgInit_0:
   \   00001B                ; Setup parameters for call to function ZMacGetReq
   \   00001B   7A..         MOV     R2,#(zgExtendedPANID & 0xff)
   \   00001D   7B..         MOV     R3,#((zgExtendedPANID >> 8) & 0xff)
   \   00001F   79E2         MOV     R1,#-0x1e
   \   000021   12....       LCALL   ZMacGetReq & 0xFFFF
    374            
    375          #ifndef NONWK
    376            // Initialize the Pre-Configured Key to the default key
    377            osal_memcpy( zgPreConfigKey, defaultKey, SEC_KEY_LEN );  // Do NOT Change!!!
   \   000024                ; Setup parameters for call to function osal_memcpy
   \   000024   75....       MOV     ?V0 + 4,#(defaultKey & 0xff)
   \   000027   75....       MOV     ?V0 + 5,#((defaultKey >> 8) & 0xff)
   \   00002A   75..80       MOV     ?V0 + 6,#-0x80
   \   00002D   78..         MOV     R0,#?V0 + 4
   \   00002F   12....       LCALL   ?PUSH_XSTACK_I_THREE
   \   000032   7C10         MOV     R4,#0x10
   \   000034   7D00         MOV     R5,#0x0
   \   000036   7A..         MOV     R2,#(zgPreConfigKey & 0xff)
   \   000038   7B..         MOV     R3,#((zgPreConfigKey >> 8) & 0xff)
   \   00003A   90....       MOV     DPTR,#(osal_memcpy & 0xffff)
   \   00003D   74..         MOV     A,#((osal_memcpy >> 16) & 0xff)
   \   00003F   12....       LCALL   ?BCALL               ; Banked call to: DPTR()
   \   000042   7403         MOV     A,#0x3
   \   000044   12....       LCALL   ?DEALLOC_XSTACK8
   \   000047   801F         SJMP    ??zgInit_1
    378          #endif // NONWK
    379          
    380            while ( zgItemTable[i].id != 0x00 )
    381            {
   \                     ??zgInit_2:
   \   000049                ; Setup parameters for call to function osal_nv_read
   \   000049   12....       LCALL   ?PUSH_XSTACK_I_TWO
   \   00004C   78..         MOV     R0,#?V0 + 0
   \   00004E   12....       LCALL   ?PUSH_XSTACK_I_TWO
   \   000051   7C00         MOV     R4,#0x0
   \   000053   7D00         MOV     R5,#0x0
   \   000055   EE           MOV     A,R6
   \   000056   FA           MOV     R2,A
   \   000057   EF           MOV     A,R7
   \   000058   FB           MOV     R3,A
   \   000059   90....       MOV     DPTR,#(osal_nv_read & 0xffff)
   \   00005C   74..         MOV     A,#((osal_nv_read >> 16) & 0xff)
   \                     ??zgInit_3:
   \   00005E   12....       LCALL   ?BCALL               ; Banked call to: DPTR()
   \   000061   7404         MOV     A,#0x4
   \   000063   12....       LCALL   ?DEALLOC_XSTACK8
    382              // Initialize the item
    383              zgItemInit( zgItemTable[i].id, zgItemTable[i].len, zgItemTable[i].buf, setDefault  );
    384              
    385              // Move on to the next item
    386              i++;
   \                     ??zgInit_4:
   \   000066   05..         INC     ?V0 + 3
   \                     ??zgInit_1:
   \   000068   E5..         MOV     A,?V0 + 3
   \   00006A   75F006       MOV     B,#0x6
   \   00006D   A4           MUL     AB
   \   00006E   F8           MOV     R0,A
   \   00006F   AAF0         MOV     R2,B
   \   000071   EA           MOV     A,R2
   \   000072   F9           MOV     R1,A
   \   000073   E8           MOV     A,R0
   \   000074   24..         ADD     A,#(??zgItemTable & 0xff)
   \   000076   F582         MOV     DPL,A
   \   000078   E9           MOV     A,R1
   \   000079   34..         ADDC    A,#((??zgItemTable >> 8) & 0xff)

⌨️ 快捷键说明

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