📄 mac_power_management.lst
字号:
319
320 }
321
322 PCON = 1;
\ ??mpmSetAndResumeMacAndCpuPowerMode_0:
\ 00003F 758701 MOV 0x87,#0x1
323 // CPU will HALT here. Processing is resumed when an external interrupt or a sleep timer interrupt
324 // occurs
325
326 // Correction of active power up bug
327 asm("NOP");
\ 000042 00 NOP
328 asm("NOP");
\ 000043 00 NOP
329 mpmResumeMacAfterPowerDown (resumeMode,
330 synchronousStart,
331 rxOnWhenIdle);
\ 000044 ; Setup parameters for call to function mpmResumeMacAfterPowerDown
\ 000044 85..82 MOV DPL,?XSP + 0
\ 000047 85..83 MOV DPH,?XSP + 1
\ 00004A E0 MOVX A,@DPTR
\ 00004B FB MOV R3,A
\ 00004C AA.. MOV R2,?V0 + 0
\ 00004E EF MOV A,R7
\ 00004F F9 MOV R1,A
\ 000050 12.... LCALL mpmResumeMacAfterPowerDown
332
333 }
\ 000053 7401 MOV A,#0x1
\ 000055 REQUIRE ?Subroutine1
\ 000055 ; // Fall through to label ?Subroutine1
\ In segment NEAR_CODE, align 1, keep-with-next
\ ?Subroutine1:
\ 000000 12.... LCALL ?DEALLOC_XSTACK8
\ 000003 7F01 MOV R7,#0x1
\ 000005 02.... LJMP ?FUNC_LEAVE_XDATA
334
335
336 //-------------------------------------------------------------------------------------------------------
337 // ROOT void mpmPowerDownMac (BYTE *rxOnWhenIdle)
338 //
339 // DESCRIPTION:
340 // Stops MAC prosessing and turns the radio off.
341 //
342 // ARGUMENTS:
343 // BYTE rxOnWhenIdle
344 // Contains the value of rxOnWhenIdle prior to power down
345 //
346 //-------------------------------------------------------------------------------------------------------
\ In segment NEAR_CODE, align 1, keep-with-next
347 ROOT void mpmPowerDownMac (BYTE *rxOnWhenIdle)
\ mpmPowerDownMac:
348 {
\ 000000 C082 PUSH DPL
\ 000002 C083 PUSH DPH
\ 000004 ; Saved register size: 2
\ 000004 ; Auto size: 1
\ 000004 74FF MOV A,#-0x1
\ 000006 12.... LCALL ?ALLOC_XSTACK8
349 BYTE setAttributeValue;
350
351 mlmeGetRequest (MAC_RX_ON_WHEN_IDLE, rxOnWhenIdle);
\ 000009 ; Setup parameters for call to function mlmeGetRequest
\ 000009 7952 MOV R1,#0x52
\ 00000B 12.... LCALL mlmeGetRequest
352
353 setAttributeValue = FALSE;
\ 00000E E4 CLR A
\ 00000F 85..82 MOV DPL,?XSP + 0
\ 000012 85..83 MOV DPH,?XSP + 1
\ 000015 F0 MOVX @DPTR,A
354 mlmeSetRequest (MAC_RX_ON_WHEN_IDLE, &setAttributeValue);
\ 000016 ; Setup parameters for call to function mlmeSetRequest
\ 000016 AA82 MOV R2,DPL
\ 000018 AB83 MOV R3,DPH
\ 00001A 7952 MOV R1,#0x52
\ 00001C 12.... LCALL mlmeSetRequest
355
356 // Power down
357 mpmSetRequest(MPM_CC2430_XOSC_AND_VREG_OFF);
\ 00001F ; Setup parameters for call to function mpmSetRequest
\ 00001F 7902 MOV R1,#0x2
\ 000021 12.... LCALL mpmSetRequest
358 while (mpmGetState() != MPM_CC2430_XOSC_AND_VREG_OFF);
\ ??mpmPowerDownMac_0:
\ 000024 90.... MOV DPTR,#mpmInfo
\ 000027 E0 MOVX A,@DPTR
\ 000028 6402 XRL A,#0x2
\ 00002A 70F8 JNZ ??mpmPowerDownMac_0
359
360 }
\ 00002C 7401 MOV A,#0x1
\ 00002E 12.... LCALL ?DEALLOC_XSTACK8
\ 000031 02.... LJMP ??Subroutine0_0
361
362 //-------------------------------------------------------------------------------------------------------
363 // void mpmResumeMacAfterPowerDown (RESUME_MODE resumeMode,
364 // BOOL synchronousStart,
365 // BOOL rxOnWhenIdle)
366 //
367 // DESCRIPTION:
368 // Resumes the mac protocol after a power down
369 //
370 // ARGUMENTS:
371 // RESUME_MODE resumeMode
372 // Depends on how much of the MAC variables that was preserved during power down. In power control
373 // PM1 or when all data are places in upper 4 kRAM, RESUME_MODE_ALL_PRESERVED can be used. The
374 // XDATA segment and the PM0_XDATA segment must be located in upper 4 kRAM.
375 // If the PM0_XDATA segment is located in lower 4 kRAM and XDATA in upper 4 kRAM,
376 // the RESUME_MODE_PARTS_PRESERVED must be used.
377 // RESUME_MODE_ALL_PRESERVED, restarts only timer2. The fastest and less power consuming mode
378 // RESUME_MODE_PARTS_PRESERVED restarts timer2, the task and memory pool system
379 //
380 // BOOL synchronousStart
381 // FALSE Start timer2 immediate
382 // TRUE Start timer2 synchronous with external 32.768 kHz clock
383 //
384 // BOOL rxOnWhenIdle
385 // FALSE RX is off
386 // TRUE Turn RX on
387 //-------------------------------------------------------------------------------------------------------
\ In segment NEAR_CODE, align 1, keep-with-next
388 ROOT void mpmResumeMacAfterPowerDown (RESUME_MODE resumeMode,
\ mpmResumeMacAfterPowerDown:
389 BOOL synchronousStart,
390 BOOL rxOnWhenIdle)
391 {
\ 000000 74F8 MOV A,#-0x8
\ 000002 12.... LCALL ?FUNC_ENTER_XDATA
\ 000005 ; Saved register size: 8
\ 000005 ; Auto size: 2
\ 000005 74FE MOV A,#-0x2
\ 000007 12.... LCALL ?ALLOC_XSTACK8
\ 00000A E9 MOV A,R1
\ 00000B FF MOV R7,A
\ 00000C 8A.. MOV ?V0 + 0,R2
\ 00000E EB MOV A,R3
\ 00000F FE MOV R6,A
392 BYTE setAttributeValue;
393 WORD mdmctrl0;
394
395 switch (resumeMode)
\ 000010 EF MOV A,R7
\ 000011 12.... LCALL ?UC_SWITCH_DENSE
\ `?<Jumptable for mpmResumeMacAfterPowerDown>_0`:
\ 000014 00 DB 0
\ 000015 01 DB 1
\ 000016 .... DW ??mpmResumeMacAfterPowerDown_0
\ 000018 .... DW ??mpmResumeMacAfterPowerDown_1
\ 00001A .... DW ??mpmResumeMacAfterPowerDown_2
396 {
397 case RESUME_MODE_ALL_PRESERVED:
398 DISABLE_GLOBAL_INT();
\ ??mpmResumeMacAfterPowerDown_1:
\ 00001C C2AF CLR 0xa8.7
399
400 if (synchronousStart == FALSE)
\ 00001E EA MOV A,R2
\ 00001F 7008 JNZ ??mpmResumeMacAfterPowerDown_3
401 T2_START_NOSYNC ();
\ 000021 53C3FD ANL 0xc3,#0xfd
\ 000024 43C301 ORL 0xc3,#0x1
\ 000027 8003 SJMP ??mpmResumeMacAfterPowerDown_4
402 else
403 mtimStartSync ();
\ ??mpmResumeMacAfterPowerDown_3:
\ 000029 ; Setup parameters for call to function mtimStartSync
\ 000029 12.... LCALL mtimStartSync
404
405 ENABLE_TIMER2_INT();
\ ??mpmResumeMacAfterPowerDown_4:
\ 00002C D2BA SETB 0xb8.2
406 macInfo.state = MAC_STATE_DEFAULT;
\ 00002E E4 CLR A
\ 00002F 90.... MOV DPTR,#macInfo
\ 000032 F0 MOVX @DPTR,A
407
408 // Power up radio
409 mpmSetRequest(MPM_CC2430_ON);
\ 000033 ; Setup parameters for call to function mpmSetRequest
\ 000033 F9 MOV R1,A
\ 000034 12.... LCALL mpmSetRequest
410 while (mpmGetState() != MPM_CC2430_ON);
\ ??mpmResumeMacAfterPowerDown_5:
\ 000037 90.... MOV DPTR,#mpmInfo
\ 00003A E0 MOVX A,@DPTR
\ 00003B 70FA JNZ ??mpmResumeMacAfterPowerDown_5
411 DISABLE_TIMER2_INT();
\ 00003D C2BA CLR 0xb8.2
\ 00003F 8053 SJMP ??mpmResumeMacAfterPowerDown_0
412 break;
413
414 case RESUME_MODE_PARTS_PRESERVED:
415 DISABLE_GLOBAL_INT();
\ ??mpmResumeMacAfterPowerDown_2:
\ 000041 C2AF CLR 0xa8.7
416 InitializeCommonStorage ();
\ 000043 ; Setup parameters for call to function InitializeCommonStorage
\ 000043 12.... LCALL InitializeCommonStorage
417 InitializeDma ();
\ 000046 ; Setup parameters for call to function InitializeDma
\ 000046 12.... LCALL InitializeDma
418 InitializeRfInterrupts ();
\ 000049 ; Setup parameters for call to function InitializeRfInterrupts
\ 000049 12.... LCALL InitializeRfInterrupts
419 mschInit();
\ 00004C ; Setup parameters for call to function mschInit
\ 00004C 12.... LCALL mschInit
420 mtimInit(synchronousStart);
\ 00004F ; Setup parameters for call to function mtimInit
\ 00004F A9.. MOV R1,?V0 + 0
\ 000051 12.... LCALL mtimInit
421 ENABLE_TIMER2_INT();
\ 000054 D2BA SETB 0xb8.2
422 macInfo.state = MAC_STATE_DEFAULT;
\ 000056 E4 CLR A
\ 000057 90.... MOV DPTR,#macInfo
\ 00005A F0 MOVX @DPTR,A
423
424 // Power up radio
425 mpmSetRequest(MPM_CC2430_ON);
\ 00005B ; Setup parameters for call to function mpmSetRequest
\ 00005B F9 MOV R1,A
\ 00005C 12.... LCALL mpmSetRequest
426 while (mpmGetState() != MPM_CC2430_ON);
\ ??mpmResumeMacAfterPowerDown_6:
\ 00005F 90.... MOV DPTR,#mpmInfo
\ 000062 E0 MOVX A,@DPTR
\ 000063 70FA JNZ ??mpmResumeMacAfterPowerDown_6
427
428 DISABLE_TIMER2_INT();
\ 000065 C2BA CLR 0xb8.2
429
430 // Initialize variables in the various modules
431 mrxpInit();
\ 000067 ; Setup parameters for call to function mrxpInit
\ 000067 12.... LCALL mrxpInit
432 mtxpInit();
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -