///////////////////////////////////////////////////////////////////////////////
//                                                                            /
// IAR 8051 C/C++ Compiler V7.30B/W32                   12/Sep/2010  21:57:25 /
// 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\osal\common\OSAL_PwrMgr.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\osal\common\OSAL_PwrMgr.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\ /
//                          OSAL_PwrMgr.s51                                   /
//                                                                            /
//                                                                            /
///////////////////////////////////////////////////////////////////////////////

        NAME OSAL_PwrMgr

        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 XSTACK:XDATA:NOROOT(0)

        EXTERN ?BANKED_ENTER_XDATA
        EXTERN ?BANKED_LEAVE_XDATA
        EXTERN ?BDISPATCH
        EXTERN ?BRET
        EXTERN ?S_SHL
        EXTERN ?V0
        EXTERN __INIT_XDATA_Z

        PUBLIC ??osal_pwrmgr_device?relay
        FUNCTION ??osal_pwrmgr_device?relay,0203H
        PUBLIC ??osal_pwrmgr_init?relay
        FUNCTION ??osal_pwrmgr_init?relay,0203H
        PUBLIC ??osal_pwrmgr_powerconserve?relay
        FUNCTION ??osal_pwrmgr_powerconserve?relay,0203H
        PUBLIC ??osal_pwrmgr_task_state?relay
        FUNCTION ??osal_pwrmgr_task_state?relay,0203H
        PUBWEAK _A_IEN0
        PUBLIC osal_pwrmgr_device
        FUNCTION osal_pwrmgr_device,0203H
        ARGFRAME XSTACK, 0, STACK
        LOCFRAME ISTACK, 2, STACK
        PUBLIC osal_pwrmgr_init
        FUNCTION osal_pwrmgr_init,0203H
        ARGFRAME XSTACK, 0, STACK
        LOCFRAME ISTACK, 2, STACK
        PUBLIC osal_pwrmgr_powerconserve
        FUNCTION osal_pwrmgr_powerconserve,021203H
        ARGFRAME XSTACK, 0, STACK
        LOCFRAME XSTACK, 10, STACK
        PUBLIC osal_pwrmgr_task_state
        FUNCTION osal_pwrmgr_task_state,0203H
        ARGFRAME XSTACK, 0, STACK
        LOCFRAME ISTACK, 1, STACK
        LOCFRAME XSTACK, 10, STACK
        PUBLIC pwrmgr_attribute
        
        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
        
osal_next_timeout   SYMBOL "osal_next_timeout"
halSleep            SYMBOL "halSleep"
??halSleep?relay    SYMBOL "?relay", halSleep
??osal_next_timeout?relay SYMBOL "?relay", osal_next_timeout
osal_pwrmgr_device  SYMBOL "osal_pwrmgr_device"
??osal_pwrmgr_device?relay SYMBOL "?relay", osal_pwrmgr_device
osal_pwrmgr_init    SYMBOL "osal_pwrmgr_init"
??osal_pwrmgr_init?relay SYMBOL "?relay", osal_pwrmgr_init
osal_pwrmgr_powerconserve SYMBOL "osal_pwrmgr_powerconserve"
??osal_pwrmgr_powerconserve?relay SYMBOL "?relay", osal_pwrmgr_powerconserve
osal_pwrmgr_task_state SYMBOL "osal_pwrmgr_task_state"
??osal_pwrmgr_task_state?relay SYMBOL "?relay", osal_pwrmgr_task_state

        EXTERN osal_next_timeout
        FUNCTION osal_next_timeout,0202H
        ARGFRAME ISTACK, 0, STACK
        ARGFRAME PSTACK, 0, STACK
        ARGFRAME XSTACK, 10, STACK
        ARGFRAME IOVERLAY, 0, STATIC
        ARGFRAME DOVERLAY, 0, STATIC
        EXTERN halSleep
        FUNCTION halSleep,0202H
        ARGFRAME ISTACK, 0, STACK
        ARGFRAME PSTACK, 0, STACK
        ARGFRAME XSTACK, 10, STACK
        ARGFRAME IOVERLAY, 0, STATIC
        ARGFRAME DOVERLAY, 0, STATIC
        EXTERN ??halSleep?relay
        FUNCTION ??halSleep?relay,00H
        EXTERN ??osal_next_timeout?relay
        FUNCTION ??osal_next_timeout?relay,00H
        EXTERN tasksCnt

// C:\Texas Instruments 33\ZStack-1.4.3-1.2.1\Components\osal\common\OSAL_PwrMgr.c
//    1 /**************************************************************************************************
//    2   Filename:       OSAL_pwrmgr.c
//    3   Revised:        $Date: 2007-10-28 18:43:04 -0700 (Sun, 28 Oct 2007) $
//    4   Revision:       $Revision: 15800 $
//    5 
//    6   Description:    This file contains the OSAL Power Management API.
//    7 
//    8 
//    9   Copyright 2004-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 "ZComDef.h"
//   45 #include "OnBoard.h"

        ASEGN SFR_AN:DATA:NOROOT,0a8H
// union <unnamed> volatile __sfr _A_IEN0
_A_IEN0:
        DS 1
//   46 #include "OSAL.h"
//   47 #include "OSAL_Tasks.h"
//   48 #include "OSAL_Timers.h"
//   49 #include "OSAL_PwrMgr.h"
//   50 
//   51 /*********************************************************************
//   52  * MACROS
//   53  */
//   54 
//   55 /*********************************************************************
//   56  * CONSTANTS
//   57  */
//   58 
//   59 /*********************************************************************
//   60  * TYPEDEFS
//   61  */
//   62 
//   63 /*********************************************************************
//   64  * GLOBAL VARIABLES
//   65  */
//   66 
//   67 /* This global variable stores the power management attributes.
//   68  */

        RSEG XDATA_Z:XDATA:NOROOT(0)
//   69 pwrmgr_attribute_t pwrmgr_attribute;
pwrmgr_attribute:
        DS 7
        REQUIRE __INIT_XDATA_Z
//   70 
//   71 /*********************************************************************
//   72  * EXTERNAL VARIABLES
//   73  */
//   74 
//   75 /*********************************************************************
//   76  * EXTERNAL FUNCTIONS
//   77  */
//   78 
//   79 /*********************************************************************
//   80  * LOCAL VARIABLES
//   81  */
//   82 
//   83 /*********************************************************************
//   84  * LOCAL FUNCTION PROTOTYPES
//   85  */
//   86 
//   87 /*********************************************************************
//   88  * FUNCTIONS
//   89  *********************************************************************/
//   90 
//   91 /*********************************************************************
//   92  * @fn      osal_pwrmgr_init
//   93  *
//   94  * @brief   Initialize the power management system.
//   95  *
//   96  * @param   none.
//   97  *
//   98  * @return  none.
//   99  */

        RSEG BANKED_CODE:CODE:NOROOT(0)
//  100 void osal_pwrmgr_init( void )
osal_pwrmgr_init:
        CFI Block cfiBlock0 Using cfiCommon0
        CFI Function osal_pwrmgr_init
//  101 {
        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
//  102   pwrmgr_attribute.pwrmgr_device = PWRMGR_ALWAYS_ON; // Default to no power conservation.
        CLR     A
        MOV     DPTR,#(pwrmgr_attribute + 6)
        MOVX    @DPTR,A
//  103   pwrmgr_attribute.pwrmgr_task_state = 0;            // Cleared.  All set to conserve
        MOV     DPTR,#pwrmgr_attribute
        MOVX    @DPTR,A
        INC     DPTR
        CFI EndBlock cfiBlock0
        REQUIRE ?Subroutine0
        ; // Fall through to label ?Subroutine0
//  104 }

        RSEG BANKED_CODE:CODE:NOROOT(0)
?Subroutine0:
        CFI Block cfiBlock1 Using cfiCommon0
        CFI NoFunction
        CFI CFA_SP SP+-5
        CFI DPL0 Frame(CFA_SP, 4)
        CFI DPH0 Frame(CFA_SP, 5)
        MOVX    @DPTR,A
        POP     DPH
        CFI CFA_SP SP+-4
        CFI DPH0 SameValue
        POP     DPL
        CFI CFA_SP SP+-3
        CFI DPL0 SameValue
        LJMP    ?BRET
        CFI EndBlock cfiBlock1
//  105 
//  106 /*********************************************************************
//  107  * @fn      osal_pwrmgr_device
//  108  *
//  109  * @brief   Sets the device power characteristic.
//  110  *
//  111  * @param   pwrmgr_device - type of power devices. With PWRMGR_ALWAYS_ON
//  112  *          selection, there is no power savings and the device is most
//  113  *          likely on mains power. The PWRMGR_BATTERY selection allows the
//  114  *          HAL sleep manager to enter sleep.
//  115  *
//  116  * @return  none
//  117  */

        RSEG BANKED_CODE:CODE:NOROOT(0)
//  118 void osal_pwrmgr_device( uint8 pwrmgr_device )
osal_pwrmgr_device:
        CFI Block cfiBlock2 Using cfiCommon0
        CFI Function osal_pwrmgr_device
//  119 {
        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
//  120   pwrmgr_attribute.pwrmgr_device = pwrmgr_device;
        MOV     A,R1
        MOV     DPTR,#(pwrmgr_attribute + 6)
        SJMP    ?Subroutine0
        CFI EndBlock cfiBlock2
//  121 }
//  122 
//  123 /*********************************************************************
//  124  * @fn      osal_pwrmgr_task_state
//  125  *
//  126  * @brief   This function is called by each task to state whether or
//  127  *          not this task wants to conserve power.
//  128  *
//  129  * @param   task_id - calling task ID.
//  130  *          state - whether the calling task wants to
//  131  *          conserve power or not.
//  132  *
//  133  * @return  ZSUCCESS if task complete
//  134  */

        RSEG BANKED_CODE:CODE:NOROOT(0)
//  135 uint8 osal_pwrmgr_task_state( uint8 task_id, uint8 state )
osal_pwrmgr_task_state:
        CFI Block cfiBlock3 Using cfiCommon0
        CFI Function osal_pwrmgr_task_state
//  136 {
        MOV     A,#-0xa
        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 V1 load(1, XDATA, add(CFA_XSP16, literal(-7)))
        CFI V0 load(1, XDATA, add(CFA_XSP16, literal(-8)))
        CFI VB load(1, XDATA, add(CFA_XSP16, literal(-9)))
        CFI R6 load(1, XDATA, add(CFA_XSP16, literal(-10)))
        CFI CFA_SP SP+0
        CFI CFA_XSP16 add(XSP16, 10)
        ; Saved register size: 10
        ; Auto size: 0
//  137   if ( task_id >= tasksCnt )
        MOV     DPTR,#tasksCnt
        MOVX    A,@DPTR
        MOV     R3,A
        MOV     A,R1
        CLR     C
        SUBB    A,R3
        JC      ??osal_pwrmgr_task_state_0
//  138     return ( INVALID_TASK );
        MOV     R1,#0x1
        SJMP    ??osal_pwrmgr_task_state_1
//  139 
//  140   if ( state == PWRMGR_CONSERVE )
??osal_pwrmgr_task_state_0:
        MOV     A,R2
        MOV     ?V0 + 0,#0x1
        MOV     ?V0 + 1,#0x0
        JNZ     ??osal_pwrmgr_task_state_2
//  141   {
//  142     // Clear the task state flag
//  143     pwrmgr_attribute.pwrmgr_task_state &= ~(1 << task_id );
        MOV     A,R1
        MOV     R0,#?V0 + 0
        LCALL   ?S_SHL
        MOV     A,?V0 + 0
        CPL     A
        MOV     R0,A
        MOV     A,?V0 + 1
        CPL     A
        MOV     R1,A
        MOV     DPTR,#pwrmgr_attribute
        MOVX    A,@DPTR
        ANL     A,R0
        MOVX    @DPTR,A
        INC     DPTR
        MOVX    A,@DPTR
        ANL     A,R1
        SJMP    ??osal_pwrmgr_task_state_3
//  144   }
//  145   else
//  146   {
//  147     // Set the task state flag
//  148     pwrmgr_attribute.pwrmgr_task_state |= (1 << task_id);
??osal_pwrmgr_task_state_2:
        MOV     A,R1
        MOV     R0,#?V0 + 0
        LCALL   ?S_SHL
        MOV     DPTR,#pwrmgr_attribute
        MOVX    A,@DPTR
        ORL     A,?V0 + 0
        MOVX    @DPTR,A
        INC     DPTR
        MOVX    A,@DPTR
        ORL     A,?V0 + 1
??osal_pwrmgr_task_state_3:
        MOVX    @DPTR,A
//  149   }
//  150 
//  151   return ( ZSUCCESS );
        MOV     R1,#0x0
        CFI EndBlock cfiBlock3
??osal_pwrmgr_task_state_1:
        REQUIRE ?Subroutine1
        ; // Fall through to label ?Subroutine1
//  152 }

        RSEG BANKED_CODE:CODE:NOROOT(0)
?Subroutine1:
        CFI Block cfiBlock4 Using cfiCommon0
        CFI NoFunction
        CFI CFA_SP SP+0
        CFI CFA_XSP16 add(XSP16, 10)
        CFI VB load(1, XDATA, add(CFA_XSP16, literal(-9)))
        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(-10)))
        CFI R7 load(1, XDATA, add(CFA_XSP16, literal(-6)))
        CFI V0 load(1, XDATA, add(CFA_XSP16, literal(-8)))
        CFI V1 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     R7,#0x2
        LJMP    ?BANKED_LEAVE_XDATA
        CFI EndBlock cfiBlock4
//  153 
//  154 #if defined( POWER_SAVING )
//  155 /*********************************************************************
//  156  * @fn      osal_pwrmgr_powerconserve
//  157  *
//  158  * @brief   This function is called from the main OSAL loop when there are
//  159  *          no events scheduled and shouldn't be called from anywhere else.
//  160  *
//  161  * @param   none.
//  162  *
//  163  * @return  none.
//  164  */

        RSEG BANKED_CODE:CODE:NOROOT(0)
//  165 void osal_pwrmgr_powerconserve( void )
osal_pwrmgr_powerconserve:
        CFI Block cfiBlock5 Using cfiCommon0
        CFI Function osal_pwrmgr_powerconserve
//  166 {
        FUNCALL osal_pwrmgr_powerconserve, osal_next_timeout
        LOCFRAME ISTACK, 0, STACK
        LOCFRAME PSTACK, 0, STACK
        LOCFRAME XSTACK, 10, STACK
        LOCFRAME IOVERLAY, 0, STATIC
        LOCFRAME DOVERLAY, 0, STATIC
        ARGFRAME ISTACK, 0, STACK
        ARGFRAME PSTACK, 0, STACK
        ARGFRAME XSTACK, 10, STACK
        ARGFRAME IOVERLAY, 0, STATIC
        ARGFRAME DOVERLAY, 0, STATIC
        FUNCALL osal_pwrmgr_powerconserve, halSleep
        LOCFRAME ISTACK, 0, STACK
        LOCFRAME PSTACK, 0, STACK
        LOCFRAME XSTACK, 10, STACK
        LOCFRAME IOVERLAY, 0, STATIC
        LOCFRAME DOVERLAY, 0, STATIC
        ARGFRAME ISTACK, 0, STACK
        ARGFRAME PSTACK, 0, STACK
        ARGFRAME XSTACK, 10, STACK
        ARGFRAME IOVERLAY, 0, STATIC
        ARGFRAME DOVERLAY, 0, STATIC
        MOV     A,#-0xa
        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 V1 load(1, XDATA, add(CFA_XSP16, literal(-7)))
        CFI V0 load(1, XDATA, add(CFA_XSP16, literal(-8)))
        CFI VB load(1, XDATA, add(CFA_XSP16, literal(-9)))
        CFI R6 load(1, XDATA, add(CFA_XSP16, literal(-10)))
        CFI CFA_SP SP+0
        CFI CFA_XSP16 add(XSP16, 10)
        ; Saved register size: 10
        ; Auto size: 0
//  167   uint16        next;
//  168   halIntState_t intState;
//  169 
//  170   // Should we even look into power conservation
//  171   if ( pwrmgr_attribute.pwrmgr_device != PWRMGR_ALWAYS_ON )
        MOV     DPTR,#(pwrmgr_attribute + 6)
        MOVX    A,@DPTR
        JZ      ??osal_pwrmgr_powerconserve_0
//  172   {
//  173     // Are all tasks in agreement to conserve
//  174     if ( pwrmgr_attribute.pwrmgr_task_state == 0 )
        MOV     DPTR,#pwrmgr_attribute
        MOVX    A,@DPTR
        JNZ     ??osal_pwrmgr_powerconserve_1
        INC     DPTR
        MOVX    A,@DPTR
??osal_pwrmgr_powerconserve_1:
        JNZ     ??osal_pwrmgr_powerconserve_0
//  175     {
//  176       // Hold off interrupts.
//  177       HAL_ENTER_CRITICAL_SECTION( intState );
        MOV     C,0xa8.7
        CLR     A
        MOV     0xE0 /* A   */.0,C
        MOV     R6,A
        CLR     0xa8.7
//  178 
//  179       // Get next time-out
//  180       next = osal_next_timeout();
        ; Setup parameters for call to function osal_next_timeout
        LCALL   ??osal_next_timeout?relay
//  181 
//  182       // Re-enable interrupts.
//  183       HAL_EXIT_CRITICAL_SECTION( intState );
        MOV     A,R6
        MOV     C,0xE0 /* A   */.0
        MOV     0xa8.7,C
//  184 
//  185       // Put the processor into sleep mode
//  186       OSAL_SET_CPU_INTO_SLEEP( next );
        ; Setup parameters for call to function halSleep
        LCALL   ??halSleep?relay
//  187     }
//  188   }
//  189 }
??osal_pwrmgr_powerconserve_0:
        SJMP    ?Subroutine1
        CFI EndBlock cfiBlock5
        REQUIRE _A_IEN0

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

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

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

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

        END
//  190 #endif /* POWER_SAVING */
//  191 
//  192 /*********************************************************************
//  193 *********************************************************************/
// 
// 152 bytes in segment BANKED_CODE
//  24 bytes in segment BANK_RELAYS
//   1 byte  in segment SFR_AN
//   7 bytes in segment XDATA_Z
// 
// 176 bytes of CODE  memory
//   0 bytes of DATA  memory (+ 1 byte shared)
//   7 bytes of XDATA memory
//
//Errors: none
//Warnings: none
