📄 zglobals.lst
字号:
210 ZCD_NV_BCAST_DELIVERY_TIME, sizeof(zgBcastDeliveryTime), &zgBcastDeliveryTime
211 },
212 {
213 ZCD_NV_NWK_MODE, sizeof(zgNwkMode), &zgNwkMode
214 },
215 {
216 ZCD_NV_CONCENTRATOR_ENABLE, sizeof(zgConcentratorEnable), &zgConcentratorEnable
217 },
218 {
219 ZCD_NV_CONCENTRATOR_DISCOVERY, sizeof(zgConcentratorDiscoveryTime), &zgConcentratorDiscoveryTime
220 },
221 {
222 ZCD_NV_CONCENTRATOR_RADIUS, sizeof(zgConcentratorRadius), &zgConcentratorRadius
223 },
224 {
225 ZCD_NV_MAX_SOURCE_ROUTE, sizeof(zgMaxSourceRoute), &zgMaxSourceRoute
226 },
227 #ifndef NONWK
228 {
229 ZCD_NV_PANID, sizeof(zgConfigPANID), &zgConfigPANID
230 },
231 {
232 ZCD_NV_PRECFGKEY, SEC_KEY_LEN, &zgPreConfigKey
233 },
234 {
235 ZCD_NV_PRECFGKEYS_ENABLE, sizeof(zgPreConfigKeys), &zgPreConfigKeys
236 },
237 {
238 ZCD_NV_SECURITY_LEVEL, sizeof(zgSecurityLevel), &zgSecurityLevel
239 },
240 #endif // NONWK
241 {
242 ZCD_NV_APS_FRAME_RETRIES, sizeof(zgApscMaxFrameRetries), &zgApscMaxFrameRetries
243 },
244 {
245 ZCD_NV_APS_ACK_WAIT_DURATION, sizeof(zgApscAckWaitDurationPolled), &zgApscAckWaitDurationPolled
246 },
247 {
248 ZCD_NV_APS_ACK_WAIT_MULTIPLIER, sizeof(zgApsAckWaitMultiplier), &zgApsAckWaitMultiplier
249 },
250 {
251 ZCD_NV_BINDING_TIME, sizeof(zgApsDefaultMaxBindingTime), &zgApsDefaultMaxBindingTime
252 },
253 {
254 ZCD_NV_START_DELAY, sizeof(zgStartDelay), &zgStartDelay
255 },
256 {
257 ZCD_NV_SAPI_ENDPOINT, sizeof(zgSapiEndpoint), &zgSapiEndpoint
258 },
259 #endif // NV_INIT
260 // Last item -- DO NOT MOVE IT!
261 {
262 0x00, 0, NULL
263 }
264 };
265
266 /*********************************************************************
267 * LOCAL FUNCTIONS
268 */
269
270 static uint8 zgItemInit( uint16 id, uint16 len, void *buf, uint8 setDefault );
271
272
273 /*********************************************************************
274 * @fn zgItemInit()
275 *
276 * @brief
277 *
278 * Initialize a global item. If the item doesn't exist in NV memory,
279 * write the system default (value passed in) into NV memory. But if
280 * it exists, set the item to the value stored in NV memory.
281 *
282 * Also, if setDefault is TRUE and the item exists, we will write
283 * the default value to NV space.
284 *
285 * @param id - item id
286 * @param len - item len
287 * @param buf - pointer to the item
288 * @param setDefault - TRUE to set default, not read
289 *
290 * @return ZSUCCESS if successful, NV_ITEM_UNINIT if item did not
291 * exist in NV, NV_OPER_FAILED if failure.
292 */
293 static uint8 zgItemInit( uint16 id, uint16 len, void *buf, uint8 setDefault )
294 {
295
296 uint8 status;
297
298 // If the item doesn't exist in NV memory, create and initialize
299 // it with the value passed in.
300 status = osal_nv_item_init( id, len, buf );
301 if ( status == ZSUCCESS )
302 {
303 if ( setDefault )
304 {
305 // Write the default value back to NV
306 status = osal_nv_write( id, 0, len, buf );
307 }
308 else
309 {
310 // The item exists in NV memory, read it from NV memory
311 status = osal_nv_read( id, 0, len, buf );
312 }
313 }
314
315 return (status);
316 }
317
318 /*********************************************************************
319 * API FUNCTIONS
320 */
321
322
323 /*********************************************************************
324 * @fn zgInit
325 *
326 * @brief
327 *
328 * Initialize the Z-Stack Globals. If an item doesn't exist in
329 * NV memory, write the system default into NV memory. But if
330 * it exists, set the item to the value stored in NV memory.
331 *
332 * NOTE: The Startup Options (ZCD_NV_STARTUP_OPTION) indicate
333 * that the Config state items (zgItemTable) need to be
334 * set to defaults (ZCD_STARTOPT_DEFAULT_CONFIG_STATE). The
335 *
336 *
337 * @param none
338 *
339 * @return ZSUCCESS if successful, NV_ITEM_UNINIT if item did not
340 * exist in NV, NV_OPER_FAILED if failure.
341 */
\ In segment BANKED_CODE, align 1, keep-with-next
342 uint8 zgInit( void )
\ zgInit:
343 {
\ 000000 74F1 MOV A,#-0xf
\ 000002 12.... LCALL ?BANKED_ENTER_XDATA
\ 000005 ; Saved register size: 15
\ 000005 ; Auto size: 0
344 uint8 i = 0;
\ 000005 75..00 MOV ?V0 + 3,#0x0
345 uint8 setDefault = FALSE;
\ 000008 75..00 MOV ?V0 + 2,#0x0
346
347 // Do we want to default the Config state values
348 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
349 {
350 setDefault = TRUE;
\ 000018 75..01 MOV ?V0 + 2,#0x1
351 }
352
353 #if 0
354 // Enable this section if you need to track the number of resets
355 // This section is normally disabled to minimize "wear" on NV memory
356 uint16 bootCnt = 0;
357
358 // Update the Boot Counter
359 if ( osal_nv_item_init( ZCD_NV_BOOTCOUNTER, sizeof(bootCnt), &bootCnt ) == ZSUCCESS )
360 {
361 // Get the old value from NV memory
362 osal_nv_read( ZCD_NV_BOOTCOUNTER, 0, sizeof(bootCnt), &bootCnt );
363 }
364
365 // Increment the Boot Counter and store it into NV memory
366 if ( setDefault )
367 bootCnt = 0;
368 else
369 bootCnt++;
370 osal_nv_write( ZCD_NV_BOOTCOUNTER, 0, sizeof(bootCnt), &bootCnt );
371 #endif
372
373 // Initialize the Extended PAN ID as my own extended address
374 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
375
376 #ifndef NONWK
377 // Initialize the Pre-Configured Key to the default key
378 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
379 #endif // NONWK
380
381 while ( zgItemTable[i].id != 0x00 )
382 {
\ ??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
383 // Initialize the item
384 zgItemInit( zgItemTable[i].id, zgItemTable[i].len, zgItemTable[i].buf, setDefault );
385
386 // Move on to the next item
387 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)
\ 00007B F583 MOV DPH,A
\ 00007D E4 CLR A
\ 00007E 93 MOVC A,@A+DPTR
\ 00007F F8 MOV R0,A
\ 000080 7401 MOV A,#0x1
\ 000082 93 MOVC A,@A+DPTR
\ 000083 F9 MOV R1,A
\ 000084 E8 MOV A,R0
\ 000085 7001 JNZ ??zgInit_5
\ 000087 E9 MOV A,R1
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -