///////////////////////////////////////////////////////////////////////////////
//                                                                            /
// IAR 8051 C/C++ Compiler V7.30B/W32                   12/Sep/2010  21:57:34 /
// Copyright 2004-2007 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        =  C:\Texas Instruments 33\ZStack-1.4.3-1.2.1\Compon /
//                          ents\hal\target\CC2430BB\hal_sleep.c              /
//    Command line       =  -f "C:\Texas Instruments                          /
//                          33\ZStack-1.4.3-1.2.1\Projects\zstack\Project\Loc /
//                          ation\CC2430DB\..\..\..\Tools\CC2430DB\f8wRouter. /
//                          cfg" (-DCPU32MHZ -DFORCE_MAC_NEAR                 /
//                          -DROOT=__near_func -DMAC_CFG_APP_PENDING_QUEUE=TR /
//                          UE -DRTR_NWK -DBLINK_LEDS "-DCONST=const __code"  /
//                          -DGENERIC=__generic) -f "C:\Texas Instruments     /
//                          33\ZStack-1.4.3-1.2.1\Projects\zstack\Project\Loc /
//                          ation\CC2430DB\..\..\..\Tools\CC2430DB\f8wConfig. /
//                          cfg" (-DSECURE=1 -DDEFAULT_CHANLIST=0x04000000    /
//                          -DZDAPP_CONFIG_PAN_ID=0x00FF                      /
//                          -DNWK_START_DELAY=100 -DEXTENDED_JOINING_RANDOM_M /
//                          ASK=0x007F -DBEACON_REQUEST_DELAY=100             /
//                          -DBEACON_REQ_DELAY_MASK=0x00FF                    /
//                          -DROUTE_EXPIRY_TIME=30 -DAPSC_ACK_WAIT_DURATION_P /
//                          OLLED=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={0x02, 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  /
//                          "C:\Texas Instruments 33\ZStack-1.4.3-1.2.1\Compo /
//                          nents\hal\target\CC2430BB\hal_sleep.c" -D         /
//                          CC2430EB -D LOCATION_REFNODE -D xNV_RESTORE -D    /
//                          ZTOOL_P1 -D MT_TASK -D POWER_SAVING -D            /
//                          HAL_UART_BIG_TX_BUF=1 -D                          /
//                          SPI_MGR_DEFAULT_MAX_TX_BUFF=1024 -D               /
//                          SPI_MGR_DEFAULT_OVERFLOW=1 -lC "C:\Texas          /
//                          Instruments 33\ZStack-1.4.3-1.2.1\Projects\zstack /
//                          \Project\Location\CC2430DB\RefNode\List\" -lA     /
//                          "C:\Texas Instruments 33\ZStack-1.4.3-1.2.1\Proje /
//                          cts\zstack\Project\Location\CC2430DB\RefNode\List /
//                          \" --diag_suppress Pe001,Pa010 --diag_remark      /
//                          pe550 -o "C:\Texas Instruments                    /
//                          33\ZStack-1.4.3-1.2.1\Projects\zstack\Project\Loc /
//                          ation\CC2430DB\RefNode\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 -I     /
//                          "C:\Texas Instruments 33\ZStack-1.4.3-1.2.1\Proje /
//                          cts\zstack\Project\Location\CC2430DB\" -I         /
//                          "C:\Texas Instruments 33\ZStack-1.4.3-1.2.1\Proje /
//                          cts\zstack\Project\Location\CC2430DB\..\SOURCE\"  /
//                          -I "C:\Texas Instruments                          /
//                          33\ZStack-1.4.3-1.2.1\Projects\zstack\Project\Loc /
//                          ation\CC2430DB\..\..\..\ZMAIN\TI2430DB\" -I       /
//                          "C:\Texas Instruments 33\ZStack-1.4.3-1.2.1\Proje /
//                          cts\zstack\Project\Location\CC2430DB\..\..\..\..\ /
//                          ..\COMPONENTS\MT\" -I "C:\Texas Instruments       /
//                          33\ZStack-1.4.3-1.2.1\Projects\zstack\Project\Loc /
//                          ation\CC2430DB\..\..\..\..\..\COMPONENTS\HAL\INCL /
//                          UDE\" -I "C:\Texas Instruments                    /
//                          33\ZStack-1.4.3-1.2.1\Projects\zstack\Project\Loc /
//                          ation\CC2430DB\..\..\..\..\..\COMPONENTS\HAL\TARG /
//                          ET\CC2430BB\" -I "C:\Texas Instruments            /
//                          33\ZStack-1.4.3-1.2.1\Projects\zstack\Project\Loc /
//                          ation\CC2430DB\..\..\..\..\..\COMPONENTS\OSAL\MCU /
//                          \CCSOC\" -I "C:\Texas Instruments                 /
//                          33\ZStack-1.4.3-1.2.1\Projects\zstack\Project\Loc /
//                          ation\CC2430DB\..\..\..\..\..\COMPONENTS\OSAL\INC /
//                          LUDE\" -I "C:\Texas Instruments                   /
//                          33\ZStack-1.4.3-1.2.1\Projects\zstack\Project\Loc /
//                          ation\CC2430DB\..\..\..\..\..\COMPONENTS\STACK\AF /
//                          \" -I "C:\Texas Instruments                       /
//                          33\ZStack-1.4.3-1.2.1\Projects\zstack\Project\Loc /
//                          ation\CC2430DB\..\..\..\..\..\COMPONENTS\STACK\NW /
//                          K\" -I "C:\Texas Instruments                      /
//                          33\ZStack-1.4.3-1.2.1\Projects\zstack\Project\Loc /
//                          ation\CC2430DB\..\..\..\..\..\COMPONENTS\STACK\SE /
//                          C\" -I "C:\Texas Instruments                      /
//                          33\ZStack-1.4.3-1.2.1\Projects\zstack\Project\Loc /
//                          ation\CC2430DB\..\..\..\..\..\COMPONENTS\STACK\SY /
//                          S\" -I "C:\Texas Instruments                      /
//                          33\ZStack-1.4.3-1.2.1\Projects\zstack\Project\Loc /
//                          ation\CC2430DB\..\..\..\..\..\COMPONENTS\STACK\ZD /
//                          O\" -I "C:\Texas Instruments                      /
//                          33\ZStack-1.4.3-1.2.1\Projects\zstack\Project\Loc /
//                          ation\CC2430DB\..\..\..\..\..\COMPONENTS\ZMAC\F8W /
//                          \" -I "C:\Texas Instruments                       /
//                          33\ZStack-1.4.3-1.2.1\Projects\zstack\Project\Loc /
//                          ation\CC2430DB\..\..\..\..\..\COMPONENTS\ZMAC\"   /
//                          -I "C:\Texas Instruments                          /
//                          33\ZStack-1.4.3-1.2.1\Projects\zstack\Project\Loc /
//                          ation\CC2430DB\..\..\..\..\..\COMPONENTS\SERVICES /
//                          \SADDR\" -I "C:\Texas Instruments                 /
//                          33\ZStack-1.4.3-1.2.1\Projects\zstack\Project\Loc /
//                          ation\CC2430DB\..\..\..\..\..\COMPONENTS\SERVICES /
//                          \SDATA\" -I "C:\Texas Instruments                 /
//                          33\ZStack-1.4.3-1.2.1\Projects\zstack\Project\Loc /
//                          ation\CC2430DB\..\..\..\..\..\COMPONENTS\MAC\INCL /
//                          UDE\" -I "C:\Texas Instruments                    /
//                          33\ZStack-1.4.3-1.2.1\Projects\zstack\Project\Loc /
//                          ation\CC2430DB\..\..\..\..\..\COMPONENTS\MAC\HIGH /
//                          _LEVEL\" -I "C:\Texas Instruments                 /
//                          33\ZStack-1.4.3-1.2.1\Projects\zstack\Project\Loc /
//                          ation\CC2430DB\..\..\..\..\..\COMPONENTS\MAC\LOW_ /
//                          LEVEL\SRF03\" -I "C:\Texas Instruments            /
//                          33\ZStack-1.4.3-1.2.1\Projects\zstack\Project\Loc /
//                          ation\CC2430DB\..\..\..\..\..\COMPONENTS\MAC\LOW_ /
//                          LEVEL\SRF03\SINGLE_CHIP\" -I "C:\Program          /
//                          Files\IAR Systems\Embedded Workbench 4.0          /
//                          Evaluation version\8051\INC\" -I "C:\Program      /
//                          Files\IAR Systems\Embedded Workbench 4.0          /
//                          Evaluation version\8051\INC\CLIB\"                /
//    List file          =  C:\Texas Instruments 33\ZStack-1.4.3-1.2.1\Projec /
//                          ts\zstack\Project\Location\CC2430DB\RefNode\List\ /
//                          hal_sleep.s51                                     /
//                                                                            /
//                                                                            /
///////////////////////////////////////////////////////////////////////////////

        NAME hal_sleep

        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 XSP:DATA:REORDER:NOROOT(0)
        RSEG XSTACK:XDATA:NOROOT(0)

        EXTERN ??HalTimerElapsed?relay
        EXTERN ??halSleepSetTimer?relay
        EXTERN ??halSleepWait?relay
        EXTERN ?ALLOC_XSTACK8
        EXTERN ?BANKED_ENTER_XDATA
        EXTERN ?BANKED_LEAVE_XDATA
        EXTERN ?BDISPATCH
        EXTERN ?BRET
        EXTERN ?DEALLOC_XSTACK8
        EXTERN ?L_ADD_TO_X
        EXTERN ?L_ADD_X
        EXTERN ?L_AND_X
        EXTERN ?L_EQ_X
        EXTERN ?L_MOV_TO_X
        EXTERN ?L_MOV_X
        EXTERN ?L_MUL
        EXTERN ?L_SUB_X
        EXTERN ?UL_GT
        EXTERN ?UL_GT_X
        EXTERN ?UL_SHR
        EXTERN ?V0
        EXTERN ?XSP
        EXTERN ?XSTACK_DISP0_8
        EXTERN __INIT_XDATA_I
        EXTERN __INIT_XDATA_Z

        PUBLIC ??HalTimerElapsed?relay
        FUNCTION ??HalTimerElapsed?relay,0203H
        PUBLIC ??TimerElapsed?relay
        FUNCTION ??TimerElapsed?relay,0203H
        PUBLIC ??halRestoreSleepLevel?relay
        FUNCTION ??halRestoreSleepLevel?relay,0203H
        PUBLIC ??halSleep?relay
        FUNCTION ??halSleep?relay,0203H
        PUBLIC ??halSleepSetTimer?relay
        FUNCTION ??halSleepSetTimer?relay,0203H
        PUBWEAK `??halSleepTimerIsr??INTVEC 43`
        PUBLIC ??halSleepWait?relay
        FUNCTION ??halSleepWait?relay,0203H
        PUBWEAK CLKCON
        PUBLIC HalTimerElapsed
        FUNCTION HalTimerElapsed,0203H
        ARGFRAME XSTACK, 21, STACK
        ARGFRAME IOVERLAY, 0, STATIC
        ARGFRAME DOVERLAY, 0, STATIC
        LOCFRAME ISTACK, 1, STACK
        LOCFRAME XSTACK, 20, STACK
        PUBWEAK IEN2
        PUBWEAK P0DIR
        PUBWEAK P0INP
        PUBWEAK PCON
        PUBWEAK SLEEP
        PUBWEAK ST0
        PUBWEAK ST1
        PUBWEAK ST2
        PUBLIC TimerElapsed
        FUNCTION TimerElapsed,0203H
        ARGFRAME XSTACK, 0, STACK
        LOCFRAME XSTACK, 12, STACK
        PUBWEAK _A_IEN0
        PUBWEAK _A_IEN1
        PUBWEAK _A_IRCON
        PUBWEAK _A_P0
        PUBWEAK __Constant_0
        PUBWEAK __Constant_185196
        PUBWEAK __Constant_185197
        PUBWEAK __Constant_1f
        PUBWEAK __Constant_22
        PUBWEAK __Constant_29f
        PUBWEAK __Constant_2d
        PUBWEAK __Constant_64
        PUBWEAK __Constant_7d
        PUBWEAK __Constant_ffe7ae6a
        PUBWEAK __Constant_fff
        PUBWEAK __Constant_ffff7f
        PUBWEAK __Constant_ffff80
        PUBWEAK __Constant_ffffff
        PUBWEAK __Constant_ffffffde
        PUBLIC halRestoreSleepLevel
        FUNCTION halRestoreSleepLevel,0203H
        ARGFRAME XSTACK, 0, STACK
        LOCFRAME ISTACK, 2, STACK
        PUBLIC halSleep
        FUNCTION halSleep,0a1203H
        ARGFRAME XSTACK, 0, STACK
        LOCFRAME ISTACK, 2, STACK
        LOCFRAME XSTACK, 21, STACK
        PUBLIC halSleepSetTimer
        FUNCTION halSleepSetTimer,0203H
        ARGFRAME XSTACK, 21, STACK
        ARGFRAME IOVERLAY, 0, STATIC
        ARGFRAME DOVERLAY, 0, STATIC
        LOCFRAME ISTACK, 2, STACK
        LOCFRAME XSTACK, 20, STACK
        PUBLIC halSleepTimerIsr
        FUNCTION halSleepTimerIsr,0233H
        ARGFRAME XSTACK, 0, STACK
        LOCFRAME ISTACK, 4, STACK
        PUBLIC halSleepWait
        FUNCTION halSleepWait,080203H
        ARGFRAME XSTACK, 21, STACK
        ARGFRAME IOVERLAY, 0, STATIC
        ARGFRAME DOVERLAY, 0, STATIC
        
        CFI Names cfiNames0
        CFI StackFrame CFA_SP SP DATA
        CFI StackFrame CFA_PSP16 PSP16 XDATA
        CFI StackFrame CFA_XSP16 XSP16 XDATA
        CFI StaticOverlayFrame CFA_IOVERLAY IOVERLAY
        CFI StaticOverlayFrame CFA_DOVERLAY DOVERLAY
        CFI Resource `PSW.CY`:1, `B.BR0`:1, `B.BR1`:1, `B.BR2`:1, `B.BR3`:1
        CFI Resource `B.BR4`:1, `B.BR5`:1, `B.BR6`:1, `B.BR7`:1, `VB.BR8`:1
        CFI Resource `VB.BR9`:1, `VB.BR10`:1, `VB.BR11`:1, `VB.BR12`:1
        CFI Resource `VB.BR13`:1, `VB.BR14`:1, `VB.BR15`:1, VB:8, B:8, A:8
        CFI Resource PSW:8, DPL0:8, DPH0:8, R0:8, R1:8, R2:8, R3:8, R4:8, R5:8
        CFI Resource R6:8, R7:8, V0:8, V1:8, V2:8, V3:8, V4:8, V5:8, V6:8, V7:8
        CFI Resource SP:8, PSPH:8, PSPL:8, PSP16:16, XSPH:8, XSPL:8, XSP16:16
        CFI VirtualResource ?RET:24
        CFI Resource ?BRET_EXT:8
        CFI VirtualResource ?RET_HIGH:8, ?RET_LOW:8
        CFI ResourceParts PSP16 PSPH, PSPL
        CFI ResourceParts XSP16 XSPH, XSPL
        CFI ResourceParts ?RET ?BRET_EXT, ?RET_HIGH, ?RET_LOW
        CFI EndNames cfiNames0
        
        CFI Common cfiCommon0 Using cfiNames0
        CFI CodeAlign 1
        CFI DataAlign -1
        CFI ReturnAddress ?RET CODE
        CFI CFA_DOVERLAY Used
        CFI CFA_IOVERLAY Used
        CFI CFA_SP SP+-3
        CFI CFA_PSP16 PSP16+0
        CFI CFA_XSP16 XSP16+0
        CFI `PSW.CY` SameValue
        CFI `B.BR0` SameValue
        CFI `B.BR1` SameValue
        CFI `B.BR2` SameValue
        CFI `B.BR3` SameValue
        CFI `B.BR4` SameValue
        CFI `B.BR5` SameValue
        CFI `B.BR6` SameValue
        CFI `B.BR7` SameValue
        CFI `VB.BR8` SameValue
        CFI `VB.BR9` SameValue
        CFI `VB.BR10` SameValue
        CFI `VB.BR11` SameValue
        CFI `VB.BR12` SameValue
        CFI `VB.BR13` SameValue
        CFI `VB.BR14` SameValue
        CFI `VB.BR15` SameValue
        CFI VB SameValue
        CFI B Undefined
        CFI A Undefined
        CFI PSW SameValue
        CFI DPL0 SameValue
        CFI DPH0 SameValue
        CFI R0 Undefined
        CFI R1 Undefined
        CFI R2 Undefined
        CFI R3 Undefined
        CFI R4 Undefined
        CFI R5 Undefined
        CFI R6 SameValue
        CFI R7 SameValue
        CFI V0 SameValue
        CFI V1 SameValue
        CFI V2 SameValue
        CFI V3 SameValue
        CFI V4 SameValue
        CFI V5 SameValue
        CFI V6 SameValue
        CFI V7 SameValue
        CFI PSPH Undefined
        CFI PSPL Undefined
        CFI XSPH Undefined
        CFI XSPL Undefined
        CFI ?RET Concat
        CFI ?BRET_EXT Frame(CFA_SP, 3)
        CFI ?RET_HIGH Frame(CFA_SP, 2)
        CFI ?RET_LOW Frame(CFA_SP, 1)
        CFI EndCommon cfiCommon0
        
        
        CFI Common cfiCommon1 Using cfiNames0
        CFI CodeAlign 1
        CFI DataAlign -1
        CFI ReturnAddress ?RET CODE
        CFI CFA_DOVERLAY Used
        CFI CFA_IOVERLAY Used
        CFI CFA_SP SP+-2
        CFI CFA_PSP16 PSP16+0
        CFI CFA_XSP16 XSP16+0
        CFI `PSW.CY` SameValue
        CFI `B.BR0` SameValue
        CFI `B.BR1` SameValue
        CFI `B.BR2` SameValue
        CFI `B.BR3` SameValue
        CFI `B.BR4` SameValue
        CFI `B.BR5` SameValue
        CFI `B.BR6` SameValue
        CFI `B.BR7` SameValue
        CFI `VB.BR8` SameValue
        CFI `VB.BR9` SameValue
        CFI `VB.BR10` SameValue
        CFI `VB.BR11` SameValue
        CFI `VB.BR12` SameValue
        CFI `VB.BR13` SameValue
        CFI `VB.BR14` SameValue
        CFI `VB.BR15` SameValue
        CFI VB SameValue
        CFI B SameValue
        CFI A SameValue
        CFI PSW SameValue
        CFI DPL0 SameValue
        CFI DPH0 SameValue
        CFI R0 SameValue
        CFI R1 SameValue
        CFI R2 SameValue
        CFI R3 SameValue
        CFI R4 SameValue
        CFI R5 SameValue
        CFI R6 SameValue
        CFI R7 SameValue
        CFI V0 SameValue
        CFI V1 SameValue
        CFI V2 SameValue
        CFI V3 SameValue
        CFI V4 SameValue
        CFI V5 SameValue
        CFI V6 SameValue
        CFI V7 SameValue
        CFI PSPH Undefined
        CFI PSPL Undefined
        CFI XSPH Undefined
        CFI XSPL Undefined
        CFI ?RET Concat
        CFI ?BRET_EXT SameValue
        CFI ?RET_HIGH Frame(CFA_SP, 2)
        CFI ?RET_LOW Frame(CFA_SP, 1)
        CFI EndCommon cfiCommon1
        
MAC_PwrNextTimeout  SYMBOL "MAC_PwrNextTimeout"
MAC_PwrOffReq       SYMBOL "MAC_PwrOffReq"
HalKeyEnterSleep    SYMBOL "HalKeyEnterSleep"
HalLedEnterSleep    SYMBOL "HalLedEnterSleep"
HalLedExitSleep     SYMBOL "HalLedExitSleep"
HalKeyExitSleep     SYMBOL "HalKeyExitSleep"
MAC_PwrOnReq        SYMBOL "MAC_PwrOnReq"
osal_adjust_timers  SYMBOL "osal_adjust_timers"
??HalKeyEnterSleep?relay SYMBOL "?relay", HalKeyEnterSleep
??HalKeyExitSleep?relay SYMBOL "?relay", HalKeyExitSleep
??HalLedEnterSleep?relay SYMBOL "?relay", HalLedEnterSleep
??HalLedExitSleep?relay SYMBOL "?relay", HalLedExitSleep
??MAC_PwrNextTimeout?relay SYMBOL "?relay", MAC_PwrNextTimeout
??MAC_PwrOffReq?relay SYMBOL "?relay", MAC_PwrOffReq
??MAC_PwrOnReq?relay SYMBOL "?relay", MAC_PwrOnReq
??osal_adjust_timers?relay SYMBOL "?relay", osal_adjust_timers
HalTimerElapsed     SYMBOL "HalTimerElapsed"
??HalTimerElapsed?relay SYMBOL "?relay", HalTimerElapsed
TimerElapsed        SYMBOL "TimerElapsed"
??TimerElapsed?relay SYMBOL "?relay", TimerElapsed
halRestoreSleepLevel SYMBOL "halRestoreSleepLevel"
??halRestoreSleepLevel?relay SYMBOL "?relay", halRestoreSleepLevel
halSleep            SYMBOL "halSleep"
??halSleep?relay    SYMBOL "?relay", halSleep
halSleepSetTimer    SYMBOL "halSleepSetTimer"
??halSleepSetTimer?relay SYMBOL "?relay", halSleepSetTimer
halSleepTimerIsr    SYMBOL "halSleepTimerIsr"
`??halSleepTimerIsr??INTVEC 43` SYMBOL "??INTVEC 43", halSleepTimerIsr
halSleepWait        SYMBOL "halSleepWait"
??halSleepWait?relay SYMBOL "?relay", halSleepWait

        EXTERN MAC_PwrNextTimeout
        FUNCTION MAC_PwrNextTimeout,0202H
        ARGFRAME ISTACK, 0, STACK
        ARGFRAME PSTACK, 0, STACK
        ARGFRAME XSTACK, 21, STACK
        ARGFRAME IOVERLAY, 0, STATIC
        ARGFRAME DOVERLAY, 0, STATIC
        EXTERN MAC_PwrOffReq
        FUNCTION MAC_PwrOffReq,0202H
        ARGFRAME ISTACK, 0, STACK
        ARGFRAME PSTACK, 0, STACK
        ARGFRAME XSTACK, 21, STACK
        ARGFRAME IOVERLAY, 0, STATIC
        ARGFRAME DOVERLAY, 0, STATIC
        EXTERN HalKeyEnterSleep
        FUNCTION HalKeyEnterSleep,0202H
        ARGFRAME ISTACK, 0, STACK
        ARGFRAME PSTACK, 0, STACK
        ARGFRAME XSTACK, 21, STACK
        ARGFRAME IOVERLAY, 0, STATIC
        ARGFRAME DOVERLAY, 0, STATIC
        EXTERN HalLedEnterSleep
        FUNCTION HalLedEnterSleep,0202H
        ARGFRAME ISTACK, 0, STACK
        ARGFRAME PSTACK, 0, STACK
        ARGFRAME XSTACK, 21, STACK
        ARGFRAME IOVERLAY, 0, STATIC
        ARGFRAME DOVERLAY, 0, STATIC
        EXTERN HalLedExitSleep
        FUNCTION HalLedExitSleep,0202H
        ARGFRAME ISTACK, 0, STACK
        ARGFRAME PSTACK, 0, STACK
        ARGFRAME XSTACK, 21, STACK
        ARGFRAME IOVERLAY, 0, STATIC
        ARGFRAME DOVERLAY, 0, STATIC
        EXTERN HalKeyExitSleep
        FUNCTION HalKeyExitSleep,0202H
        ARGFRAME ISTACK, 0, STACK
        ARGFRAME PSTACK, 0, STACK
        ARGFRAME XSTACK, 21, STACK
        ARGFRAME IOVERLAY, 0, STATIC
        ARGFRAME DOVERLAY, 0, STATIC
        EXTERN MAC_PwrOnReq
        FUNCTION MAC_PwrOnReq,0202H
        ARGFRAME ISTACK, 0, STACK
        ARGFRAME PSTACK, 0, STACK
        ARGFRAME XSTACK, 21, STACK
        ARGFRAME IOVERLAY, 0, STATIC
        ARGFRAME DOVERLAY, 0, STATIC
        EXTERN osal_adjust_timers
        FUNCTION osal_adjust_timers,0202H
        ARGFRAME ISTACK, 0, STACK
        ARGFRAME PSTACK, 0, STACK
        ARGFRAME XSTACK, 21, STACK
        ARGFRAME IOVERLAY, 0, STATIC
        ARGFRAME DOVERLAY, 0, STATIC
        EXTERN ??HalKeyEnterSleep?relay
        FUNCTION ??HalKeyEnterSleep?relay,00H
        EXTERN ??HalKeyExitSleep?relay
        FUNCTION ??HalKeyExitSleep?relay,00H
        EXTERN ??HalLedEnterSleep?relay
        FUNCTION ??HalLedEnterSleep?relay,00H
        EXTERN ??HalLedExitSleep?relay
        FUNCTION ??HalLedExitSleep?relay,00H
        EXTERN ??MAC_PwrNextTimeout?relay
        FUNCTION ??MAC_PwrNextTimeout?relay,00H
        EXTERN ??MAC_PwrOffReq?relay
        FUNCTION ??MAC_PwrOffReq?relay,00H
        EXTERN ??MAC_PwrOnReq?relay
        FUNCTION ??MAC_PwrOnReq?relay,00H
        EXTERN ??osal_adjust_timers?relay
        FUNCTION ??osal_adjust_timers?relay,00H

// C:\Texas Instruments 33\ZStack-1.4.3-1.2.1\Components\hal\target\CC2430BB\hal_sleep.c
//    1 /**************************************************************************************************
//    2   Filename:       hal_sleep.c
//    3   Revised:        $Date: 2007-11-01 08:44:53 -0700 (Thu, 01 Nov 2007) $
//    4   Revision:       $Revision: 15821 $
//    5 
//    6   Description:    This module contains the HAL power management procedures for the CC2430.
//    7 
//    8 
//    9   Copyright 2006-2007 Texas Instruments Incorporated. All rights reserved.
//   10 
//   11   IMPORTANT: Your use of this Software is limited to those specific rights
//   12   granted under the terms of a software license agreement between the user
//   13   who downloaded the software, his/her employer (which must be your employer)
//   14   and Texas Instruments Incorporated (the "License").  You may not use this
//   15   Software unless you agree to abide by the terms of the License. The License
//   16   limits your use, and you acknowledge, that the Software may not be modified,
//   17   copied or distributed unless embedded on a Texas Instruments microcontroller
//   18   or used solely and exclusively in conjunction with a Texas Instruments radio
//   19   frequency transceiver, which is integrated into your product.  Other than for
//   20   the foregoing purpose, you may not use, reproduce, copy, prepare derivative
//   21   works of, modify, distribute, perform, display or sell this Software and/or
//   22   its documentation for any purpose.
//   23 
//   24   YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
//   25   PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, 
//   26   INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE, 
//   27   NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
//   28   TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
//   29   NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
//   30   LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
//   31   INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
//   32   OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
//   33   OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
//   34   (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
//   35 
//   36   Should you have any questions regarding your right to use this Software,
//   37   contact Texas Instruments Incorporated at www.TI.com. 
//   38 **************************************************************************************************/
//   39 
//   40 /* ------------------------------------------------------------------------------------------------
//   41  *                                          Includes
//   42  * ------------------------------------------------------------------------------------------------
//   43  */
//   44 #include "hal_types.h"
//   45 #include "hal_mcu.h"

        ASEGN SFR_AN:DATA:NOROOT,080H
// union <unnamed> volatile __sfr _A_P0
_A_P0:
        DS 1

        ASEGN SFR_AN:DATA:NOROOT,087H
// unsigned char volatile __sfr PCON
PCON:
        DS 1

        ASEGN SFR_AN:DATA:NOROOT,08fH
// unsigned char volatile __sfr P0INP
P0INP:
        DS 1

        ASEGN SFR_AN:DATA:NOROOT,095H
// unsigned char volatile __sfr ST0
ST0:
        DS 1

        ASEGN SFR_AN:DATA:NOROOT,096H
// unsigned char volatile __sfr ST1
ST1:
        DS 1

        ASEGN SFR_AN:DATA:NOROOT,097H
// unsigned char volatile __sfr ST2
ST2:
        DS 1

        ASEGN SFR_AN:DATA:NOROOT,09aH
// unsigned char volatile __sfr IEN2
IEN2:
        DS 1

        ASEGN SFR_AN:DATA:NOROOT,0a8H
// union <unnamed> volatile __sfr _A_IEN0
_A_IEN0:
        DS 1

        ASEGN SFR_AN:DATA:NOROOT,0b8H
// union <unnamed> volatile __sfr _A_IEN1
_A_IEN1:
        DS 1

        ASEGN SFR_AN:DATA:NOROOT,0beH
// unsigned char volatile __sfr SLEEP
SLEEP:
        DS 1

        ASEGN SFR_AN:DATA:NOROOT,0c0H
// union <unnamed> volatile __sfr _A_IRCON
_A_IRCON:
        DS 1

        ASEGN SFR_AN:DATA:NOROOT,0c6H
// unsigned char volatile __sfr CLKCON
CLKCON:
        DS 1

        ASEGN SFR_AN:DATA:NOROOT,0fdH
// unsigned char volatile __sfr P0DIR
P0DIR:
        DS 1
//   46 #include "hal_board.h"
//   47 #include "hal_sleep.h"
//   48 #include "hal_led.h"
//   49 #include "hal_key.h"
//   50 #include "mac_api.h"
//   51 #include "OSAL.h"
//   52 #include "OSAL_Timers.h"
//   53 #include "OSAL_Tasks.h"
//   54 #include "OSAL_PwrMgr.h"
//   55 #include "OnBoard.h"
//   56 #include "hal_drivers.h"
//   57 
//   58 #if !defined (RTR_NWK) && defined (NWK_AUTO_POLL)
//   59 #include "nwk_globals.h"
//   60 #include "ZGlobals.h"
//   61 #endif
//   62 
//   63 /* ------------------------------------------------------------------------------------------------
//   64  *                                           Macros
//   65  * ------------------------------------------------------------------------------------------------
//   66  */
//   67 
//   68 /* 32 kHz clock source select in CLKCON */
//   69 #if !defined (OSC32K_CRYSTAL_INSTALLED) || (defined (OSC32K_CRYSTAL_INSTALLED) && (OSC32K_CRYSTAL_INSTALLED == TRUE))
//   70 #define OSC_32KHZ                        0x00  /* external 32 KHz xosc */
//   71 #else
//   72 #define OSC_32KHZ                        0x80  /* internal 32 KHz rcosc */
//   73 #endif
//   74 
//   75 /* POWER CONSERVATION DEFINITIONS
//   76  * Sleep mode H/W definitions (enabled with POWER_SAVING compile option)
//   77  */
//   78 #define CC2430_PM0            0  /* PM0, Clock oscillators on, voltage regulator on */
//   79 #define CC2430_PM1            1  /* PM1, 32.768 kHz oscillators on, voltage regulator on */
//   80 #define CC2430_PM2            2  /* PM2, 32.768 kHz oscillators on, voltage regulator off */
//   81 #define CC2430_PM3            3  /* PM3, All clock oscillators off, voltage regulator off */
//   82 
//   83 /* HAL power management mode is set according to the power management state. The default
//   84  * setting is HAL_SLEEP_OFF. The actual value is tailored to different HW platform. Both
//   85  * HAL_SLEEP_TIMER and HAL_SLEEP_DEEP selections will:
//   86  *   1. turn off the system clock, and
//   87  *   2. halt the MCU.
//   88  * HAL_SLEEP_TIMER can be woken up by sleep timer interrupt, I/O interrupt and reset.
//   89  * HAL_SLEEP_DEEP can be woken up by I/O interrupt and reset.
//   90  */
//   91 #define HAL_SLEEP_OFF         CC2430_PM0
//   92 #define HAL_SLEEP_TIMER       CC2430_PM2
//   93 #define HAL_SLEEP_DEEP        CC2430_PM3
//   94 
//   95 /* MAX_SLEEP_TIME calculation:
//   96  *   Sleep timer maximum duration = 0xFFFF7F / 32768 Hz = 511.996 seconds
//   97  *   Round it to 510 seconds or 510000 ms
//   98  */
//   99 #define MAX_SLEEP_TIME                   510000             /* maximum time to sleep allowed by ST */
//  100 
//  101 /* minimum time to sleep, this macro is to:
//  102  * 1. avoid thrashing in-and-out of sleep with short OSAL timer (~2ms)
//  103  * 2. define minimum safe sleep period for different CC2430 revisions
//  104  * AN044 - MINIMUM SLEEP PERIODS WITH PULL-DOWN RESISTOR
//  105  */
//  106 #if !defined (PM_MIN_SLEEP_TIME)
//  107 #define PM_MIN_SLEEP_TIME                14                 /* default to minimum safe sleep time for CC2430 Rev B */
//  108 #endif
//  109 
//  110 /* to disallow PM2/PM3 and use PM1 only set this value to false
//  111  * AN044 - RESTRICT_USE_TO_PM1_ONLY
//  112  */
//  113 #if !defined (PM1_ONLY)
//  114 #define PM1_ONLY                         FALSE              /* default to no AN044 - RESTRICT USE TO PM1 ONLY */
//  115 #endif
//  116 
//  117 /* when a device is waken up be key interrupt, it
//  118  * should stay in PM1 for PM2_HOLDOFF_TIME expecting
//  119  * more key presses. When the timer is expired, the device
//  120  * is allowed to go back to PM2 sleep.
//  121  * AN044 - COMBINING POWER MODES
//  122  */
//  123 #if !defined (PM2_HOLDOFF_TIME)
//  124 #define PM2_HOLDOFF_TIME                 0
//  125 #endif
//  126 
//  127 /* Add code to set external interrupt line to output, drive the line to inactive level,
//  128  * delay for 180us (30us if P1.0 or P1.1), set the line to input as close to PCON.IDLE = 1
//  129  * as possible, and set the line tri-state. The following macro is using S1 key as an example.
//  130  * User should tailor this macro for different interrupt line(s). On CC2430EB or CC2430DB boards,
//  131  * the S1 key is mapped to P0.1. Thus 180us should be used for delays.
//  132  * AN044 - DELAYING EXTERNAL INTERRUPTS
//  133  */
//  134 #define EXTERNAL_INTERRUPT_DELAY()          st(P0DIR |= BV(1);    /* set P0.1 output */            \ 
//  135                                                P0_1 = 1;          /* drive P0.1 inactive (high) */ \ 
//  136                                                halSleepWait(180); /* delay 180us */                \ 
//  137                                                P0DIR &= ~BV(1);   /* set P0.1 input */             \ 
//  138                                                P0INP |= BV(1);)   /* set P0.1 tri-state */
//  139 
//  140 /* This value is used to adjust the sleep timer compare value such that the sleep timer
//  141  * compare takes into account the amount of processing time spent in function halSleep().
//  142  * The first value is determined by measuring the number of sleep timer ticks it from
//  143  * the beginning of the function to entering sleep mode.  The second value is determined
//  144  * by measuring the number of sleep timer ticks from exit of sleep mode to the call to
//  145  * osal_adjust_timers().
//  146  */
//  147 #define HAL_SLEEP_ADJ_TICKS   (9 + 25)
//  148 
//  149 #ifndef HAL_SLEEP_DEBUG_POWER_MODE
//  150 /* set CC2430 power mode; always use PM2 */
//  151 #define HAL_SLEEP_SET_POWER_MODE(mode)      st( if( CHVER <= REV_D )                    \ 
//  152                                                 {                                       \ 
//  153                                                   HAL_SLEEP_SET_POWER_MODE_REV_D(mode); \ 
//  154                                                 }                                       \ 
//  155                                                 else                                    \ 
//  156                                                 {                                       \ 
//  157                                                   HAL_SLEEP_SET_POWER_MODE_REV_E(mode); \ 
//  158                                                 }; )
//  159 #else
//  160 /* Debug: don't set power mode, just block until sleep timer interrupt */
//  161 #define HAL_SLEEP_SET_POWER_MODE(mode)      st( while(halSleepInt == FALSE); \ 
//  162                                                 halSleepInt = FALSE; )
//  163 #endif
//  164 
//  165 /* for revision E, this sw workaround require additional code in all
//  166  * ISR's that are used to wake up from PM.
//  167  */
//  168 #define HAL_SLEEP_SET_POWER_MODE_REV_E(mode) st( SLEEP &= ~0x03;  /* clear mode bits */               \ 
//  169                                                  SLEEP |= mode;   /* set mode bits   */               \ 
//  170                                                  asm("NOP");                                          \ 
//  171                                                  asm("NOP");                                          \ 
//  172                                                  asm("NOP");                                          \ 
//  173                                                  if( SLEEP & 0x03 )                                   \ 
//  174                                                  {                                                    \ 
//  175                                                    PCON |= 0x01;  /* enable mode */                   \ 
//  176                                                    asm("NOP");    /* first instruction after sleep*/  \ 
//  177                                                  }; )
//  178 
//  179 /* for revision D and earlier */
//  180 #define HAL_SLEEP_SET_POWER_MODE_REV_D(mode)   st(SLEEP &= ~0x03;  /* clear mode bits */               \ 
//  181                                                   SLEEP |= mode;   /* set mode bits   */               \ 
//  182                                                   PCON |= 0x01;    /* enable mode     */               \ 
//  183                                                   asm("NOP");)     /* first instruction after sleep*/
//  184 
//  185 /* set main clock source to crystal (exit sleep) */
//  186 #define HAL_SLEEP_SET_MAIN_CLOCK_CRYSTAL()  st(SLEEP &= ~0x04;          /* turn on both oscs */ \ 
//  187                                                while(!(SLEEP & 0x40));  /* wait for XOSC */     \ 
//  188                                                asm("NOP");                                      \ 
//  189                                                halSleepWait(63);        /* required for Rev B */\ 
//  190                                                CLKCON = (0x00 | OSC_32KHZ);   /* 32MHx XOSC */  \ 
//  191                                                while (CLKCON != (0x00 | OSC_32KHZ));            \ 
//  192                                                SLEEP |= 0x04;)          /* turn off 16MHz RC */
//  193 
//  194 /* set main clock source to RC oscillator (enter sleep) */
//  195 #define HAL_SLEEP_SET_MAIN_CLOCK_RC()       st(SLEEP &= ~0x04;          /* turn on both oscs */     \ 
//  196                                                while(!(SLEEP & 0x20));  /* wait for RC osc */       \ 
//  197                                                asm("NOP");                                          \ 
//  198                                                CLKCON = (0x49 | OSC_32KHZ); /* select RC osc */     \ 
//  199                                                /* wait for requested settings to take effect */     \ 
//  200                                                while (CLKCON != (0x49 | OSC_32KHZ));                \ 
//  201                                                SLEEP |= 0x04;)          /* turn off XOSC */
//  202 
//  203 /* sleep and external interrupt port masks */
//  204 #define STIE_BV                             BV(5)
//  205 #define P0IE_BV                             BV(5)
//  206 #define P1IE_BV                             BV(4)
//  207 #define P2IE_BV                             BV(1)
//  208 
//  209 /* sleep timer interrupt control */
//  210 #define HAL_SLEEP_TIMER_ENABLE_INT()        st(IEN0 |= STIE_BV;)     /* enable sleep timer interrupt */
//  211 #define HAL_SLEEP_TIMER_DISABLE_INT()       st(IEN0 &= ~STIE_BV;)    /* disable sleep timer interrupt */
//  212 #define HAL_SLEEP_TIMER_CLEAR_INT()         st(IRCON &= ~0x80;)      /* clear sleep interrupt flag */
//  213 
//  214 /* backup interrupt enable registers before sleep */
//  215 #define HAL_SLEEP_IE_BACKUP_AND_DISABLE(ien0, ien1, ien2) st(ien0  = IEN0;    /* backup IEN0 register */ \ 
//  216                                                              ien1  = IEN1;    /* backup IEN1 register */ \ 
//  217                                                              ien2  = IEN2;    /* backup IEN2 register */ \ 
//  218                                                              IEN0 &= STIE_BV; /* disable IEN0 except STIE */ \ 
//  219                                                              IEN1 &= P0IE_BV; /* disable IEN1 except P0IE */ \ 
//  220                                                              IEN2 &= (P1IE_BV|P2IE_BV);) /* disable IEN2 except P1IE, P2IE */
//  221 
//  222 /* restore interrupt enable registers before sleep */
//  223 #define HAL_SLEEP_IE_RESTORE(ien0, ien1, ien2) st(IEN0 = ien0;   /* restore IEN0 register */ \ 
//  224                                                   IEN1 = ien1;   /* restore IEN1 register */ \ 
//  225                                                   IEN2 = ien2;)  /* restore IEN2 register */
//  226 
//  227 /* Internal (MCU) Stack addresses. This is to check if the stack is exceeding the disappearing
//  228  * RAM boundary of 0xF000. If the stack does exceed the boundary (unlikely), do not enter sleep
//  229  * until the stack is back to normal.
//  230  */
//  231 #define CSTK_PTR _Pragma("segment=\"XSP\"") __segment_begin("XSP")
//  232 
//  233 /* convert msec to 320 usec units with round */
//  234 #define HAL_SLEEP_MS_TO_320US(ms)           (((((uint32) (ms)) * 100) + 31) / 32)
//  235 
//  236 /* for optimized indexing of uint32's */
//  237 #if HAL_MCU_LITTLE_ENDIAN()
//  238 #define UINT32_NDX0   0
//  239 #define UINT32_NDX1   1
//  240 #define UINT32_NDX2   2
//  241 #define UINT32_NDX3   3
//  242 #else
//  243 #define UINT32_NDX0   3
//  244 #define UINT32_NDX1   2
//  245 #define UINT32_NDX2   1
//  246 #define UINT32_NDX3   0
//  247 #endif
//  248 
//  249 /* ------------------------------------------------------------------------------------------------
//  250  *                                        Local Variables
//  251  * ------------------------------------------------------------------------------------------------
//  252  */
//  253 
//  254 /* HAL power management mode is set according to the power management state.
//  255  */

        RSEG XDATA_Z:XDATA:NOROOT(0)
//  256 static uint8 halPwrMgtMode = HAL_SLEEP_OFF;
halPwrMgtMode:
        DS 1
        REQUIRE __INIT_XDATA_Z
//  257 
//  258 /* stores the sleep timer count upon entering sleep */

        RSEG XDATA_Z:XDATA:NOROOT(0)
//  259 static uint32 halSleepTimerStart;
halSleepTimerStart:
        DS 4
        REQUIRE __INIT_XDATA_Z
//  260 
//  261 /* stores the accumulated sleep time */

        RSEG XDATA_Z:XDATA:NOROOT(0)
//  262 static uint32 halAccumulatedSleepTime;
halAccumulatedSleepTime:
        DS 4
        REQUIRE __INIT_XDATA_Z
//  263 
//  264 /* stores the deepest level the device is allowed to sleep
//  265  * See AN044 - COMBINING POWER MODES
//  266  */

        RSEG XDATA_I:XDATA:NOROOT(0)
        DATA
//  267 static uint8 halSleepLevel = CC2430_PM2;
halSleepLevel:
        DS 1
        REQUIRE `?<Initializer for halSleepLevel>`
        REQUIRE __INIT_XDATA_I

        RSEG XDATA_I:XDATA:NOROOT(0)
        DATA
__Constant_0:
        DS 4
        REQUIRE `?<Initializer for __Constant_0>`
        REQUIRE __INIT_XDATA_I

        RSEG XDATA_I:XDATA:NOROOT(0)
        DATA
__Constant_64:
        DS 4
        REQUIRE `?<Initializer for __Constant_64>`
        REQUIRE __INIT_XDATA_I

        RSEG XDATA_I:XDATA:NOROOT(0)
        DATA
__Constant_1f:
        DS 4
        REQUIRE `?<Initializer for __Constant_1f>`
        REQUIRE __INIT_XDATA_I

        RSEG XDATA_I:XDATA:NOROOT(0)
        DATA
__Constant_2d:
        DS 4
        REQUIRE `?<Initializer for __Constant_2d>`
        REQUIRE __INIT_XDATA_I

        RSEG XDATA_I:XDATA:NOROOT(0)
        DATA
__Constant_185197:
        DS 4
        REQUIRE `?<Initializer for __Constant_185197>`
        REQUIRE __INIT_XDATA_I

        RSEG XDATA_I:XDATA:NOROOT(0)
        DATA
__Constant_ffe7ae6a:
        DS 4
        REQUIRE `?<Initializer for __Constant_ffe7ae6a>`
        REQUIRE __INIT_XDATA_I

        RSEG XDATA_I:XDATA:NOROOT(0)
        DATA
__Constant_185196:
        DS 4
        REQUIRE `?<Initializer for __Constant_185196>`
        REQUIRE __INIT_XDATA_I

        RSEG XDATA_I:XDATA:NOROOT(0)
        DATA
__Constant_29f:
        DS 4
        REQUIRE `?<Initializer for __Constant_29f>`
        REQUIRE __INIT_XDATA_I

        RSEG XDATA_I:XDATA:NOROOT(0)
        DATA
__Constant_ffffffde:
        DS 4
        REQUIRE `?<Initializer for __Constant_ffffffde>`
        REQUIRE __INIT_XDATA_I

        RSEG XDATA_I:XDATA:NOROOT(0)
        DATA
__Constant_ffffff:
        DS 4
        REQUIRE `?<Initializer for __Constant_ffffff>`
        REQUIRE __INIT_XDATA_I

        RSEG XDATA_I:XDATA:NOROOT(0)
        DATA
__Constant_ffff80:
        DS 4
        REQUIRE `?<Initializer for __Constant_ffff80>`
        REQUIRE __INIT_XDATA_I

        RSEG XDATA_I:XDATA:NOROOT(0)
        DATA
__Constant_ffff7f:
        DS 4
        REQUIRE `?<Initializer for __Constant_ffff7f>`
        REQUIRE __INIT_XDATA_I

        RSEG XDATA_I:XDATA:NOROOT(0)
        DATA
__Constant_22:
        DS 4
        REQUIRE `?<Initializer for __Constant_22>`
        REQUIRE __INIT_XDATA_I

        RSEG XDATA_I:XDATA:NOROOT(0)
        DATA
__Constant_7d:
        DS 4
        REQUIRE `?<Initializer for __Constant_7d>`
        REQUIRE __INIT_XDATA_I

        RSEG XDATA_I:XDATA:NOROOT(0)
        DATA
__Constant_fff:
        DS 4
        REQUIRE `?<Initializer for __Constant_fff>`
        REQUIRE __INIT_XDATA_I
//  268 
//  269 #ifdef HAL_SLEEP_DEBUG_POWER_MODE
//  270 static bool halSleepInt = FALSE;
//  271 #endif
//  272 
//  273 /* ------------------------------------------------------------------------------------------------
//  274  *                                      Function Prototypes
//  275  * ------------------------------------------------------------------------------------------------
//  276  */
//  277 
//  278 void halSleepSetTimer(uint32 timeout);
//  279 uint32 HalTimerElapsed( void );
//  280 
//  281 /**************************************************************************************************
//  282  * @fn          halSleep
//  283  *
//  284  * @brief       This function is called from the OSAL task loop using and existing OSAL
//  285  *              interface.  It sets the low power mode of the MAC and the CC2430.
//  286  *
//  287  * input parameters
//  288  *
//  289  * @param       osal_timeout - Next OSAL timer timeout.
//  290  *
//  291  * output parameters
//  292  *
//  293  * None.
//  294  *
//  295  * @return      None.
//  296  **************************************************************************************************
//  297  */

        RSEG BANKED_CODE:CODE:NOROOT(0)
//  298 void halSleep( uint16 osal_timeout )
halSleep:
        CFI Block cfiBlock0 Using cfiCommon0
        CFI Function halSleep
//  299 {
        FUNCALL halSleep, MAC_PwrNextTimeout
        LOCFRAME ISTACK, 0, STACK
        LOCFRAME PSTACK, 0, STACK
        LOCFRAME XSTACK, 21, STACK
        LOCFRAME IOVERLAY, 0, STATIC
        LOCFRAME DOVERLAY, 0, STATIC
        ARGFRAME ISTACK, 0, STACK
        ARGFRAME PSTACK, 0, STACK
        ARGFRAME XSTACK, 21, STACK
        ARGFRAME IOVERLAY, 0, STATIC
        ARGFRAME DOVERLAY, 0, STATIC
        FUNCALL halSleep, MAC_PwrNextTimeout
        LOCFRAME ISTACK, 0, STACK
        LOCFRAME PSTACK, 0, STACK
        LOCFRAME XSTACK, 21, STACK
        LOCFRAME IOVERLAY, 0, STATIC
        LOCFRAME DOVERLAY, 0, STATIC
        ARGFRAME ISTACK, 0, STACK
        ARGFRAME PSTACK, 0, STACK
        ARGFRAME XSTACK, 21, STACK
        ARGFRAME IOVERLAY, 0, STATIC
        ARGFRAME DOVERLAY, 0, STATIC
        FUNCALL halSleep, MAC_PwrOffReq
        LOCFRAME ISTACK, 0, STACK
        LOCFRAME PSTACK, 0, STACK
        LOCFRAME XSTACK, 21, STACK
        LOCFRAME IOVERLAY, 0, STATIC
        LOCFRAME DOVERLAY, 0, STATIC
        ARGFRAME ISTACK, 0, STACK
        ARGFRAME PSTACK, 0, STACK
        ARGFRAME XSTACK, 21, STACK
        ARGFRAME IOVERLAY, 0, STATIC
        ARGFRAME DOVERLAY, 0, STATIC
        FUNCALL halSleep, HalKeyEnterSleep
        LOCFRAME ISTACK, 0, STACK
        LOCFRAME PSTACK, 0, STACK
        LOCFRAME XSTACK, 21, STACK
        LOCFRAME IOVERLAY, 0, STATIC
        LOCFRAME DOVERLAY, 0, STATIC
        ARGFRAME ISTACK, 0, STACK
        ARGFRAME PSTACK, 0, STACK
        ARGFRAME XSTACK, 21, STACK
        ARGFRAME IOVERLAY, 0, STATIC
        ARGFRAME DOVERLAY, 0, STATIC
        FUNCALL halSleep, HalLedEnterSleep
        LOCFRAME ISTACK, 0, STACK
        LOCFRAME PSTACK, 0, STACK
        LOCFRAME XSTACK, 21, STACK
        LOCFRAME IOVERLAY, 0, STATIC
        LOCFRAME DOVERLAY, 0, STATIC
        ARGFRAME ISTACK, 0, STACK
        ARGFRAME PSTACK, 0, STACK
        ARGFRAME XSTACK, 21, STACK
        ARGFRAME IOVERLAY, 0, STATIC
        ARGFRAME DOVERLAY, 0, STATIC
        FUNCALL halSleep, halSleepSetTimer
        LOCFRAME ISTACK, 0, STACK
        LOCFRAME PSTACK, 0, STACK
        LOCFRAME XSTACK, 21, STACK
        LOCFRAME IOVERLAY, 0, STATIC
        LOCFRAME DOVERLAY, 0, STATIC
        ARGFRAME ISTACK, 0, STACK
        ARGFRAME PSTACK, 0, STACK
        ARGFRAME XSTACK, 21, STACK
        ARGFRAME IOVERLAY, 0, STATIC
        ARGFRAME DOVERLAY, 0, STATIC
        FUNCALL halSleep, halSleepSetTimer
        LOCFRAME ISTACK, 0, STACK
        LOCFRAME PSTACK, 0, STACK
        LOCFRAME XSTACK, 21, STACK
        LOCFRAME IOVERLAY, 0, STATIC
        LOCFRAME DOVERLAY, 0, STATIC
        ARGFRAME ISTACK, 0, STACK
        ARGFRAME PSTACK, 0, STACK
        ARGFRAME XSTACK, 21, STACK
        ARGFRAME IOVERLAY, 0, STATIC
        ARGFRAME DOVERLAY, 0, STATIC
        FUNCALL halSleep, halSleepWait
        LOCFRAME ISTACK, 0, STACK
        LOCFRAME PSTACK, 0, STACK
        LOCFRAME XSTACK, 21, STACK
        LOCFRAME IOVERLAY, 0, STATIC
        LOCFRAME DOVERLAY, 0, STATIC
        ARGFRAME ISTACK, 0, STACK
        ARGFRAME PSTACK, 0, STACK
        ARGFRAME XSTACK, 21, STACK
        ARGFRAME IOVERLAY, 0, STATIC
        ARGFRAME DOVERLAY, 0, STATIC
        FUNCALL halSleep, halSleepWait
        LOCFRAME ISTACK, 0, STACK
        LOCFRAME PSTACK, 0, STACK
        LOCFRAME XSTACK, 21, STACK
        LOCFRAME IOVERLAY, 0, STATIC
        LOCFRAME DOVERLAY, 0, STATIC
        ARGFRAME ISTACK, 0, STACK
        ARGFRAME PSTACK, 0, STACK
        ARGFRAME XSTACK, 21, STACK
        ARGFRAME IOVERLAY, 0, STATIC
        ARGFRAME DOVERLAY, 0, STATIC
        FUNCALL halSleep, HalTimerElapsed
        LOCFRAME ISTACK, 0, STACK
        LOCFRAME PSTACK, 0, STACK
        LOCFRAME XSTACK, 21, STACK
        LOCFRAME IOVERLAY, 0, STATIC
        LOCFRAME DOVERLAY, 0, STATIC
        ARGFRAME ISTACK, 0, STACK
        ARGFRAME PSTACK, 0, STACK
        ARGFRAME XSTACK, 21, STACK
        ARGFRAME IOVERLAY, 0, STATIC
        ARGFRAME DOVERLAY, 0, STATIC
        FUNCALL halSleep, halSleepWait
        LOCFRAME ISTACK, 0, STACK
        LOCFRAME PSTACK, 0, STACK
        LOCFRAME XSTACK, 21, STACK
        LOCFRAME IOVERLAY, 0, STATIC
        LOCFRAME DOVERLAY, 0, STATIC
        ARGFRAME ISTACK, 0, STACK
        ARGFRAME PSTACK, 0, STACK
        ARGFRAME XSTACK, 21, STACK
        ARGFRAME IOVERLAY, 0, STATIC
        ARGFRAME DOVERLAY, 0, STATIC
        FUNCALL halSleep, HalLedExitSleep
        LOCFRAME ISTACK, 0, STACK
        LOCFRAME PSTACK, 0, STACK
        LOCFRAME XSTACK, 21, STACK
        LOCFRAME IOVERLAY, 0, STATIC
        LOCFRAME DOVERLAY, 0, STATIC
        ARGFRAME ISTACK, 0, STACK
        ARGFRAME PSTACK, 0, STACK
        ARGFRAME XSTACK, 21, STACK
        ARGFRAME IOVERLAY, 0, STATIC
        ARGFRAME DOVERLAY, 0, STATIC
        FUNCALL halSleep, HalKeyExitSleep
        LOCFRAME ISTACK, 0, STACK
        LOCFRAME PSTACK, 0, STACK
        LOCFRAME XSTACK, 21, STACK
        LOCFRAME IOVERLAY, 0, STATIC
        LOCFRAME DOVERLAY, 0, STATIC
        ARGFRAME ISTACK, 0, STACK
        ARGFRAME PSTACK, 0, STACK
        ARGFRAME XSTACK, 21, STACK
        ARGFRAME IOVERLAY, 0, STATIC
        ARGFRAME DOVERLAY, 0, STATIC
        FUNCALL halSleep, MAC_PwrOnReq
        LOCFRAME ISTACK, 0, STACK
        LOCFRAME PSTACK, 0, STACK
        LOCFRAME XSTACK, 21, STACK
        LOCFRAME IOVERLAY, 0, STATIC
        LOCFRAME DOVERLAY, 0, STATIC
        ARGFRAME ISTACK, 0, STACK
        ARGFRAME PSTACK, 0, STACK
        ARGFRAME XSTACK, 21, STACK
        ARGFRAME IOVERLAY, 0, STATIC
        ARGFRAME DOVERLAY, 0, STATIC
        FUNCALL halSleep, osal_adjust_timers
        LOCFRAME ISTACK, 0, STACK
        LOCFRAME PSTACK, 0, STACK
        LOCFRAME XSTACK, 21, STACK
        LOCFRAME IOVERLAY, 0, STATIC
        LOCFRAME DOVERLAY, 0, STATIC
        ARGFRAME ISTACK, 0, STACK
        ARGFRAME PSTACK, 0, STACK
        ARGFRAME XSTACK, 21, STACK
        ARGFRAME IOVERLAY, 0, STATIC
        ARGFRAME DOVERLAY, 0, STATIC
        MOV     A,#-0x10
        LCALL   ?BANKED_ENTER_XDATA
        CFI DPH0 load(1, XDATA, add(CFA_XSP16, literal(-1)))
        CFI DPL0 load(1, XDATA, add(CFA_XSP16, literal(-2)))
        CFI ?BRET_EXT load(1, XDATA, add(CFA_XSP16, literal(-3)))
        CFI ?RET_HIGH load(1, XDATA, add(CFA_XSP16, literal(-4)))
        CFI ?RET_LOW load(1, XDATA, add(CFA_XSP16, literal(-5)))
        CFI R7 load(1, XDATA, add(CFA_XSP16, literal(-6)))
        CFI V7 load(1, XDATA, add(CFA_XSP16, literal(-7)))
        CFI V6 load(1, XDATA, add(CFA_XSP16, literal(-8)))
        CFI V5 load(1, XDATA, add(CFA_XSP16, literal(-9)))
        CFI V4 load(1, XDATA, add(CFA_XSP16, literal(-10)))
        CFI V3 load(1, XDATA, add(CFA_XSP16, literal(-11)))
        CFI V2 load(1, XDATA, add(CFA_XSP16, literal(-12)))
        CFI V1 load(1, XDATA, add(CFA_XSP16, literal(-13)))
        CFI V0 load(1, XDATA, add(CFA_XSP16, literal(-14)))
        CFI VB load(1, XDATA, add(CFA_XSP16, literal(-15)))
        CFI R6 load(1, XDATA, add(CFA_XSP16, literal(-16)))
        CFI CFA_SP SP+0
        CFI CFA_XSP16 add(XSP16, 16)
        ; Saved register size: 16
        ; Auto size: 5
        MOV     A,#-0x5
        LCALL   ?ALLOC_XSTACK8
        CFI CFA_XSP16 add(XSP16, 21)
        MOV     A,R2
        MOV     R6,A
        MOV     A,R3
        MOV     R7,A
//  300   uint32        timeout;
//  301   uint32        macTimeout;
//  302 
//  303   halAccumulatedSleepTime = 0;
        MOV     DPTR,#__Constant_0
        MOV     R0,#?V0 + 0
        LCALL   ?L_MOV_X
        MOV     DPTR,#halAccumulatedSleepTime
        MOV     R0,#?V0 + 0
        LCALL   ?L_MOV_TO_X
//  304 
//  305   /* get next OSAL timer expiration converted to 320 usec units */
//  306   timeout = HAL_SLEEP_MS_TO_320US(osal_timeout);
        MOV     ?V0 + 4,R6
        MOV     ?V0 + 5,R7
        MOV     ?V0 + 6,#0x0
        MOV     ?V0 + 7,#0x0
        MOV     DPTR,#__Constant_64
        MOV     R0,#?V0 + 0
        LCALL   ?L_MOV_X
        MOV     R0,#?V0 + 4
        MOV     R1,#?V0 + 0
        LCALL   ?L_MUL
        MOV     DPTR,#__Constant_1f
        MOV     R0,#?V0 + 4
        LCALL   ?L_ADD_X
        MOV     A,#0x5
        MOV     R0,#?V0 + 4
        LCALL   ?UL_SHR
        MOV     DPL,?XSP + 0
        MOV     DPH,?XSP + 1
        MOV     R0,#?V0 + 4
        LCALL   ?L_MOV_TO_X
//  307   if (timeout == 0)
        MOV     DPL,?XSP + 0
        MOV     DPH,?XSP + 1
        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
        JNZ     ??halSleep_0
//  308   {
//  309     timeout = MAC_PwrNextTimeout();
        ; Setup parameters for call to function MAC_PwrNextTimeout
        LCALL   ?Subroutine0 & 0xFFFF
??CrossCallReturnLabel_0:
        MOV     DPL,?XSP + 0
        MOV     DPH,?XSP + 1
        MOV     R0,#?V0 + 0
        LCALL   ?L_MOV_TO_X
//  310   }
//  311   else
//  312   {
//  313     /* get next MAC timer expiration */
//  314     macTimeout = MAC_PwrNextTimeout();
//  315 
//  316     /* get lesser of two timeouts */
//  317     if ((macTimeout != 0) && (macTimeout < timeout))
//  318     {
//  319       timeout = macTimeout;
//  320     }
//  321   }
//  322 
//  323   /* HAL_SLEEP_PM2 is entered only if the timeout is zero and
//  324    * the device is a stimulated device.
//  325    */
//  326   halPwrMgtMode = (timeout == 0) ? HAL_SLEEP_DEEP : HAL_SLEEP_TIMER;
        MOV     DPL,?XSP + 0
        MOV     DPH,?XSP + 1
        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
        JNZ     ??halSleep_1
        MOV     R2,#0x3
        SJMP    ??halSleep_2
??halSleep_0:
        ; Setup parameters for call to function MAC_PwrNextTimeout
        LCALL   ?Subroutine0 & 0xFFFF
??CrossCallReturnLabel_1:
        MOV     DPTR,#__Constant_0
        MOV     R0,#?V0 + 0
        LCALL   ?L_EQ_X
        JZ      ??halSleep_1
        MOV     DPL,?XSP + 0
        MOV     DPH,?XSP + 1
        MOV     R0,#?V0 + 4
        LCALL   ?L_MOV_X
        MOV     R0,#?V0 + 4
        MOV     R1,#?V0 + 0
        LCALL   ?UL_GT
        JNC     ??halSleep_1
        MOV     DPL,?XSP + 0
        MOV     DPH,?XSP + 1
        MOV     R0,#?V0 + 0
        LCALL   ?L_MOV_TO_X
??halSleep_1:
        MOV     R2,#0x2
??halSleep_2:
        MOV     A,R2
        MOV     DPTR,#halPwrMgtMode
        LCALL   ?Subroutine1 & 0xFFFF
//  327 
//  328   /* The sleep mode is also controlled by halSleepLevel which
//  329    * defined the deepest level of sleep allowed. This is applied
//  330    * to timer sleep only.
//  331    */
//  332   if ( timeout > 0 && halPwrMgtMode > halSleepLevel )
??CrossCallReturnLabel_2:
        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      ??halSleep_3
        MOV     DPTR,#halSleepLevel
        MOVX    A,@DPTR
        CLR     C
        SUBB    A,R2
        JNC     ??halSleep_3
//  333   {
//  334     halPwrMgtMode = halSleepLevel;
        MOVX    A,@DPTR
        MOV     DPTR,#halPwrMgtMode
        MOVX    @DPTR,A
//  335   }
//  336 
//  337   /* Allow PM1 only.
//  338    * AN044 - RESTRICT USE TO PM1 ONLY
//  339    */
//  340 #if defined (PM1_ONLY) && (PM1_ONLY == TRUE)
//  341     if (timeout > 0)
//  342     {
//  343       halPwrMgtMode = CC2430_PM1;
//  344     }
//  345     else
//  346     {
//  347       /* do not allow PM3 either */
//  348       return;
//  349     }
//  350 #endif
//  351 
//  352   /* DEEP sleep can only be entered when zgPollRate == 0.
//  353    * This is to eliminate any possibility of entering PM3 between
//  354    * two network timers.
//  355    */
//  356 #if !defined (RTR_NWK) && defined (NWK_AUTO_POLL)
//  357   if ((timeout > HAL_SLEEP_MS_TO_320US(PM_MIN_SLEEP_TIME)) ||
//  358       (timeout == 0 && zgPollRate == 0))
//  359 #else
//  360   if ((timeout > HAL_SLEEP_MS_TO_320US(PM_MIN_SLEEP_TIME)) ||
//  361       (timeout == 0))
??halSleep_3:
        MOV     DPL,?XSP + 0
        MOV     DPH,?XSP + 1
        PUSH    DPL
        CFI CFA_SP SP+-1
        PUSH    DPH
        CFI CFA_SP SP+-2
        MOV     DPTR,#__Constant_2d
        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   ?UL_GT_X
        JNC     ??halSleep_4
        MOV     DPL,?XSP + 0
        MOV     DPH,?XSP + 1
        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_5 & 0xFFFF
//  362 #endif
//  363   {
//  364     halIntState_t intState, ien0, ien1, ien2;
//  365     HAL_ENTER_CRITICAL_SECTION(intState);
??halSleep_4:
        MOV     C,0xa8.7
        CLR     A
        MOV     0xE0 /* A   */.0,C
        PUSH    A
        CFI CFA_SP SP+-1
        MOV     A,#0x4
        LCALL   ?XSTACK_DISP0_8
        POP     A
        CFI CFA_SP SP+0
        MOVX    @DPTR,A
        CLR     0xa8.7
//  366 
//  367     /* always use "deep sleep" to turn off radio VREG on CC2430 */
//  368     if (MAC_PwrOffReq(MAC_PWR_SLEEP_DEEP) == MAC_SUCCESS)
        ; Setup parameters for call to function MAC_PwrOffReq
        MOV     R1,#0x2
        LCALL   ??MAC_PwrOffReq?relay
        MOV     A,R1
        JZ      $+5
        LJMP    ??halSleep_6 & 0xFFFF
//  369     {
//  370       while ( (HAL_SLEEP_MS_TO_320US(halAccumulatedSleepTime) < timeout) || (timeout == 0) )
??halSleep_7:
        MOV     DPTR,#halAccumulatedSleepTime
        MOV     R0,#?V0 + 0
        LCALL   ?L_MOV_X
        MOV     DPTR,#__Constant_64
        MOV     R0,#?V0 + 4
        LCALL   ?L_MOV_X
        MOV     R0,#?V0 + 0
        MOV     R1,#?V0 + 4
        LCALL   ?L_MUL
        MOV     DPTR,#__Constant_1f
        MOV     R0,#?V0 + 0
        LCALL   ?L_ADD_X
        MOV     A,#0x5
        MOV     R0,#?V0 + 0
        LCALL   ?UL_SHR
        MOV     DPL,?XSP + 0
        MOV     DPH,?XSP + 1
        MOV     R0,#?V0 + 4
        LCALL   ?L_MOV_X
        MOV     R0,#?V0 + 4
        MOV     R1,#?V0 + 0
        LCALL   ?UL_GT
        JC      ??halSleep_8
        MOV     DPL,?XSP + 0
        MOV     DPH,?XSP + 1
        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_9 & 0xFFFF
//  371       {
//  372         /* get peripherals ready for sleep */
//  373         HalKeyEnterSleep();
??halSleep_8:
        ; Setup parameters for call to function HalKeyEnterSleep
        LCALL   ??HalKeyEnterSleep?relay
//  374 
//  375 #ifdef HAL_SLEEP_DEBUG_LED
//  376         HAL_TURN_OFF_LED3();
//  377 #else
//  378         /* use this to turn LEDs off during sleep */
//  379         HalLedEnterSleep();
        ; Setup parameters for call to function HalLedEnterSleep
        LCALL   ??HalLedEnterSleep?relay
//  380 #endif
//  381 
//  382         /* set main clock source to RC oscillator for Rev B and Rev D */
//  383         HAL_SLEEP_SET_MAIN_CLOCK_RC();
        ANL     0xbe,#0xfb
??halSleep_10:
        MOV     A,0xbe
        MOV     C,0xE0 /* A   */.5
        JNC     ??halSleep_10
        NOP
        MOV     0xc6,#0x49
??halSleep_11:
        MOV     A,#0x49
        XRL     A,0xc6
        JNZ     ??halSleep_11
        ORL     0xbe,#0x4
//  384 
//  385         /* enable sleep timer interrupt */
//  386         if (timeout != 0)
        MOV     DPL,?XSP + 0
        MOV     DPH,?XSP + 1
        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      ??halSleep_12
//  387         {
//  388           if (timeout > HAL_SLEEP_MS_TO_320US( MAX_SLEEP_TIME ))
        MOV     DPL,?XSP + 0
        MOV     DPH,?XSP + 1
        PUSH    DPL
        CFI CFA_SP SP+-1
        PUSH    DPH
        CFI CFA_SP SP+-2
        MOV     DPTR,#__Constant_185197
        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   ?UL_GT_X
        JC      ??halSleep_13
//  389           {
//  390             timeout -= HAL_SLEEP_MS_TO_320US( MAX_SLEEP_TIME );
        MOV     DPTR,#__Constant_ffe7ae6a
        MOV     R0,#?V0 + 0
        LCALL   ?L_MOV_X
        MOV     DPL,?XSP + 0
        MOV     DPH,?XSP + 1
        MOV     R0,#?V0 + 0
        LCALL   ?L_ADD_TO_X
//  391             halSleepSetTimer(HAL_SLEEP_MS_TO_320US( MAX_SLEEP_TIME ));
        ; Setup parameters for call to function halSleepSetTimer
        MOV     DPTR,#__Constant_185196
        SJMP    ??halSleep_14
//  392           }
//  393           else
//  394           {
//  395             /* set sleep timer */
//  396             halSleepSetTimer(timeout);
??halSleep_13:
        ; Setup parameters for call to function halSleepSetTimer
        MOV     DPL,?XSP + 0
        MOV     DPH,?XSP + 1
??halSleep_14:
        MOV     R0,#?V0 + 0
        LCALL   ?L_MOV_X
        MOV     R2,?V0 + 0
        MOV     R3,?V0 + 1
        MOV     R4,?V0 + 2
        MOV     R5,?V0 + 3
        LCALL   ??halSleepSetTimer?relay
//  397           }
//  398 
//  399           /* set up sleep timer interrupt */
//  400           HAL_SLEEP_TIMER_CLEAR_INT();
        CLR     0xc0.7
//  401           HAL_SLEEP_TIMER_ENABLE_INT();
        SETB    0xa8.5
//  402         }
//  403 
//  404 #ifdef HAL_SLEEP_DEBUG_LED
//  405         if (halPwrMgtMode == CC2430_PM1)
//  406         {
//  407           HAL_TURN_ON_LED1();
//  408         }
//  409         else
//  410         {
//  411           HAL_TURN_OFF_LED1();
//  412         }
//  413 #endif
//  414 
//  415         /* save interrupt enable registers and disable all interrupts */
//  416         HAL_SLEEP_IE_BACKUP_AND_DISABLE(ien0, ien1, ien2);
??halSleep_12:
        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
//  417 
//  418         /* This is to check if the stack is exceeding the disappearing
//  419          * RAM boundary of 0xF000. If the stack does exceed the boundary
//  420          * (unlikely), do not enter sleep until the stack is back to normal.
//  421          */
//  422         if ( ((uint16)(*( __idata uint16*)(CSTK_PTR)) >= 0xF000) )
        MOV     R0,#(SFB(XSP) & 0xff)
        CLR     C
        INC     R0
        MOV     A,@R0
        SUBB    A,#-0x10
        JC      ??halSleep_15
//  423         {
//  424           HAL_EXIT_CRITICAL_SECTION(intState);
        MOV     A,#0x4
        LCALL   ?XSTACK_DISP0_8
        MOVX    A,@DPTR
        MOV     C,0xE0 /* A   */.0
        MOV     0xa8.7,C
//  425 
//  426           /* AN044 - DELAYING EXTERNAL INTERRUPTS, do not relocate this line.
//  427            * it has to stay as close to PCON.IDLE = 1 as possible.
//  428            */
//  429           EXTERNAL_INTERRUPT_DELAY();
        ORL     0xfd,#0x2
        SETB    0x80.1
        ; Setup parameters for call to function halSleepWait
        MOV     R2,#-0x4c
        MOV     R3,#0x0
        LCALL   ??halSleepWait?relay
        ANL     0xfd,#0xfd
        ORL     0x8f,#0x2
//  430 
//  431           /* set CC2430 power mode */
//  432           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_16
        NOP
        NOP
        NOP
        MOV     A,#0x3
        ANL     A,0xbe
        JZ      ??halSleep_17
??halSleep_16:
        ORL     0x87,#0x1
        NOP
//  433           /* wake up from sleep */
//  434 
//  435           HAL_ENTER_CRITICAL_SECTION(intState);
??halSleep_17:
        MOV     C,0xa8.7
        CLR     A
        MOV     0xE0 /* A   */.0,C
        PUSH    A
        CFI CFA_SP SP+-1
        MOV     A,#0x4
        LCALL   ?XSTACK_DISP0_8
        POP     A
        CFI CFA_SP SP+0
        MOVX    @DPTR,A
        CLR     0xa8.7
//  436         }
//  437 
//  438         /* restore interrupt enable registers */
//  439         HAL_SLEEP_IE_RESTORE(ien0, ien1, ien2);
??halSleep_15:
        MOV     0xa8,?V0 + 0
        MOV     0xb8,?V0 + 1
        MOV     0x9a,?V0 + 2
//  440 
//  441         /* disable sleep timer interrupt */
//  442         HAL_SLEEP_TIMER_DISABLE_INT();
        CLR     0xa8.5
//  443 
//  444         /* set main clock source to crystal for Rev B and Rev D only */
//  445         HAL_SLEEP_SET_MAIN_CLOCK_CRYSTAL();
        ANL     0xbe,#0xfb
??halSleep_18:
        MOV     A,0xbe
        MOV     C,0xE0 /* A   */.6
        JNC     ??halSleep_18
        NOP
        ; Setup parameters for call to function halSleepWait
        MOV     R2,#0x3f
        MOV     R3,#0x0
        LCALL   ??halSleepWait?relay
        MOV     0xc6,#0x0
??halSleep_19:
        MOV     A,0xc6
        JNZ     ??halSleep_19
        ORL     0xbe,#0x4
//  446 
//  447         /* Calculate timer elasped */
//  448         halAccumulatedSleepTime += (HalTimerElapsed() / TICK_COUNT);
        ; Setup parameters for call to function HalTimerElapsed
        LCALL   ??HalTimerElapsed?relay
        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
//  449 
//  450         /* deduct the sleep time for the next iteration */
//  451         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_20
//  452         {
//  453           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
//  454         }
//  455 
//  456         /* if the remaining time is less than the PM_MIN_SLEEP_TIME
//  457          * burn the remaining time in a delay loop
//  458          * AN044 - MINIMUM SLEEP PERIODS WITH PULL-DOWN RESISTOR
//  459          */
//  460         if ( osal_timeout < PM_MIN_SLEEP_TIME )
??halSleep_20:
        CLR     C
        MOV     A,R6
        SUBB    A,#0xe
        MOV     A,R7
        SUBB    A,#0x0
        JNC     ??halSleep_21
//  461         {
//  462           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
        LCALL   ??halSleepWait?relay
//  463           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
//  464           osal_timeout = halAccumulatedSleepTime;
        MOV     DPTR,#halAccumulatedSleepTime
        MOV     R0,#?V0 + 0
        LCALL   ?L_MOV_X
        MOV     R6,?V0 + 0
        MOV     R7,?V0 + 1
//  465         }
//  466 
//  467 #ifdef HAL_SLEEP_DEBUG_LED
//  468         HAL_TURN_ON_LED3();
//  469 #else
//  470         /* use this to turn LEDs back on after sleep */
//  471         HalLedExitSleep();
??halSleep_21:
        ; Setup parameters for call to function HalLedExitSleep
        LCALL   ??HalLedExitSleep?relay
//  472 #endif
//  473 
//  474         /* handle peripherals; exit loop if key presses */
//  475         if ( HalKeyExitSleep() )
        ; Setup parameters for call to function HalKeyExitSleep
        LCALL   ??HalKeyExitSleep?relay
        MOV     A,R1
        JNZ     ??halSleep_9
//  476         {
//  477 #if defined (PM2_HOLDOFF_TIME) && (PM2_HOLDOFF_TIME > 0)
//  478           /* The deepest sleep alowwed is PM1 until after the timer expired
//  479            * AN044 - COMBINING POWER MODES
//  480            */
//  481           halSleepLevel = CC2430_PM1;
//  482           osal_stop_timerEx (Hal_TaskID, HAL_SLEEP_TIMER_EVENT);
//  483           osal_start_timerEx (Hal_TaskID, HAL_SLEEP_TIMER_EVENT, PM2_HOLDOFF_TIME);
//  484 #endif /* (PM2_HOLDOFF_TIME > 0) */
//  485           break;
//  486         }
//  487 
//  488         /* exit loop if no timer active */
//  489         if ( timeout == 0 ) break;
        MOV     DPL,?XSP + 0
        MOV     DPH,?XSP + 1
        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_7 & 0xFFFF
//  490       }
//  491 
//  492       /* power on the MAC; blocks until completion */
//  493       MAC_PwrOnReq();
??halSleep_9:
        ; Setup parameters for call to function MAC_PwrOnReq
        LCALL   ??MAC_PwrOnReq?relay
//  494 
//  495       /* adjust OSAL timers */
//  496       osal_adjust_timers();
        ; Setup parameters for call to function osal_adjust_timers
        LCALL   ??osal_adjust_timers?relay
//  497 
//  498     }
//  499 
//  500     HAL_EXIT_CRITICAL_SECTION(intState);
??halSleep_6:
        MOV     A,#0x4
        LCALL   ?XSTACK_DISP0_8
        MOVX    A,@DPTR
        MOV     C,0xE0 /* A   */.0
        MOV     0xa8.7,C
//  501   }
//  502 }
??halSleep_5:
        MOV     A,#0x5
        LJMP    ??Subroutine2_0 & 0xFFFF
        CFI EndBlock cfiBlock0
        REQUIRE _A_P0
        REQUIRE PCON
        REQUIRE P0INP
        REQUIRE IEN2
        REQUIRE _A_IEN0
        REQUIRE _A_IEN1
        REQUIRE SLEEP
        REQUIRE _A_IRCON
        REQUIRE CLKCON
        REQUIRE P0DIR

        RSEG BANKED_CODE:CODE:NOROOT(0)
?Subroutine0:
        CFI Block cfiCond1 Using cfiCommon0
        CFI NoFunction
        CFI Conditional ??CrossCallReturnLabel_0
        CFI R6 load(1, XDATA, add(CFA_XSP16, literal(-16)))
        CFI VB load(1, XDATA, add(CFA_XSP16, literal(-15)))
        CFI V0 load(1, XDATA, add(CFA_XSP16, literal(-14)))
        CFI V1 load(1, XDATA, add(CFA_XSP16, literal(-13)))
        CFI V2 load(1, XDATA, add(CFA_XSP16, literal(-12)))
        CFI V3 load(1, XDATA, add(CFA_XSP16, literal(-11)))
        CFI V4 load(1, XDATA, add(CFA_XSP16, literal(-10)))
        CFI V5 load(1, XDATA, add(CFA_XSP16, literal(-9)))
        CFI V6 load(1, XDATA, add(CFA_XSP16, literal(-8)))
        CFI V7 load(1, XDATA, add(CFA_XSP16, literal(-7)))
        CFI R7 load(1, XDATA, add(CFA_XSP16, literal(-6)))
        CFI ?RET_LOW load(1, XDATA, add(CFA_XSP16, literal(-5)))
        CFI ?RET_HIGH load(1, XDATA, add(CFA_XSP16, literal(-4)))
        CFI ?BRET_EXT load(1, XDATA, add(CFA_XSP16, literal(-3)))
        CFI DPL0 load(1, XDATA, add(CFA_XSP16, literal(-2)))
        CFI DPH0 load(1, XDATA, add(CFA_XSP16, literal(-1)))
        CFI CFA_SP SP+0
        CFI CFA_XSP16 add(XSP16, 21)
        CFI Block cfiCond2 Using cfiCommon0
        CFI (cfiCond2) NoFunction
        CFI (cfiCond2) Conditional ??CrossCallReturnLabel_1
        CFI (cfiCond2) R6 load(1, XDATA, add(CFA_XSP16, literal(-16)))
        CFI (cfiCond2) VB load(1, XDATA, add(CFA_XSP16, literal(-15)))
        CFI (cfiCond2) V0 load(1, XDATA, add(CFA_XSP16, literal(-14)))
        CFI (cfiCond2) V1 load(1, XDATA, add(CFA_XSP16, literal(-13)))
        CFI (cfiCond2) V2 load(1, XDATA, add(CFA_XSP16, literal(-12)))
        CFI (cfiCond2) V3 load(1, XDATA, add(CFA_XSP16, literal(-11)))
        CFI (cfiCond2) V4 load(1, XDATA, add(CFA_XSP16, literal(-10)))
        CFI (cfiCond2) V5 load(1, XDATA, add(CFA_XSP16, literal(-9)))
        CFI (cfiCond2) V6 load(1, XDATA, add(CFA_XSP16, literal(-8)))
        CFI (cfiCond2) V7 load(1, XDATA, add(CFA_XSP16, literal(-7)))
        CFI (cfiCond2) R7 load(1, XDATA, add(CFA_XSP16, literal(-6)))
        CFI (cfiCond2) ?RET_LOW load(1, XDATA, add(CFA_XSP16, literal(-5)))
        CFI (cfiCond2) ?RET_HIGH load(1, XDATA, add(CFA_XSP16, literal(-4)))
        CFI (cfiCond2) ?BRET_EXT load(1, XDATA, add(CFA_XSP16, literal(-3)))
        CFI (cfiCond2) DPL0 load(1, XDATA, add(CFA_XSP16, literal(-2)))
        CFI (cfiCond2) DPH0 load(1, XDATA, add(CFA_XSP16, literal(-1)))
        CFI (cfiCond2) CFA_SP SP+0
        CFI (cfiCond2) CFA_XSP16 add(XSP16, 21)
        CFI Block cfiPicker3 Using cfiCommon1
        CFI (cfiPicker3) NoFunction
        CFI (cfiPicker3) Picker
        LCALL   ??MAC_PwrNextTimeout?relay
        MOV     ?V0 + 0,R2
        MOV     ?V0 + 1,R3
        MOV     ?V0 + 2,R4
        MOV     ?V0 + 3,R5
        RET
        CFI EndBlock cfiCond1
        CFI EndBlock cfiCond2
        CFI EndBlock cfiPicker3
//  503 
//  504 /**************************************************************************************************
//  505  * @fn          halSleepSetTimer
//  506  *
//  507  * @brief       This function sets the CC2430 sleep timer compare value.  First it reads and
//  508  *              stores the value of the sleep timer; this value is used later to update OSAL
//  509  *              timers.  Then the timeout value is converted from 320 usec units to 32 kHz
//  510  *              period units and the compare value is set to the timeout.
//  511  *
//  512  * input parameters
//  513  *
//  514  * @param       timeout - Timeout value in 320 usec units.  The sleep timer compare is set to
//  515  *                        this value.
//  516  *
//  517  * output parameters
//  518  *
//  519  * None.
//  520  *
//  521  * @return      None.
//  522  **************************************************************************************************
//  523  */

        RSEG BANKED_CODE:CODE:NOROOT(0)
//  524 void halSleepSetTimer(uint32 timeout)
halSleepSetTimer:
        CFI Block cfiBlock4 Using cfiCommon0
        CFI Function halSleepSetTimer
//  525 {
        MOV     A,#-0x10
        LCALL   ?BANKED_ENTER_XDATA
        CFI DPH0 load(1, XDATA, add(CFA_XSP16, literal(-1)))
        CFI DPL0 load(1, XDATA, add(CFA_XSP16, literal(-2)))
        CFI ?BRET_EXT load(1, XDATA, add(CFA_XSP16, literal(-3)))
        CFI ?RET_HIGH load(1, XDATA, add(CFA_XSP16, literal(-4)))
        CFI ?RET_LOW load(1, XDATA, add(CFA_XSP16, literal(-5)))
        CFI R7 load(1, XDATA, add(CFA_XSP16, literal(-6)))
        CFI V7 load(1, XDATA, add(CFA_XSP16, literal(-7)))
        CFI V6 load(1, XDATA, add(CFA_XSP16, literal(-8)))
        CFI V5 load(1, XDATA, add(CFA_XSP16, literal(-9)))
        CFI V4 load(1, XDATA, add(CFA_XSP16, literal(-10)))
        CFI V3 load(1, XDATA, add(CFA_XSP16, literal(-11)))
        CFI V2 load(1, XDATA, add(CFA_XSP16, literal(-12)))
        CFI V1 load(1, XDATA, add(CFA_XSP16, literal(-13)))
        CFI V0 load(1, XDATA, add(CFA_XSP16, literal(-14)))
        CFI VB load(1, XDATA, add(CFA_XSP16, literal(-15)))
        CFI R6 load(1, XDATA, add(CFA_XSP16, literal(-16)))
        CFI CFA_SP SP+0
        CFI CFA_XSP16 add(XSP16, 16)
        ; Saved register size: 16
        ; Auto size: 4
        MOV     A,#-0x4
        LCALL   ?ALLOC_XSTACK8
        CFI CFA_XSP16 add(XSP16, 20)
        MOV     ?V0 + 0,R2
        MOV     ?V0 + 1,R3
        MOV     ?V0 + 2,R4
        MOV     ?V0 + 3,R5
//  526   uint32 ticks;
//  527 
//  528   /* read the sleep timer; ST0 must be read first */
//  529   ((uint8 *) &ticks)[UINT32_NDX0] = ST0;
        MOV     A,0x95
        MOV     DPL,?XSP + 0
        MOV     DPH,?XSP + 1
        MOVX    @DPTR,A
//  530   ((uint8 *) &ticks)[UINT32_NDX1] = ST1;
        MOV     A,0x96
        PUSH    A
        CFI CFA_SP SP+-1
        MOV     A,#0x1
        LCALL   ?XSTACK_DISP0_8
        POP     A
        CFI CFA_SP SP+0
        MOVX    @DPTR,A
//  531   ((uint8 *) &ticks)[UINT32_NDX2] = ST2;
        MOV     A,0x97
        PUSH    A
        CFI CFA_SP SP+-1
        MOV     A,#0x2
        LCALL   ?XSTACK_DISP0_8
        POP     A
        CFI CFA_SP SP+0
        MOVX    @DPTR,A
//  532   ((uint8 *) &ticks)[UINT32_NDX3] = 0;
        MOV     A,#0x3
        LCALL   ?XSTACK_DISP0_8
        CLR     A
        LCALL   ?Subroutine1 & 0xFFFF
//  533 
//  534   /* store value for later */
//  535   halSleepTimerStart = ticks;
??CrossCallReturnLabel_3:
        MOV     R0,#?V0 + 4
        LCALL   ?L_MOV_X
        MOV     DPTR,#halSleepTimerStart
        MOV     R0,#?V0 + 4
        LCALL   ?L_MOV_TO_X
//  536 
//  537 
//  538   /* Compute sleep timer compare value.  The ratio of 32 kHz ticks to 320 usec ticks
//  539    * is 32768/3125 = 10.48576.  This is nearly 671/64 = 10.484375.
//  540    */
//  541   ticks += (timeout * 671) / 64;
//  542 
//  543   /* subtract the processing time spent in function halSleep() */
//  544   ticks -= HAL_SLEEP_ADJ_TICKS;
        MOV     DPTR,#__Constant_29f
        MOV     R0,#?V0 + 4
        LCALL   ?L_MOV_X
        MOV     R0,#?V0 + 0
        MOV     R1,#?V0 + 4
        LCALL   ?L_MUL
        MOV     A,#0x6
        MOV     R0,#?V0 + 0
        LCALL   ?UL_SHR
        MOV     DPTR,#__Constant_ffffffde
        MOV     R0,#?V0 + 0
        LCALL   ?L_ADD_X
        MOV     DPL,?XSP + 0
        MOV     DPH,?XSP + 1
        MOV     R0,#?V0 + 0
        LCALL   ?L_ADD_TO_X
//  545 
//  546   /* CC2430 Rev. B bug:  compare value must not be set higher than 0xFFFF7F */
//  547   if((ticks & 0xFFFFFF) > 0xFFFF7F)
        MOV     DPL,?XSP + 0
        MOV     DPH,?XSP + 1
        PUSH    DPL
        CFI CFA_SP SP+-1
        PUSH    DPH
        CFI CFA_SP SP+-2
        MOV     DPTR,#__Constant_ffffff
        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_AND_X
        MOV     DPTR,#__Constant_ffff80
        MOV     R0,#?V0 + 4
        LCALL   ?L_MOV_X
        MOV     R0,#?V0 + 4
        MOV     R1,#?V0 + 0
        LCALL   ?UL_GT
        JC      ??halSleepSetTimer_0
//  548   {
//  549     ticks = 0xFFFF7F;
        MOV     DPTR,#__Constant_ffff7f
        MOV     R0,#?V0 + 0
        LCALL   ?L_MOV_X
        MOV     DPL,?XSP + 0
        MOV     DPH,?XSP + 1
        MOV     R0,#?V0 + 0
        LCALL   ?L_MOV_TO_X
//  550   }
//  551 
//  552   /* set sleep timer compare; ST0 must be written last */
//  553   ST2 = ((uint8 *) &ticks)[UINT32_NDX2];
??halSleepSetTimer_0:
        MOV     A,#0x2
        LCALL   ?XSTACK_DISP0_8
        MOVX    A,@DPTR
        MOV     0x97,A
//  554   ST1 = ((uint8 *) &ticks)[UINT32_NDX1];
        MOV     A,#0x1
        LCALL   ?XSTACK_DISP0_8
        MOVX    A,@DPTR
        MOV     0x96,A
//  555   ST0 = ((uint8 *) &ticks)[UINT32_NDX0];
        MOV     DPL,?XSP + 0
        MOV     DPH,?XSP + 1
        MOVX    A,@DPTR
        MOV     0x95,A
        CFI EndBlock cfiBlock4
//  556 }
        REQUIRE ?Subroutine2
        REQUIRE ST0
        REQUIRE ST1
        REQUIRE ST2
        ; // Fall through to label ?Subroutine2

        RSEG BANKED_CODE:CODE:NOROOT(0)
?Subroutine2:
        CFI Block cfiBlock5 Using cfiCommon0
        CFI NoFunction
        CFI CFA_SP SP+0
        CFI CFA_XSP16 add(XSP16, 20)
        CFI VB load(1, XDATA, add(CFA_XSP16, literal(-15)))
        CFI DPL0 load(1, XDATA, add(CFA_XSP16, literal(-2)))
        CFI DPH0 load(1, XDATA, add(CFA_XSP16, literal(-1)))
        CFI R6 load(1, XDATA, add(CFA_XSP16, literal(-16)))
        CFI R7 load(1, XDATA, add(CFA_XSP16, literal(-6)))
        CFI V0 load(1, XDATA, add(CFA_XSP16, literal(-14)))
        CFI V1 load(1, XDATA, add(CFA_XSP16, literal(-13)))
        CFI V2 load(1, XDATA, add(CFA_XSP16, literal(-12)))
        CFI V3 load(1, XDATA, add(CFA_XSP16, literal(-11)))
        CFI V4 load(1, XDATA, add(CFA_XSP16, literal(-10)))
        CFI V5 load(1, XDATA, add(CFA_XSP16, literal(-9)))
        CFI V6 load(1, XDATA, add(CFA_XSP16, literal(-8)))
        CFI V7 load(1, XDATA, add(CFA_XSP16, literal(-7)))
        CFI ?BRET_EXT load(1, XDATA, add(CFA_XSP16, literal(-3)))
        CFI ?RET_HIGH load(1, XDATA, add(CFA_XSP16, literal(-4)))
        CFI ?RET_LOW load(1, XDATA, add(CFA_XSP16, literal(-5)))
        MOV     A,#0x4
??Subroutine2_0:
        LCALL   ?DEALLOC_XSTACK8
        CFI CFA_XSP16 add(XSP16, 16)
        MOV     R7,#0x8
        LJMP    ?BANKED_LEAVE_XDATA
        CFI EndBlock cfiBlock5

        RSEG BANKED_CODE:CODE:NOROOT(0)
?Subroutine1:
        CFI Block cfiCond6 Using cfiCommon0
        CFI NoFunction
        CFI Conditional ??CrossCallReturnLabel_2
        CFI R6 load(1, XDATA, add(CFA_XSP16, literal(-16)))
        CFI VB load(1, XDATA, add(CFA_XSP16, literal(-15)))
        CFI V0 load(1, XDATA, add(CFA_XSP16, literal(-14)))
        CFI V1 load(1, XDATA, add(CFA_XSP16, literal(-13)))
        CFI V2 load(1, XDATA, add(CFA_XSP16, literal(-12)))
        CFI V3 load(1, XDATA, add(CFA_XSP16, literal(-11)))
        CFI V4 load(1, XDATA, add(CFA_XSP16, literal(-10)))
        CFI V5 load(1, XDATA, add(CFA_XSP16, literal(-9)))
        CFI V6 load(1, XDATA, add(CFA_XSP16, literal(-8)))
        CFI V7 load(1, XDATA, add(CFA_XSP16, literal(-7)))
        CFI R7 load(1, XDATA, add(CFA_XSP16, literal(-6)))
        CFI ?RET_LOW load(1, XDATA, add(CFA_XSP16, literal(-5)))
        CFI ?RET_HIGH load(1, XDATA, add(CFA_XSP16, literal(-4)))
        CFI ?BRET_EXT load(1, XDATA, add(CFA_XSP16, literal(-3)))
        CFI DPL0 load(1, XDATA, add(CFA_XSP16, literal(-2)))
        CFI DPH0 load(1, XDATA, add(CFA_XSP16, literal(-1)))
        CFI CFA_SP SP+0
        CFI CFA_XSP16 add(XSP16, 21)
        CFI Block cfiCond7 Using cfiCommon0
        CFI (cfiCond7) NoFunction
        CFI (cfiCond7) Conditional ??CrossCallReturnLabel_3
        CFI (cfiCond7) R6 load(1, XDATA, add(CFA_XSP16, literal(-16)))
        CFI (cfiCond7) VB load(1, XDATA, add(CFA_XSP16, literal(-15)))
        CFI (cfiCond7) V0 load(1, XDATA, add(CFA_XSP16, literal(-14)))
        CFI (cfiCond7) V1 load(1, XDATA, add(CFA_XSP16, literal(-13)))
        CFI (cfiCond7) V2 load(1, XDATA, add(CFA_XSP16, literal(-12)))
        CFI (cfiCond7) V3 load(1, XDATA, add(CFA_XSP16, literal(-11)))
        CFI (cfiCond7) V4 load(1, XDATA, add(CFA_XSP16, literal(-10)))
        CFI (cfiCond7) V5 load(1, XDATA, add(CFA_XSP16, literal(-9)))
        CFI (cfiCond7) V6 load(1, XDATA, add(CFA_XSP16, literal(-8)))
        CFI (cfiCond7) V7 load(1, XDATA, add(CFA_XSP16, literal(-7)))
        CFI (cfiCond7) R7 load(1, XDATA, add(CFA_XSP16, literal(-6)))
        CFI (cfiCond7) ?RET_LOW load(1, XDATA, add(CFA_XSP16, literal(-5)))
        CFI (cfiCond7) ?RET_HIGH load(1, XDATA, add(CFA_XSP16, literal(-4)))
        CFI (cfiCond7) ?BRET_EXT load(1, XDATA, add(CFA_XSP16, literal(-3)))
        CFI (cfiCond7) DPL0 load(1, XDATA, add(CFA_XSP16, literal(-2)))
        CFI (cfiCond7) DPH0 load(1, XDATA, add(CFA_XSP16, literal(-1)))
        CFI (cfiCond7) CFA_SP SP+0
        CFI (cfiCond7) CFA_XSP16 add(XSP16, 20)
        CFI Block cfiCond8 Using cfiCommon0
        CFI (cfiCond8) NoFunction
        CFI (cfiCond8) Conditional ??CrossCallReturnLabel_4
        CFI (cfiCond8) R6 load(1, XDATA, add(CFA_XSP16, literal(-16)))
        CFI (cfiCond8) VB load(1, XDATA, add(CFA_XSP16, literal(-15)))
        CFI (cfiCond8) V0 load(1, XDATA, add(CFA_XSP16, literal(-14)))
        CFI (cfiCond8) V1 load(1, XDATA, add(CFA_XSP16, literal(-13)))
        CFI (cfiCond8) V2 load(1, XDATA, add(CFA_XSP16, literal(-12)))
        CFI (cfiCond8) V3 load(1, XDATA, add(CFA_XSP16, literal(-11)))
        CFI (cfiCond8) V4 load(1, XDATA, add(CFA_XSP16, literal(-10)))
        CFI (cfiCond8) V5 load(1, XDATA, add(CFA_XSP16, literal(-9)))
        CFI (cfiCond8) V6 load(1, XDATA, add(CFA_XSP16, literal(-8)))
        CFI (cfiCond8) V7 load(1, XDATA, add(CFA_XSP16, literal(-7)))
        CFI (cfiCond8) R7 load(1, XDATA, add(CFA_XSP16, literal(-6)))
        CFI (cfiCond8) ?RET_LOW load(1, XDATA, add(CFA_XSP16, literal(-5)))
        CFI (cfiCond8) ?RET_HIGH load(1, XDATA, add(CFA_XSP16, literal(-4)))
        CFI (cfiCond8) ?BRET_EXT load(1, XDATA, add(CFA_XSP16, literal(-3)))
        CFI (cfiCond8) DPL0 load(1, XDATA, add(CFA_XSP16, literal(-2)))
        CFI (cfiCond8) DPH0 load(1, XDATA, add(CFA_XSP16, literal(-1)))
        CFI (cfiCond8) CFA_SP SP+0
        CFI (cfiCond8) CFA_XSP16 add(XSP16, 20)
        CFI Block cfiPicker9 Using cfiCommon1
        CFI (cfiPicker9) NoFunction
        CFI (cfiPicker9) Picker
        MOVX    @DPTR,A
        MOV     DPL,?XSP + 0
        MOV     DPH,?XSP + 1
        RET
        CFI EndBlock cfiCond6
        CFI EndBlock cfiCond7
        CFI EndBlock cfiCond8
        CFI EndBlock cfiPicker9
//  557 
//  558 /**************************************************************************************************
//  559  * @fn          TimerElapsed
//  560  *
//  561  * @brief       Determine the number of OSAL timer ticks elapsed during sleep.
//  562  *
//  563  * input parameters
//  564  *
//  565  * @param       None.
//  566  *
//  567  * output parameters
//  568  *
//  569  * None.
//  570  *
//  571  * @return      Number of timer ticks elapsed during sleep.
//  572  **************************************************************************************************
//  573  */

        RSEG BANKED_CODE:CODE:NOROOT(0)
//  574 uint32 TimerElapsed( void )
TimerElapsed:
        CFI Block cfiBlock10 Using cfiCommon0
        CFI Function TimerElapsed
//  575 {
        MOV     A,#-0xc
        LCALL   ?BANKED_ENTER_XDATA
        CFI DPH0 load(1, XDATA, add(CFA_XSP16, literal(-1)))
        CFI DPL0 load(1, XDATA, add(CFA_XSP16, literal(-2)))
        CFI ?BRET_EXT load(1, XDATA, add(CFA_XSP16, literal(-3)))
        CFI ?RET_HIGH load(1, XDATA, add(CFA_XSP16, literal(-4)))
        CFI ?RET_LOW load(1, XDATA, add(CFA_XSP16, literal(-5)))
        CFI R7 load(1, XDATA, add(CFA_XSP16, literal(-6)))
        CFI V3 load(1, XDATA, add(CFA_XSP16, literal(-7)))
        CFI V2 load(1, XDATA, add(CFA_XSP16, literal(-8)))
        CFI V1 load(1, XDATA, add(CFA_XSP16, literal(-9)))
        CFI V0 load(1, XDATA, add(CFA_XSP16, literal(-10)))
        CFI VB load(1, XDATA, add(CFA_XSP16, literal(-11)))
        CFI R6 load(1, XDATA, add(CFA_XSP16, literal(-12)))
        CFI CFA_SP SP+0
        CFI CFA_XSP16 add(XSP16, 12)
        ; Saved register size: 12
        ; Auto size: 0
//  576   return ( halAccumulatedSleepTime );
        MOV     DPTR,#halAccumulatedSleepTime
        MOV     R0,#?V0 + 0
        LCALL   ?L_MOV_X
        MOV     R2,?V0 + 0
        MOV     R3,?V0 + 1
        MOV     R4,?V0 + 2
        MOV     R5,?V0 + 3
        MOV     R7,#0x4
        LJMP    ?BANKED_LEAVE_XDATA
        CFI EndBlock cfiBlock10
//  577 }
//  578 
//  579 /**************************************************************************************************
//  580  * @fn          HalTimerElapsed
//  581  *
//  582  * @brief       Determine the number of OSAL timer ticks elapsed during sleep.  This function
//  583  *              relies on OSAL macro TICK_COUNT to be set to 1; then ticks are calculated in
//  584  *              units of msec.  (Setting TICK_COUNT to 1 avoids a costly uint32 divide.)
//  585  *
//  586  * input parameters
//  587  *
//  588  * @param       None.
//  589  *
//  590  * output parameters
//  591  *
//  592  * None.
//  593  *
//  594  * @return      Number of timer ticks elapsed during sleep.
//  595  **************************************************************************************************
//  596  */

        RSEG BANKED_CODE:CODE:NOROOT(0)
//  597 uint32 HalTimerElapsed( void )
HalTimerElapsed:
        CFI Block cfiBlock11 Using cfiCommon0
        CFI Function HalTimerElapsed
//  598 {
        MOV     A,#-0x10
        LCALL   ?BANKED_ENTER_XDATA
        CFI DPH0 load(1, XDATA, add(CFA_XSP16, literal(-1)))
        CFI DPL0 load(1, XDATA, add(CFA_XSP16, literal(-2)))
        CFI ?BRET_EXT load(1, XDATA, add(CFA_XSP16, literal(-3)))
        CFI ?RET_HIGH load(1, XDATA, add(CFA_XSP16, literal(-4)))
        CFI ?RET_LOW load(1, XDATA, add(CFA_XSP16, literal(-5)))
        CFI R7 load(1, XDATA, add(CFA_XSP16, literal(-6)))
        CFI V7 load(1, XDATA, add(CFA_XSP16, literal(-7)))
        CFI V6 load(1, XDATA, add(CFA_XSP16, literal(-8)))
        CFI V5 load(1, XDATA, add(CFA_XSP16, literal(-9)))
        CFI V4 load(1, XDATA, add(CFA_XSP16, literal(-10)))
        CFI V3 load(1, XDATA, add(CFA_XSP16, literal(-11)))
        CFI V2 load(1, XDATA, add(CFA_XSP16, literal(-12)))
        CFI V1 load(1, XDATA, add(CFA_XSP16, literal(-13)))
        CFI V0 load(1, XDATA, add(CFA_XSP16, literal(-14)))
        CFI VB load(1, XDATA, add(CFA_XSP16, literal(-15)))
        CFI R6 load(1, XDATA, add(CFA_XSP16, literal(-16)))
        CFI CFA_SP SP+0
        CFI CFA_XSP16 add(XSP16, 16)
        ; Saved register size: 16
        ; Auto size: 4
        MOV     A,#-0x4
        LCALL   ?ALLOC_XSTACK8
        CFI CFA_XSP16 add(XSP16, 20)
//  599   uint32 ticks;
//  600 
//  601   /* read the sleep timer; ST0 must be read first */
//  602   ((uint8 *) &ticks)[UINT32_NDX0] = ST0;
        MOV     A,0x95
        MOV     DPL,?XSP + 0
        MOV     DPH,?XSP + 1
        MOVX    @DPTR,A
//  603   ((uint8 *) &ticks)[UINT32_NDX1] = ST1;
        MOV     A,0x96
        PUSH    A
        CFI CFA_SP SP+-1
        MOV     A,#0x1
        LCALL   ?XSTACK_DISP0_8
        POP     A
        CFI CFA_SP SP+0
        MOVX    @DPTR,A
//  604   ((uint8 *) &ticks)[UINT32_NDX2] = ST2;
        MOV     A,0x97
        PUSH    A
        CFI CFA_SP SP+-1
        MOV     A,#0x2
        LCALL   ?XSTACK_DISP0_8
        POP     A
        CFI CFA_SP SP+0
        MOVX    @DPTR,A
//  605 
//  606   /* set bit 24 to handle wraparound */
//  607   ((uint8 *) &ticks)[UINT32_NDX3] = 0x01;
        MOV     A,#0x3
        LCALL   ?XSTACK_DISP0_8
        MOV     A,#0x1
        LCALL   ?Subroutine1 & 0xFFFF
//  608 
//  609   /* calculate elapsed time */
//  610   ticks -= halSleepTimerStart;
//  611 
//  612   /* add back the processing time spent in function halSleep() */
//  613   ticks += HAL_SLEEP_ADJ_TICKS;
//  614 
//  615   /* mask off excess if no wraparound */
//  616   ticks &= 0x00FFFFFF;
//  617 
//  618   /* Convert elapsed time in milliseconds with round.  1000/32768 = 125/4096 */
//  619   return ( ((ticks * 125) + 4095) / 4096 );
??CrossCallReturnLabel_4:
        MOV     R0,#?V0 + 0
        LCALL   ?L_MOV_X
        MOV     DPTR,#halSleepTimerStart
        MOV     R0,#?V0 + 0
        LCALL   ?L_SUB_X
        MOV     DPTR,#__Constant_22
        MOV     R0,#?V0 + 0
        LCALL   ?L_ADD_X
        MOV     DPTR,#__Constant_ffffff
        MOV     R0,#?V0 + 0
        LCALL   ?L_AND_X
        MOV     DPTR,#__Constant_7d
        MOV     R0,#?V0 + 4
        LCALL   ?L_MOV_X
        MOV     R0,#?V0 + 0
        MOV     R1,#?V0 + 4
        LCALL   ?L_MUL
        MOV     DPTR,#__Constant_fff
        MOV     R0,#?V0 + 0
        LCALL   ?L_ADD_X
        MOV     A,#0xc
        MOV     R0,#?V0 + 0
        LCALL   ?UL_SHR
        MOV     R2,?V0 + 0
        MOV     R3,?V0 + 1
        MOV     R4,?V0 + 2
        MOV     R5,A
        LJMP    ?Subroutine2 & 0xFFFF
        CFI EndBlock cfiBlock11
        REQUIRE ST0
        REQUIRE ST1
        REQUIRE ST2
//  620 }
//  621 
//  622 /**************************************************************************************************
//  623  * @fn          halSleepWait
//  624  *
//  625  * @brief       Perform a blocking wait.
//  626  *
//  627  * input parameters
//  628  *
//  629  * @param       duration - Duration of wait in microseconds.
//  630  *
//  631  * output parameters
//  632  *
//  633  * None.
//  634  *
//  635  * @return      None.
//  636  **************************************************************************************************
//  637  */

        RSEG BANKED_CODE:CODE:NOROOT(0)
//  638 void halSleepWait(uint16 duration)
halSleepWait:
        CFI Block cfiBlock12 Using cfiCommon0
        CFI Function halSleepWait
//  639 {
        ; Saved register size: 0
        ; Auto size: 0
        SJMP    ??halSleepWait_0
//  640   while (duration--)
//  641   {
//  642     asm("NOP");
??halSleepWait_1:
        NOP
//  643     asm("NOP");
        NOP
//  644     asm("NOP");
        NOP
//  645     asm("NOP");
        NOP
//  646     asm("NOP");
        NOP
//  647     asm("NOP");
        NOP
//  648     asm("NOP");
        NOP
//  649     asm("NOP");
        NOP
//  650   }
??halSleepWait_0:
        MOV     A,R2
        MOV     R0,A
        MOV     A,R3
        MOV     R1,A
        MOV     A,#-0x1
        ADD     A,R0
        DEC     R2
        MOV     A,#-0x1
        ADDC    A,R1
        MOV     R3,A
        MOV     A,R0
        JNZ     ??halSleepWait_2
        MOV     A,R1
??halSleepWait_2:
        JNZ     ??halSleepWait_1
//  651 }
        LJMP    ?BRET
        CFI EndBlock cfiBlock12
//  652 
//  653 /**************************************************************************************************
//  654  * @fn          halRestoreSleepLevel
//  655  *
//  656  * @brief       Restore the deepest timer sleep level.
//  657  *
//  658  * input parameters
//  659  *
//  660  * @param       None
//  661  *
//  662  * output parameters
//  663  *
//  664  *              None.
//  665  *
//  666  * @return      None.
//  667  **************************************************************************************************
//  668  */

        RSEG BANKED_CODE:CODE:NOROOT(0)
//  669 void halRestoreSleepLevel( void )
halRestoreSleepLevel:
        CFI Block cfiBlock13 Using cfiCommon0
        CFI Function halRestoreSleepLevel
//  670 {
        PUSH    DPL
        CFI DPL0 Frame(CFA_SP, 4)
        CFI CFA_SP SP+-4
        PUSH    DPH
        CFI DPH0 Frame(CFA_SP, 5)
        CFI CFA_SP SP+-5
        ; Saved register size: 2
        ; Auto size: 0
//  671   halSleepLevel = CC2430_PM2;
        MOV     A,#0x2
        MOV     DPTR,#halSleepLevel
        MOVX    @DPTR,A
//  672 }
        POP     DPH
        CFI DPH0 SameValue
        CFI CFA_SP SP+-4
        POP     DPL
        CFI DPL0 SameValue
        CFI CFA_SP SP+-3
        LJMP    ?BRET
        CFI EndBlock cfiBlock13
//  673 
//  674 /**************************************************************************************************
//  675  * @fn          halSleepTimerIsr
//  676  *
//  677  * @brief       Sleep timer ISR.
//  678  *
//  679  * input parameters
//  680  *
//  681  * None.
//  682  *
//  683  * output parameters
//  684  *
//  685  * None.
//  686  *
//  687  * @return      None.
//  688  **************************************************************************************************
//  689  */

        RSEG NEAR_CODE:CODE:NOROOT(0)
//  690 HAL_ISR_FUNCTION(halSleepTimerIsr, ST_VECTOR)
halSleepTimerIsr:
        CFI Block cfiBlock14 Using cfiCommon1
        CFI Function halSleepTimerIsr
//  691 {
        PUSH    A
        CFI A Frame(CFA_SP, 3)
        CFI CFA_SP SP+-3
        PUSH    PSW
        CFI PSW Frame(CFA_SP, 4)
        CFI CFA_SP SP+-4
        PUSH    DPL
        CFI DPL0 Frame(CFA_SP, 5)
        CFI CFA_SP SP+-5
        PUSH    DPH
        CFI DPH0 Frame(CFA_SP, 6)
        CFI CFA_SP SP+-6
        ; Saved register size: 4
        ; Auto size: 0
//  692   HAL_SLEEP_TIMER_CLEAR_INT();
        CLR     0xc0.7
//  693 
//  694   if( CHVER >= REV_E )
        MOV     DPTR,#-0x20a0
        MOVX    A,@DPTR
        CLR     C
        SUBB    A,#0x4
        JC      ??halSleepTimerIsr_0
//  695   {
//  696     CLEAR_SLEEP_MODE();
        ANL     0xbe,#0xfc
        MOV     A,0xbe
//  697   }
//  698 #ifdef HAL_SLEEP_DEBUG_POWER_MODE
//  699   halSleepInt = TRUE;
//  700 #endif
//  701 }
??halSleepTimerIsr_0:
        POP     DPH
        CFI DPH0 SameValue
        CFI CFA_SP SP+-5
        POP     DPL
        CFI DPL0 SameValue
        CFI CFA_SP SP+-4
        POP     PSW
        CFI PSW SameValue
        CFI CFA_SP SP+-3
        POP     A
        CFI A SameValue
        CFI CFA_SP SP+-2
        RETI
        CFI EndBlock cfiBlock14
        REQUIRE SLEEP
        REQUIRE _A_IRCON

        COMMON INTVEC:CODE:ROOT(0)
        ORG 43
`??halSleepTimerIsr??INTVEC 43`:
        LJMP       (halSleepTimerIsr)

        RSEG XDATA_ID:CODE:NOROOT(0)
        DATA
`?<Initializer for halSleepLevel>`:
        DB 2

        RSEG XDATA_ID:CODE:NOROOT(0)
        DATA
`?<Initializer for __Constant_0>`:
        DD 0

        RSEG XDATA_ID:CODE:NOROOT(0)
        DATA
`?<Initializer for __Constant_64>`:
        DD 100

        RSEG XDATA_ID:CODE:NOROOT(0)
        DATA
`?<Initializer for __Constant_1f>`:
        DD 31

        RSEG XDATA_ID:CODE:NOROOT(0)
        DATA
`?<Initializer for __Constant_2d>`:
        DD 45

        RSEG XDATA_ID:CODE:NOROOT(0)
        DATA
`?<Initializer for __Constant_185197>`:
        DD 1593751

        RSEG XDATA_ID:CODE:NOROOT(0)
        DATA
`?<Initializer for __Constant_ffe7ae6a>`:
        DD 4293373546

        RSEG XDATA_ID:CODE:NOROOT(0)
        DATA
`?<Initializer for __Constant_185196>`:
        DD 1593750

        RSEG XDATA_ID:CODE:NOROOT(0)
        DATA
`?<Initializer for __Constant_29f>`:
        DD 671

        RSEG XDATA_ID:CODE:NOROOT(0)
        DATA
`?<Initializer for __Constant_ffffffde>`:
        DD 4294967262

        RSEG XDATA_ID:CODE:NOROOT(0)
        DATA
`?<Initializer for __Constant_ffffff>`:
        DD 16777215

        RSEG XDATA_ID:CODE:NOROOT(0)
        DATA
`?<Initializer for __Constant_ffff80>`:
        DD 16777088

        RSEG XDATA_ID:CODE:NOROOT(0)
        DATA
`?<Initializer for __Constant_ffff7f>`:
        DD 16777087

        RSEG XDATA_ID:CODE:NOROOT(0)
        DATA
`?<Initializer for __Constant_22>`:
        DD 34

        RSEG XDATA_ID:CODE:NOROOT(0)
        DATA
`?<Initializer for __Constant_7d>`:
        DD 125

        RSEG XDATA_ID:CODE:NOROOT(0)
        DATA
`?<Initializer for __Constant_fff>`:
        DD 4095

        RSEG BANK_RELAYS:CODE:REORDER:NOROOT(0)
??halSleep?relay:
        LCALL   ?BDISPATCH
        DATA
        DC24    halSleep

        RSEG BANK_RELAYS:CODE:REORDER:NOROOT(0)
??halSleepSetTimer?relay:
        LCALL   ?BDISPATCH
        DATA
        DC24    halSleepSetTimer

        RSEG BANK_RELAYS:CODE:REORDER:NOROOT(0)
??TimerElapsed?relay:
        LCALL   ?BDISPATCH
        DATA
        DC24    TimerElapsed

        RSEG BANK_RELAYS:CODE:REORDER:NOROOT(0)
??HalTimerElapsed?relay:
        LCALL   ?BDISPATCH
        DATA
        DC24    HalTimerElapsed

        RSEG BANK_RELAYS:CODE:REORDER:NOROOT(0)
??halSleepWait?relay:
        LCALL   ?BDISPATCH
        DATA
        DC24    halSleepWait

        RSEG BANK_RELAYS:CODE:REORDER:NOROOT(0)
??halRestoreSleepLevel?relay:
        LCALL   ?BDISPATCH
        DATA
        DC24    halRestoreSleepLevel

        RSEG XSP:DATA:REORDER:NOROOT(0)

        END
// 
// 1 328 bytes in segment BANKED_CODE
//    36 bytes in segment BANK_RELAYS
//     3 bytes in segment INTVEC
//    33 bytes in segment NEAR_CODE
//    13 bytes in segment SFR_AN
//    61 bytes in segment XDATA_I
//    61 bytes in segment XDATA_ID
//     9 bytes in segment XDATA_Z
// 
// 1 398 bytes of CODE  memory (+ 63 bytes shared)
//     0 bytes of DATA  memory (+ 13 bytes shared)
//    10 bytes of XDATA memory (+ 60 bytes shared)
//
//Errors: none
//Warnings: none
