📄 hal_sleep.s51
字号:
// 396 /* save interrupt enable registers and disable all interrupts */
// 397 HAL_SLEEP_IE_BACKUP_AND_DISABLE(ien0, ien1, ien2);
??halSleep_13:
MOV A,0xa8
MOV ?V0 + 0,A
MOV A,0xb8
MOV ?V0 + 1,A
MOV A,0x9a
MOV ?V0 + 2,A
ANL 0xa8,#0x20
MOV A,0xa8
ANL 0xb8,#0x20
MOV A,0xb8
ANL 0x9a,#0x12
MOV A,0x9a
// 398
// 399 /* This is to check if the stack is exceeding the disappearing
// 400 * RAM boundary of 0xF000. If the stack does exceed the boundary
// 401 * (unlikely), do not enter sleep until the stack is back to normal.
// 402 */
// 403 if ( ((uint16)(*( __idata uint16*)(CSTK_PTR)) >= 0xF000) )
MOV R0,#(SFB(XSP) & 0xff)
CLR C
MOV A,@R0
SUBB A,#0x0
INC R0
MOV A,@R0
SUBB A,#-0x10
JC ??halSleep_16
// 404 {
// 405 HAL_EXIT_CRITICAL_SECTION(intState);
MOV DPL,?XSP + 0
MOV DPH,?XSP + 1
MOVX A,@DPTR
MOV C,0xE0 /* A */.0
MOV 0xa8.7,C
// 406
// 407 /* AN044 - DELAYING EXTERNAL INTERRUPTS, do not relocate this line.
// 408 * it has to stay as close to PCON.IDLE = 1 as possible.
// 409 */
// 410 EXTERNAL_INTERRUPT_DELAY();
ORL 0xfd,#0x2
SETB 0x80.1
; Setup parameters for call to function halSleepWait
MOV R2,#-0x4c
MOV R3,#0x0
MOV DPTR,#(halSleepWait & 0xffff)
MOV A,#((halSleepWait >> 16) & 0xff)
LCALL ?BCALL ; Banked call to: DPTR()
ANL 0xfd,#0xfd
ORL 0x8f,#0x2
// 411
// 412 /* set CC2430 power mode */
// 413 HAL_SLEEP_SET_POWER_MODE(halPwrMgtMode);
MOV DPTR,#-0x20a0
MOVX A,@DPTR
CLR C
SUBB A,#0x4
ANL 0xbe,#0xfc
MOV A,0xbe
MOV DPTR,#??halPwrMgtMode
MOVX A,@DPTR
ORL A,0xbe
MOV 0xbe,A
JC ??halSleep_17
NOP
NOP
NOP
MOV A,#0x3
ANL A,0xbe
JZ ??halSleep_18
??halSleep_17:
ORL 0x87,#0x1
NOP
// 414 /* wake up from sleep */
// 415
// 416 HAL_ENTER_CRITICAL_SECTION(intState);
??halSleep_18:
MOV C,0xa8.7
CLR A
MOV 0xE0 /* A */.0,C
MOV DPL,?XSP + 0
MOV DPH,?XSP + 1
MOVX @DPTR,A
CLR 0xa8.7
// 417 }
// 418
// 419 /* restore interrupt enable registers */
// 420 HAL_SLEEP_IE_RESTORE(ien0, ien1, ien2);
??halSleep_16:
MOV 0xa8,?V0 + 0
MOV 0xb8,?V0 + 1
MOV 0x9a,?V0 + 2
// 421
// 422 /* disable sleep timer interrupt */
// 423 HAL_SLEEP_TIMER_DISABLE_INT();
CLR 0xa8.5
// 424
// 425 /* set main clock source to crystal for Rev B and Rev D only */
// 426 HAL_SLEEP_SET_MAIN_CLOCK_CRYSTAL();
ANL 0xbe,#0xfb
??halSleep_19:
MOV A,0xbe
MOV C,0xE0 /* A */.6
JNC ??halSleep_19
NOP
; Setup parameters for call to function halSleepWait
MOV R2,#0x3f
MOV R3,#0x0
MOV DPTR,#(halSleepWait & 0xffff)
MOV A,#((halSleepWait >> 16) & 0xff)
LCALL ?BCALL ; Banked call to: DPTR()
MOV 0xc6,#0x0
??halSleep_20:
MOV A,0xc6
JNZ ??halSleep_20
ORL 0xbe,#0x4
// 427
// 428 /* Calculate timer elasped */
// 429 halAccumulatedSleepTime += (HalTimerElapsed() / TICK_COUNT);
; Setup parameters for call to function HalTimerElapsed
MOV DPTR,#(HalTimerElapsed & 0xffff)
MOV A,#((HalTimerElapsed >> 16) & 0xff)
LCALL ?BCALL ; Banked call to: DPTR()
MOV ?V0 + 0,R2
MOV ?V0 + 1,R3
MOV ?V0 + 2,R4
MOV ?V0 + 3,R5
MOV DPTR,#??halAccumulatedSleepTime
MOV R0,#?V0 + 0
LCALL ?L_ADD_TO_X
// 430
// 431 /* deduct the sleep time for the next iteration */
// 432 if ( osal_timeout > halAccumulatedSleepTime)
MOV DPTR,#??halAccumulatedSleepTime
MOV ?V0 + 0,R6
MOV ?V0 + 1,R7
MOV ?V0 + 2,#0x0
MOV ?V0 + 3,#0x0
MOV R0,#?V0 + 0
LCALL ?UL_GT_X
JNC ??halSleep_21
// 433 {
// 434 osal_timeout -= halAccumulatedSleepTime;
MOV DPTR,#??halAccumulatedSleepTime
MOV R0,#?V0 + 0
LCALL ?L_MOV_X
CLR C
MOV A,R6
SUBB A,?V0 + 0
MOV R6,A
MOV A,R7
SUBB A,?V0 + 1
MOV R7,A
// 435 }
// 436
// 437 /* if the remaining time is less than the PM_MIN_SLEEP_TIME
// 438 * burn the remaining time in a delay loop
// 439 * AN044 - MINIMUM SLEEP PERIODS WITH PULL-DOWN RESISTOR
// 440 */
// 441 if ( osal_timeout < PM_MIN_SLEEP_TIME )
??halSleep_21:
CLR C
MOV A,R6
SUBB A,#0xe
MOV A,R7
SUBB A,#0x0
JNC ??halSleep_22
// 442 {
// 443 halSleepWait(osal_timeout*1000);
; Setup parameters for call to function halSleepWait
MOV A,R6
MOV R2,A
MOV A,R7
MOV R3,A
MOV A,R2
MOV B,#-0x18
MUL AB
XCH A,R2
MOV R4,B
MOV B,#0x3
MUL AB
ADD A,R4
MOV R4,A
MOV B,#-0x18
MOV A,R3
MUL AB
ADD A,R4
MOV R3,A
MOV DPTR,#(halSleepWait & 0xffff)
MOV A,#((halSleepWait >> 16) & 0xff)
LCALL ?BCALL ; Banked call to: DPTR()
// 444 halAccumulatedSleepTime += osal_timeout;
MOV ?V0 + 0,R6
MOV ?V0 + 1,R7
MOV ?V0 + 2,#0x0
MOV ?V0 + 3,#0x0
MOV DPTR,#??halAccumulatedSleepTime
MOV R0,#?V0 + 0
LCALL ?L_ADD_TO_X
// 445 osal_timeout = halAccumulatedSleepTime;
MOV DPTR,#??halAccumulatedSleepTime
MOV R0,#?V0 + 0
LCALL ?L_MOV_X
MOV R6,?V0 + 0
MOV R7,?V0 + 1
// 446 }
// 447
// 448 #ifdef HAL_SLEEP_DEBUG_LED
// 449 HAL_TURN_ON_LED3();
// 450 #else
// 451 /* use this to turn LEDs back on after sleep */
// 452 HalLedExitSleep();
??halSleep_22:
; Setup parameters for call to function HalLedExitSleep
MOV DPTR,#(HalLedExitSleep & 0xffff)
MOV A,#((HalLedExitSleep >> 16) & 0xff)
LCALL ?BCALL ; Banked call to: DPTR()
// 453 #endif
// 454
// 455 /* handle peripherals; exit loop if key presses */
// 456 if ( HalKeyExitSleep() )
; Setup parameters for call to function HalKeyExitSleep
MOV DPTR,#(HalKeyExitSleep & 0xffff)
MOV A,#((HalKeyExitSleep >> 16) & 0xff)
LCALL ?BCALL ; Banked call to: DPTR()
MOV A,R1
JNZ ??halSleep_10
// 457 {
// 458 #if defined (PM2_HOLDOFF_TIME) && (PM2_HOLDOFF_TIME > 0)
// 459 /* The deepest sleep alowwed is PM1 until after the timer expired
// 460 * AN044 - COMBINING POWER MODES
// 461 */
// 462 halSleepLevel = CC2430_PM1;
// 463 osal_stop_timerEx (Hal_TaskID, HAL_SLEEP_TIMER_EVENT);
// 464 osal_start_timerEx (Hal_TaskID, HAL_SLEEP_TIMER_EVENT, PM2_HOLDOFF_TIME);
// 465 #endif /* (PM2_HOLDOFF_TIME > 0) */
// 466 break;
// 467 }
// 468
// 469 /* exit loop if no timer active */
// 470 if ( timeout == 0 ) break;
MOV A,#0x1
LCALL ?XSTACK_DISP0_8
PUSH DPL
CFI CFA_SP SP+-1
PUSH DPH
CFI CFA_SP SP+-2
MOV DPTR,#__Constant_0
MOV R0,#?V0 + 0
LCALL ?L_MOV_X
POP DPH
CFI CFA_SP SP+-1
POP DPL
CFI CFA_SP SP+0
MOV R0,#?V0 + 0
LCALL ?L_EQ_X
JZ $+5
LJMP ??halSleep_8 & 0xFFFF
// 471 }
// 472
// 473 /* power on the MAC; blocks until completion */
// 474 MAC_PwrOnReq();
??halSleep_10:
; Setup parameters for call to function MAC_PwrOnReq
MOV DPTR,#(MAC_PwrOnReq & 0xffff)
MOV A,#((MAC_PwrOnReq >> 16) & 0xff)
LCALL ?BCALL ; Banked call to: DPTR()
// 475
// 476 /* adjust OSAL timers */
// 477 osal_adjust_timers();
; Setup parameters for call to function osal_adjust_timers
MOV DPTR,#(osal_adjust_timers & 0xffff)
MOV A,#((osal_adjust_timers >> 16) & 0xff)
LCALL ?BCALL ; Banked call to: DPTR()
// 478
// 479 HAL_EXIT_CRITICAL_SECTION(intState);
// 480 }
// 481 else
// 482 {
// 483 HAL_EXIT_CRITICAL_SECTION(intState);
// 484 }
// 485 }
// 486 else
// 487 {
// 488 HAL_EXIT_CRITICAL_SECTION(intState);
??halSleep_7:
MOV DPL,?XSP + 0
MOV DPH,?XSP + 1
MOVX A,@DPTR
MOV C,0xE0 /* A */.0
MOV 0xa8.7,C
// 489 }
// 490 }
// 491 }
??halSleep_5:
MOV A,#0x5
LJMP ??Subroutine0_0 & 0xFFFF
CFI EndBlock cfiBlock0
// 492
// 493 /**************************************************************************************************
// 494 * @fn halSleepSetTimer
// 495 *
// 496 * @brief This function sets the CC2430 sleep timer compare value. First it reads and
// 497 * stores the value of the sleep timer; this value is used later to update OSAL
// 498 * timers. Then the timeout value is converted from 320 usec units to 32 kHz
// 499 * period units and the compare value is set to the timeout.
// 500 *
// 501 * input parameters
// 502 *
// 503 * @param timeout - Timeout value in 320 usec units. The sleep timer compare is set to
// 504 * this value.
// 505 *
// 506 * output parameters
// 507 *
// 508 * None.
// 509 *
// 510 * @return None.
// 511 **************************************************************************************************
// 512 */
RSEG BANKED_CODE:CODE:NOROOT(0)
// 513 void halSleepSetTimer(uint32 timeout)
halSleepSetTimer:
CFI Block cfiBlock1 Using cfiCommon0
CFI Function halSleepSetTimer
// 514 {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -