///////////////////////////////////////////////////////////////////////////////
//                                                                            /
// IAR 8051 C/C++ Compiler V7.30B/W32                   21/Jun/2010  17:06:54 /
// 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\ZStack-1.4.3-1.2.1\Projects\ /
//                          zstack\ZMain\TI2430DB\OnBoard.c                   /
//    Command line       =  -f "C:\Texas Instruments\ZStack-1.4.3-1.2.1\Proje /
//                          cts\zstack\Project\Location\CC2430DB\..\..\..\Too /
//                          ls\CC2430DB\f8wCoord.cfg" (-DCPU32MHZ             /
//                          -DFORCE_MAC_NEAR -DROOT=__near_func               /
//                          -DMAC_CFG_APP_PENDING_QUEUE=TRUE                  /
//                          -DZDO_COORDINATOR -DRTR_NWK -DBLINK_LEDS          /
//                          "-DCONST=const __code" -DGENERIC=__generic) -f    /
//                          "C:\Texas Instruments\ZStack-1.4.3-1.2.1\Projects /
//                          \zstack\Project\Location\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\ZStack-1.4.3-1.2.1\Projects /
//                          \zstack\ZMain\TI2430DB\OnBoard.c" -D CC2430EB -D  /
//                          ZTOOL_P1 -D LOCATION_DONGLE -D MT_TASK -D         /
//                          xNV_RESTORE -D INT_HEAP_LEN=4608 -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\ZStack-1.4.3-1.2.1\Projects\zstack\Pr /
//                          oject\Location\CC2430DB\LocDongle\List\" -lA      /
//                          "C:\Texas Instruments\ZStack-1.4.3-1.2.1\Projects /
//                          \zstack\Project\Location\CC2430DB\LocDongle\List\ /
//                          " --diag_suppress Pe001,Pa010 --diag_remark       /
//                          pe550 -o "C:\Texas Instruments\ZStack-1.4.3-1.2.1 /
//                          \Projects\zstack\Project\Location\CC2430DB\LocDon /
//                          gle\Obj\" -e --require_prototypes -z9             /
//                          --no_code_motion --debug --core=plain             /
//                          --dptr=16,1 --data_model=large                    /
//                          --code_model=banked --calling_convention=xdata_re /
//                          entrant --place_constants=data --nr_virtual_regs  /
//                          8 -I "C:\Texas Instruments\ZStack-1.4.3-1.2.1\Pro /
//                          jects\zstack\Project\Location\CC2430DB\" -I       /
//                          "C:\Texas Instruments\ZStack-1.4.3-1.2.1\Projects /
//                          \zstack\Project\Location\CC2430DB\..\SOURCE\" -I  /
//                          "C:\Texas Instruments\ZStack-1.4.3-1.2.1\Projects /
//                          \zstack\Project\Location\CC2430DB\..\..\..\ZMAIN\ /
//                          TI2430DB\" -I "C:\Texas                           /
//                          Instruments\ZStack-1.4.3-1.2.1\Projects\zstack\Pr /
//                          oject\Location\CC2430DB\..\..\..\..\WXL\INCLUDE\" /
//                           -I "C:\Texas Instruments\ZStack-1.4.3-1.2.1\Proj /
//                          ects\zstack\Project\Location\CC2430DB\..\..\..\.. /
//                          \..\COMPONENTS\MT\" -I "C:\Texas                  /
//                          Instruments\ZStack-1.4.3-1.2.1\Projects\zstack\Pr /
//                          oject\Location\CC2430DB\..\..\..\..\..\COMPONENTS /
//                          \HAL\INCLUDE\" -I "C:\Texas                       /
//                          Instruments\ZStack-1.4.3-1.2.1\Projects\zstack\Pr /
//                          oject\Location\CC2430DB\..\..\..\..\..\COMPONENTS /
//                          \HAL\TARGET\CC2430EB\" -I "C:\Texas               /
//                          Instruments\ZStack-1.4.3-1.2.1\Projects\zstack\Pr /
//                          oject\Location\CC2430DB\..\..\..\..\..\COMPONENTS /
//                          \OSAL\MCU\CCSOC\" -I "C:\Texas                    /
//                          Instruments\ZStack-1.4.3-1.2.1\Projects\zstack\Pr /
//                          oject\Location\CC2430DB\..\..\..\..\..\COMPONENTS /
//                          \OSAL\INCLUDE\" -I "C:\Texas                      /
//                          Instruments\ZStack-1.4.3-1.2.1\Projects\zstack\Pr /
//                          oject\Location\CC2430DB\..\..\..\..\..\COMPONENTS /
//                          \STACK\AF\" -I "C:\Texas                          /
//                          Instruments\ZStack-1.4.3-1.2.1\Projects\zstack\Pr /
//                          oject\Location\CC2430DB\..\..\..\..\..\COMPONENTS /
//                          \STACK\NWK\" -I "C:\Texas                         /
//                          Instruments\ZStack-1.4.3-1.2.1\Projects\zstack\Pr /
//                          oject\Location\CC2430DB\..\..\..\..\..\COMPONENTS /
//                          \STACK\SEC\" -I "C:\Texas                         /
//                          Instruments\ZStack-1.4.3-1.2.1\Projects\zstack\Pr /
//                          oject\Location\CC2430DB\..\..\..\..\..\COMPONENTS /
//                          \STACK\SYS\" -I "C:\Texas                         /
//                          Instruments\ZStack-1.4.3-1.2.1\Projects\zstack\Pr /
//                          oject\Location\CC2430DB\..\..\..\..\..\COMPONENTS /
//                          \STACK\ZDO\" -I "C:\Texas                         /
//                          Instruments\ZStack-1.4.3-1.2.1\Projects\zstack\Pr /
//                          oject\Location\CC2430DB\..\..\..\..\..\COMPONENTS /
//                          \ZMAC\F8W\" -I "C:\Texas                          /
//                          Instruments\ZStack-1.4.3-1.2.1\Projects\zstack\Pr /
//                          oject\Location\CC2430DB\..\..\..\..\..\COMPONENTS /
//                          \ZMAC\" -I "C:\Texas Instruments\ZStack-1.4.3-1.2 /
//                          .1\Projects\zstack\Project\Location\CC2430DB\..\. /
//                          .\..\..\..\COMPONENTS\SERVICES\SADDR\" -I         /
//                          "C:\Texas Instruments\ZStack-1.4.3-1.2.1\Projects /
//                          \zstack\Project\Location\CC2430DB\..\..\..\..\..\ /
//                          COMPONENTS\SERVICES\SDATA\" -I "C:\Texas          /
//                          Instruments\ZStack-1.4.3-1.2.1\Projects\zstack\Pr /
//                          oject\Location\CC2430DB\..\..\..\..\..\COMPONENTS /
//                          \MAC\INCLUDE\" -I "C:\Texas                       /
//                          Instruments\ZStack-1.4.3-1.2.1\Projects\zstack\Pr /
//                          oject\Location\CC2430DB\..\..\..\..\..\COMPONENTS /
//                          \MAC\HIGH_LEVEL\" -I "C:\Texas                    /
//                          Instruments\ZStack-1.4.3-1.2.1\Projects\zstack\Pr /
//                          oject\Location\CC2430DB\..\..\..\..\..\COMPONENTS /
//                          \MAC\LOW_LEVEL\SRF03\" -I "C:\Texas               /
//                          Instruments\ZStack-1.4.3-1.2.1\Projects\zstack\Pr /
//                          oject\Location\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\ZStack-1.4.3-1.2.1\Projects\ /
//                          zstack\Project\Location\CC2430DB\LocDongle\List\O /
//                          nBoard.s51                                        /
//                                                                            /
//                                                                            /
///////////////////////////////////////////////////////////////////////////////

        NAME OnBoard

        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 ??OnBoard_KeyCallback?relay
        EXTERN ??OnBoard_SendKeys?relay
        EXTERN ??Onboard_TimerCallBack?relay
        EXTERN ??Onboard_wait?relay
        EXTERN ?ALLOC_XSTACK8
        EXTERN ?BANKED_ENTER_XDATA
        EXTERN ?BANKED_LEAVE_XDATA
        EXTERN ?BDISPATCH
        EXTERN ?BRET
        EXTERN ?DEALLOC_XSTACK8
        EXTERN ?PUSH_XSTACK_I_TWO
        EXTERN ?US_DIV_MOD
        EXTERN ?V0
        EXTERN ?XSP
        EXTERN __INIT_XDATA_I
        EXTERN __INIT_XDATA_Z

        PUBLIC ??BigLight_Off?relay
        FUNCTION ??BigLight_Off?relay,0203H
        PUBLIC ??BigLight_On?relay
        FUNCTION ??BigLight_On?relay,0203H
        PUBLIC ??BuzzerControl?relay
        FUNCTION ??BuzzerControl?relay,0203H
        PUBLIC ??Dimmer?relay
        FUNCTION ??Dimmer?relay,0203H
        PUBLIC ??GetUserDipSw?relay
        FUNCTION ??GetUserDipSw?relay,0203H
        PUBLIC ??InitBoard?relay
        FUNCTION ??InitBoard?relay,0203H
        PUBLIC ??OnBoard_KeyCallback?relay
        FUNCTION ??OnBoard_KeyCallback?relay,0203H
        PUBLIC ??OnBoard_SendKeys?relay
        FUNCTION ??OnBoard_SendKeys?relay,0203H
        PUBLIC ??OnBoard_stack_used?relay
        FUNCTION ??OnBoard_stack_used?relay,0203H
        PUBLIC ??Onboard_TimerCallBack?relay
        FUNCTION ??Onboard_TimerCallBack?relay,0203H
        PUBLIC ??Onboard_rand?relay
        FUNCTION ??Onboard_rand?relay,0203H
        PUBLIC ??Onboard_wait?relay
        FUNCTION ??Onboard_wait?relay,0203H
        PUBLIC ??RegisterForKeys?relay
        FUNCTION ??RegisterForKeys?relay,0203H
        PUBLIC ??_itoa?relay
        FUNCTION ??_itoa?relay,0203H
        PUBLIC BigLight_Off
        FUNCTION BigLight_Off,0203H
        ARGFRAME XSTACK, 0, STACK
        PUBLIC BigLight_On
        FUNCTION BigLight_On,0203H
        ARGFRAME XSTACK, 0, STACK
        PUBLIC BuzzerControl
        FUNCTION BuzzerControl,0203H
        ARGFRAME XSTACK, 0, STACK
        PUBLIC Dimmer
        FUNCTION Dimmer,0203H
        ARGFRAME XSTACK, 0, STACK
        PUBLIC GetUserDipSw
        FUNCTION GetUserDipSw,0203H
        ARGFRAME XSTACK, 0, STACK
        PUBLIC InitBoard
        FUNCTION InitBoard,021203H
        ARGFRAME XSTACK, 0, STACK
        LOCFRAME XSTACK, 12, STACK
        PUBLIC OnBoard_KeyCallback
        FUNCTION OnBoard_KeyCallback,021603H
        ARGFRAME XSTACK, 0, STACK
        LOCFRAME ISTACK, 2, STACK
        PUBLIC OnBoard_SendKeys
        FUNCTION OnBoard_SendKeys,021203H
        ARGFRAME XSTACK, 0, STACK
        ARGFRAME IOVERLAY, 0, STATIC
        ARGFRAME DOVERLAY, 0, STATIC
        LOCFRAME ISTACK, 1, STACK
        LOCFRAME XSTACK, 10, STACK
        PUBLIC OnBoard_stack_used
        FUNCTION OnBoard_stack_used,0203H
        ARGFRAME XSTACK, 0, STACK
        LOCFRAME ISTACK, 2, STACK
        PUBLIC OnboardKeyIntEnable
        PUBLIC OnboardTimerIntEnable
        PUBLIC Onboard_TimerCallBack
        FUNCTION Onboard_TimerCallBack,021603H
        ARGFRAME XSTACK, 0, STACK
        LOCFRAME ISTACK, 2, STACK
        PUBLIC Onboard_rand
        FUNCTION Onboard_rand,021203H
        ARGFRAME XSTACK, 0, STACK
        LOCFRAME XSTACK, 9, STACK
        PUBLIC Onboard_wait
        FUNCTION Onboard_wait,080203H
        ARGFRAME XSTACK, 10, STACK
        ARGFRAME IOVERLAY, 0, STATIC
        ARGFRAME DOVERLAY, 0, STATIC
        PUBLIC RegisterForKeys
        FUNCTION RegisterForKeys,0203H
        ARGFRAME XSTACK, 0, STACK
        LOCFRAME ISTACK, 2, STACK
        PUBWEAK SLEEP
        PUBWEAK _A_IEN0
        PUBLIC _itoa
        FUNCTION _itoa,0203H
        ARGFRAME XSTACK, 0, STACK
        LOCFRAME ISTACK, 1, STACK
        LOCFRAME XSTACK, 19, STACK
        PUBLIC aExtendedAddress
        
        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_int_disable    SYMBOL "osal_int_disable"
HalLedSet           SYMBOL "HalLedSet"
HalTimerConfig      SYMBOL "HalTimerConfig"
MT_IndReset         SYMBOL "MT_IndReset"
HalKeyConfig        SYMBOL "HalKeyConfig"
osal_msg_allocate   SYMBOL "osal_msg_allocate"
osal_msg_send       SYMBOL "osal_msg_send"
macMcuRandomByte    SYMBOL "macMcuRandomByte"
osal_update_timers  SYMBOL "osal_update_timers"
??HalKeyConfig?relay SYMBOL "?relay", HalKeyConfig
??HalLedSet?relay   SYMBOL "?relay", HalLedSet
??HalTimerConfig?relay SYMBOL "?relay", HalTimerConfig
??MT_IndReset?relay SYMBOL "?relay", MT_IndReset
??macMcuRandomByte?relay SYMBOL "?relay", macMcuRandomByte
??osal_int_disable?relay SYMBOL "?relay", osal_int_disable
??osal_msg_allocate?relay SYMBOL "?relay", osal_msg_allocate
??osal_msg_send?relay SYMBOL "?relay", osal_msg_send
??osal_update_timers?relay SYMBOL "?relay", osal_update_timers
BigLight_Off        SYMBOL "BigLight_Off"
??BigLight_Off?relay SYMBOL "?relay", BigLight_Off
BigLight_On         SYMBOL "BigLight_On"
??BigLight_On?relay SYMBOL "?relay", BigLight_On
BuzzerControl       SYMBOL "BuzzerControl"
??BuzzerControl?relay SYMBOL "?relay", BuzzerControl
Dimmer              SYMBOL "Dimmer"
??Dimmer?relay      SYMBOL "?relay", Dimmer
GetUserDipSw        SYMBOL "GetUserDipSw"
??GetUserDipSw?relay SYMBOL "?relay", GetUserDipSw
InitBoard           SYMBOL "InitBoard"
??InitBoard?relay   SYMBOL "?relay", InitBoard
OnBoard_KeyCallback SYMBOL "OnBoard_KeyCallback"
??OnBoard_KeyCallback?relay SYMBOL "?relay", OnBoard_KeyCallback
OnBoard_SendKeys    SYMBOL "OnBoard_SendKeys"
??OnBoard_SendKeys?relay SYMBOL "?relay", OnBoard_SendKeys
OnBoard_stack_used  SYMBOL "OnBoard_stack_used"
??OnBoard_stack_used?relay SYMBOL "?relay", OnBoard_stack_used
Onboard_TimerCallBack SYMBOL "Onboard_TimerCallBack"
??Onboard_TimerCallBack?relay SYMBOL "?relay", Onboard_TimerCallBack
Onboard_rand        SYMBOL "Onboard_rand"
??Onboard_rand?relay SYMBOL "?relay", Onboard_rand
Onboard_wait        SYMBOL "Onboard_wait"
??Onboard_wait?relay SYMBOL "?relay", Onboard_wait
RegisterForKeys     SYMBOL "RegisterForKeys"
??RegisterForKeys?relay SYMBOL "?relay", RegisterForKeys
_itoa               SYMBOL "_itoa"
??_itoa?relay       SYMBOL "?relay", _itoa

        EXTERN osal_int_disable
        FUNCTION osal_int_disable,0202H
        ARGFRAME ISTACK, 0, STACK
        ARGFRAME PSTACK, 0, STACK
        ARGFRAME XSTACK, 10, STACK
        ARGFRAME IOVERLAY, 0, STATIC
        ARGFRAME DOVERLAY, 0, STATIC
        EXTERN HalLedSet
        FUNCTION HalLedSet,0202H
        ARGFRAME ISTACK, 0, STACK
        ARGFRAME PSTACK, 0, STACK
        ARGFRAME XSTACK, 10, STACK
        ARGFRAME IOVERLAY, 0, STATIC
        ARGFRAME DOVERLAY, 0, STATIC
        EXTERN HalTimerConfig
        FUNCTION HalTimerConfig,0202H
        ARGFRAME ISTACK, 0, STACK
        ARGFRAME PSTACK, 0, STACK
        ARGFRAME XSTACK, 12, STACK
        ARGFRAME IOVERLAY, 0, STATIC
        ARGFRAME DOVERLAY, 0, STATIC
        EXTERN MT_IndReset
        FUNCTION MT_IndReset,0202H
        ARGFRAME ISTACK, 0, STACK
        ARGFRAME PSTACK, 0, STACK
        ARGFRAME XSTACK, 10, STACK
        ARGFRAME IOVERLAY, 0, STATIC
        ARGFRAME DOVERLAY, 0, STATIC
        EXTERN HalKeyConfig
        FUNCTION HalKeyConfig,0202H
        ARGFRAME ISTACK, 0, STACK
        ARGFRAME PSTACK, 0, STACK
        ARGFRAME XSTACK, 10, STACK
        ARGFRAME IOVERLAY, 0, STATIC
        ARGFRAME DOVERLAY, 0, STATIC
        EXTERN osal_msg_allocate
        FUNCTION osal_msg_allocate,0202H
        ARGFRAME ISTACK, 0, STACK
        ARGFRAME PSTACK, 0, STACK
        ARGFRAME XSTACK, 10, STACK
        ARGFRAME IOVERLAY, 0, STATIC
        ARGFRAME DOVERLAY, 0, STATIC
        EXTERN osal_msg_send
        FUNCTION osal_msg_send,0202H
        ARGFRAME ISTACK, 0, STACK
        ARGFRAME PSTACK, 0, STACK
        ARGFRAME XSTACK, 10, STACK
        ARGFRAME IOVERLAY, 0, STATIC
        ARGFRAME DOVERLAY, 0, STATIC
        EXTERN macMcuRandomByte
        FUNCTION macMcuRandomByte,0202H
        ARGFRAME ISTACK, 0, STACK
        ARGFRAME PSTACK, 0, STACK
        ARGFRAME XSTACK, 9, STACK
        ARGFRAME IOVERLAY, 0, STATIC
        ARGFRAME DOVERLAY, 0, STATIC
        EXTERN osal_update_timers
        FUNCTION osal_update_timers,0202H
        ARGFRAME ISTACK, 2, STACK
        ARGFRAME PSTACK, 0, STACK
        ARGFRAME XSTACK, 0, STACK
        ARGFRAME IOVERLAY, 0, STATIC
        ARGFRAME DOVERLAY, 0, STATIC
        EXTERN ??HalKeyConfig?relay
        FUNCTION ??HalKeyConfig?relay,00H
        EXTERN ??HalLedSet?relay
        FUNCTION ??HalLedSet?relay,00H
        EXTERN ??HalTimerConfig?relay
        FUNCTION ??HalTimerConfig?relay,00H
        EXTERN ??MT_IndReset?relay
        FUNCTION ??MT_IndReset?relay,00H
        EXTERN ??macMcuRandomByte?relay
        FUNCTION ??macMcuRandomByte?relay,00H
        EXTERN ??osal_int_disable?relay
        FUNCTION ??osal_int_disable?relay,00H
        EXTERN ??osal_msg_allocate?relay
        FUNCTION ??osal_msg_allocate?relay,00H
        EXTERN ??osal_msg_send?relay
        FUNCTION ??osal_msg_send?relay,00H
        EXTERN ??osal_update_timers?relay
        FUNCTION ??osal_update_timers?relay,00H

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

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

        ASEGN SFR_AN:DATA:NOROOT,0beH
// unsigned char volatile __sfr SLEEP
SLEEP:
        DS 1
//   48 #include "OSAL.h"
//   49 #include "MTEL.h"
//   50 #include "DebugTrace.h"
//   51 
//   52 /* Hal */
//   53 //#include "hal_lcd.h"
//   54 
//   55 #if defined( LCD_SUPPORTED )
//   56   #include "lcd128_64.h"
//   57 #endif
//   58 #include "hal_mcu.h"
//   59 #include "hal_timer.h"
//   60 #include "hal_key.h"
//   61 #include "hal_led.h"
//   62 
//   63 /*********************************************************************
//   64  * MACROS
//   65  */
//   66 
//   67 /*********************************************************************
//   68  * CONSTANTS
//   69  */
//   70 
//   71 // Task ID not initialized
//   72 #define NO_TASK_ID 0xFF
//   73 
//   74 // Minimum length RAM "pattern" for Stack check
//   75 #define MIN_RAM_INIT 12
//   76 
//   77 /*********************************************************************
//   78  * TYPEDEFS
//   79  */
//   80 
//   81 /*********************************************************************
//   82  * GLOBAL VARIABLES
//   83  */
//   84 

        RSEG XDATA_Z:XDATA:NOROOT(0)
//   85 uint8 OnboardKeyIntEnable;
OnboardKeyIntEnable:
        DS 1
        REQUIRE __INIT_XDATA_Z

        RSEG XDATA_Z:XDATA:NOROOT(0)
//   86 uint8 OnboardTimerIntEnable;
OnboardTimerIntEnable:
        DS 1
        REQUIRE __INIT_XDATA_Z
//   87 
//   88 // 64-bit Extended Address of this device

        RSEG XDATA_Z:XDATA:NOROOT(0)
//   89 uint8 aExtendedAddress[8];
aExtendedAddress:
        DS 8
        REQUIRE __INIT_XDATA_Z
//   90 
//   91 /*********************************************************************
//   92  * EXTERNAL VARIABLES
//   93  */
//   94 
//   95 /*********************************************************************
//   96  * EXTERNAL FUNCTIONS
//   97  */
//   98 
//   99 extern uint8 macMcuRandomByte(void);
//  100 
//  101 /*********************************************************************
//  102  * LOCAL VARIABLES
//  103  */
//  104 
//  105 // Registered keys task ID, initialized to NOT USED.

        RSEG XDATA_I:XDATA:NOROOT(0)
        DATA
//  106 static byte registeredKeysTaskID = NO_TASK_ID;
registeredKeysTaskID:
        DS 1
        REQUIRE `?<Initializer for registeredKeysTaskID>`
        REQUIRE __INIT_XDATA_I
//  107 
//  108 /*********************************************************************
//  109  * LOCAL FUNCTIONS
//  110  */
//  111 
//  112 static void ChkReset( void );
//  113 
//  114 /*********************************************************************
//  115  * @fn      InitBoard()
//  116  * @brief   Initialize the CC2420DB Board Peripherals
//  117  * @param   level: COLD,WARM,READY
//  118  * @return  None
//  119  */

        RSEG BANKED_CODE:CODE:NOROOT(0)
//  120 void InitBoard( byte level )
InitBoard:
        CFI Block cfiBlock0 Using cfiCommon0
        CFI Function InitBoard
//  121 {
        FUNCALL InitBoard, osal_int_disable
        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 InitBoard, HalLedSet
        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 InitBoard, HalLedSet
        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 InitBoard, Onboard_wait
        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 InitBoard, Onboard_wait
        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 InitBoard, HalLedSet
        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 InitBoard, Onboard_wait
        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 InitBoard, Onboard_wait
        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 InitBoard, HalTimerConfig
        LOCFRAME ISTACK, 0, STACK
        LOCFRAME PSTACK, 0, STACK
        LOCFRAME XSTACK, 12, STACK
        LOCFRAME IOVERLAY, 0, STATIC
        LOCFRAME DOVERLAY, 0, STATIC
        ARGFRAME ISTACK, 0, STACK
        ARGFRAME PSTACK, 0, STACK
        ARGFRAME XSTACK, 12, STACK
        ARGFRAME IOVERLAY, 0, STATIC
        ARGFRAME DOVERLAY, 0, STATIC
        FUNCALL InitBoard, MT_IndReset
        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 InitBoard, HalKeyConfig
        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
//  122   if ( level == OB_COLD )
        MOV     A,R1
        JNZ     ??InitBoard_0
//  123   {
//  124     // Interrupts off
//  125     osal_int_disable( INTS_ALL );
        ; Setup parameters for call to function osal_int_disable
        MOV     R1,#-0x1
        LCALL   ??osal_int_disable?relay
//  126     // Turn all LEDs off
//  127     HalLedSet( HAL_LED_ALL, HAL_LED_MODE_OFF );
        ; Setup parameters for call to function HalLedSet
        MOV     R2,#0x0
        MOV     R1,#0xf
        LCALL   ??HalLedSet?relay
//  128     // Check for Brown-Out reset
//  129     ChkReset();
        MOV     A,#0x18
        ANL     A,0xbe
        MOV     R2,A
        JZ      ??InitBoard_1
        MOV     A,#0x8
        XRL     A,R2
        JZ      ??InitBoard_1
        MOV     A,#0x10
        XRL     A,R2
        JZ      ??InitBoard_1
        CLR     0xa8.7
        SJMP    ??InitBoard_2
??InitBoard_3:
        ; Setup parameters for call to function HalLedSet
        MOV     R2,#0x1
        MOV     A,R6
        MOV     R1,A
        LCALL   ??HalLedSet?relay
        ; Setup parameters for call to function Onboard_wait
        MOV     R2,#0x24
        MOV     R3,#-0xc
        LCALL   ??Onboard_wait?relay
        ; Setup parameters for call to function Onboard_wait
        MOV     R2,#0x24
        MOV     R3,#-0xc
        LCALL   ??Onboard_wait?relay
        ; Setup parameters for call to function HalLedSet
        MOV     R2,#0x0
        MOV     A,R6
        MOV     R1,A
        LCALL   ??HalLedSet?relay
        ; Setup parameters for call to function Onboard_wait
        MOV     R2,#0x7c
        MOV     R3,#-0x6e
        LCALL   ??Onboard_wait?relay
        ; Setup parameters for call to function Onboard_wait
        MOV     R2,#0x7c
        MOV     R3,#-0x6e
        LCALL   ??Onboard_wait?relay
        MOV     A,R6
        CLR     C
        RRC     A
        MOV     R6,A
        JNZ     ??InitBoard_3
??InitBoard_2:
        MOV     R6,#0x8
        SJMP    ??InitBoard_3
//  130 
//  131   /* Timer2 for Osal timer
//  132    * This development board uses ATmega128 Timer/Counter3 to provide
//  133    * system clock ticks for the OSAL scheduler. These functions perform
//  134    * the hardware specific actions required by the OSAL_Timers module.
//  135    */
//  136    OnboardTimerIntEnable = FALSE;
??InitBoard_1:
        CLR     A
        MOV     DPTR,#OnboardTimerIntEnable
        MOVX    @DPTR,A
//  137  	 HalTimerConfig (OSAL_TIMER,                        // 8bit timer2
//  138                   HAL_TIMER_MODE_CTC,                 // Clear Timer on Compare
//  139                   HAL_TIMER_CHANNEL_SINGLE,           // Channel 1 - default
//  140                   HAL_TIMER_CH_MODE_OUTPUT_COMPARE,   // Output Compare mode
//  141                   OnboardTimerIntEnable,              // Use interrupt
//  142                   Onboard_TimerCallBack);             // Channel Mode
        ; Setup parameters for call to function HalTimerConfig
        MOV     ?V0 + 0,#(??Onboard_TimerCallBack?relay & 0xff)
        MOV     ?V0 + 1,#((??Onboard_TimerCallBack?relay >> 8) & 0xff)
        MOV     R0,#?V0 + 0
        LCALL   ?PUSH_XSTACK_I_TWO
        CFI CFA_XSP16 add(XSP16, 12)
        MOV     R5,#0x0
        MOV     R4,#0x2
        MOV     R3,#0x1
        MOV     R2,#0x2
        MOV     R1,#0x2
        LCALL   ??HalTimerConfig?relay
        MOV     A,#0x2
        LCALL   ?DEALLOC_XSTACK8
        CFI CFA_XSP16 add(XSP16, 10)
        SJMP    ??InitBoard_4
//  143 
//  144   }
//  145   else  // !OB_COLD
//  146   {
//  147 #ifdef ZTOOL_PORT
//  148     MT_IndReset();
??InitBoard_0:
        ; Setup parameters for call to function MT_IndReset
        LCALL   ??MT_IndReset?relay
//  149 #endif
//  150 
//  151      /* Initialize Key stuff */
//  152     OnboardKeyIntEnable = HAL_KEY_INTERRUPT_DISABLE;
        CLR     A
        MOV     DPTR,#OnboardKeyIntEnable
        MOVX    @DPTR,A
//  153     HalKeyConfig( OnboardKeyIntEnable, OnBoard_KeyCallback);
        ; Setup parameters for call to function HalKeyConfig
        MOV     R2,#(??OnBoard_KeyCallback?relay & 0xff)
        MOV     R3,#((??OnBoard_KeyCallback?relay >> 8) & 0xff)
        MOV     R1,A
        LCALL   ??HalKeyConfig?relay
        CFI EndBlock cfiBlock0
//  154   }
//  155 }
??InitBoard_4:
        REQUIRE ?Subroutine0
        REQUIRE _A_IEN0
        REQUIRE SLEEP
        ; // Fall through to label ?Subroutine0

        RSEG BANKED_CODE:CODE:NOROOT(0)
?Subroutine0:
        CFI Block cfiBlock1 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 cfiBlock1
//  156 
//  157 /*********************************************************************
//  158  * @fn      ChkReset()
//  159  * @brief   Check reset bits - if reset cause is unknown, assume a
//  160  *          brown-out (low power), assume batteries are not reliable,
//  161  *          hang in a loop and sequence through the LEDs.
//  162  * @param   None
//  163  * @return  None
//  164  *********************************************************************/
//  165 void ChkReset( void )
//  166 {
//  167   uint8 led;
//  168   uint8 rib;
//  169 
//  170   // Isolate reset indicator bits
//  171   rib = SLEEP & LRESET;
//  172 
//  173   if ( rib == RESETPO )
//  174   {
//  175     // Put code here to handle Power-On reset
//  176   }
//  177   else if ( rib == RESETEX )
//  178   {
//  179     // Put code here to handle External reset
//  180   }
//  181   else if ( rib == RESETWD )
//  182   {
//  183     // Put code here to handle WatchDog reset
//  184   }
//  185   else
//  186   {
//  187     // Unknown, hang and blink
//  188     HAL_DISABLE_INTERRUPTS();
//  189     led = HAL_LED_4;
//  190     while ( 1 ) {
//  191       HalLedSet( led, HAL_LED_MODE_ON );
//  192       MicroWait( 62500 );
//  193       MicroWait( 62500 );
//  194       HalLedSet( led, HAL_LED_MODE_OFF );
//  195       MicroWait( 37500 );
//  196       MicroWait( 37500 );
//  197       if ( !(led >>= 1) )
//  198         led = HAL_LED_4;
//  199     }
//  200   }
//  201 }
//  202 
//  203 /*********************************************************************
//  204  *                        "Keyboard" Support
//  205  *********************************************************************/
//  206 
//  207 /*********************************************************************
//  208  * Keyboard Register function
//  209  *
//  210  * The keyboard handler is setup to send all keyboard changes to
//  211  * one task (if a task is registered).
//  212  *
//  213  * If a task registers, it will get all the keys. You can change this
//  214  * to register for individual keys.
//  215  *********************************************************************/

        RSEG BANKED_CODE:CODE:NOROOT(0)
//  216 byte RegisterForKeys( byte task_id )
RegisterForKeys:
        CFI Block cfiBlock2 Using cfiCommon0
        CFI Function RegisterForKeys
//  217 {
        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
//  218   // Allow only the first task
//  219   if ( registeredKeysTaskID == NO_TASK_ID )
        MOV     DPTR,#registeredKeysTaskID
        MOVX    A,@DPTR
        XRL     A,#0xff
        JNZ     ??RegisterForKeys_0
//  220   {
//  221     registeredKeysTaskID = task_id;
        MOV     A,R1
        MOVX    @DPTR,A
//  222     return ( true );
        MOV     R1,#0x1
        SJMP    ??RegisterForKeys_1
//  223   }
//  224   else
//  225     return ( false );
??RegisterForKeys_0:
        MOV     R1,#0x0
??RegisterForKeys_1:
        LJMP    ?Subroutine1 & 0xFFFF
        CFI EndBlock cfiBlock2
//  226 }
//  227 
//  228 /*********************************************************************
//  229  * @fn      OnBoard_SendKeys
//  230  *
//  231  * @brief   Send "Key Pressed" message to application.
//  232  *
//  233  * @param   keys  - keys that were pressed
//  234  *          state - shifted
//  235  *
//  236  * @return  status
//  237  *********************************************************************/

        RSEG BANKED_CODE:CODE:NOROOT(0)
//  238 byte OnBoard_SendKeys( byte keys, byte state )
OnBoard_SendKeys:
        CFI Block cfiBlock3 Using cfiCommon0
        CFI Function OnBoard_SendKeys
//  239 {
        FUNCALL OnBoard_SendKeys, osal_msg_allocate
        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 OnBoard_SendKeys, osal_msg_send
        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
        MOV     A,R1
        MOV     R6,A
        MOV     A,R2
        MOV     R7,A
//  240   keyChange_t *msgPtr;
//  241 
//  242   if ( registeredKeysTaskID != NO_TASK_ID )
        MOV     DPTR,#registeredKeysTaskID
        MOVX    A,@DPTR
        XRL     A,#0xff
        JZ      ??OnBoard_SendKeys_0
//  243   {
//  244     // Send the address to the task
//  245     msgPtr = (keyChange_t *)osal_msg_allocate( sizeof(keyChange_t) );
        ; Setup parameters for call to function osal_msg_allocate
        MOV     R2,#0x4
        MOV     R3,#0x0
        LCALL   ??osal_msg_allocate?relay
//  246     if ( msgPtr )
        MOV     A,R2
        JNZ     ??OnBoard_SendKeys_1
        MOV     A,R3
??OnBoard_SendKeys_1:
        JZ      ??OnBoard_SendKeys_2
//  247     {
//  248       msgPtr->hdr.event = KEY_CHANGE;
        MOV     A,#-0x40
        MOV     DPL,R2
        MOV     DPH,R3
        MOVX    @DPTR,A
//  249       msgPtr->state = state;
        MOV     A,R7
        INC     DPTR
        INC     DPTR
        MOVX    @DPTR,A
//  250       msgPtr->keys = keys;
        MOV     A,R6
        MOV     DPL,R2
        MOV     DPH,R3
        INC     DPTR
        INC     DPTR
        INC     DPTR
        MOVX    @DPTR,A
//  251 
//  252       osal_msg_send( registeredKeysTaskID, (uint8 *)msgPtr );
        ; Setup parameters for call to function osal_msg_send
        MOV     DPTR,#registeredKeysTaskID
        MOVX    A,@DPTR
        MOV     R1,A
        LCALL   ??osal_msg_send?relay
//  253     }
//  254     return ( ZSuccess );
??OnBoard_SendKeys_2:
        MOV     R1,#0x0
        SJMP    ??OnBoard_SendKeys_3
//  255   }
//  256   else
//  257     return ( ZFailure );
??OnBoard_SendKeys_0:
        MOV     R1,#0x1
??OnBoard_SendKeys_3:
        SJMP    ?Subroutine0
        CFI EndBlock cfiBlock3
//  258 }
//  259 
//  260 /*********************************************************************
//  261  * @fn      OnBoard_KeyCallback
//  262  *
//  263  * @brief   Callback service for keys
//  264  *
//  265  * @param   keys  - keys that were pressed
//  266  *          state - shifted
//  267  *
//  268  * @return  void
//  269  *********************************************************************/

        RSEG BANKED_CODE:CODE:NOROOT(0)
//  270 void OnBoard_KeyCallback ( uint8 keys, uint8 state )
OnBoard_KeyCallback:
        CFI Block cfiBlock4 Using cfiCommon0
        CFI Function OnBoard_KeyCallback
//  271 {
        FUNCALL OnBoard_KeyCallback, OnBoard_SendKeys
        LOCFRAME ISTACK, 2, STACK
        LOCFRAME PSTACK, 0, STACK
        LOCFRAME XSTACK, 0, STACK
        LOCFRAME IOVERLAY, 0, STATIC
        LOCFRAME DOVERLAY, 0, STATIC
        ARGFRAME ISTACK, 2, STACK
        ARGFRAME PSTACK, 0, STACK
        ARGFRAME XSTACK, 0, STACK
        ARGFRAME IOVERLAY, 0, STATIC
        ARGFRAME DOVERLAY, 0, STATIC
        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
//  272   uint8 shift;
//  273 
//  274   // shift key (S1) is used to generate key interrupt
//  275   // applications should not use S1 when key interrupt is enabled
//  276   shift = (OnboardKeyIntEnable == HAL_KEY_INTERRUPT_ENABLE) ? false : ((keys & HAL_KEY_SW_6) ? true : false);
        MOV     DPTR,#OnboardKeyIntEnable
        MOVX    A,@DPTR
        XRL     A,#0x1
        JNZ     ??OnBoard_KeyCallback_0
        MOV     R3,#0x0
        SJMP    ??OnBoard_KeyCallback_1
??OnBoard_KeyCallback_0:
        MOV     A,R1
        MOV     C,0xE0 /* A   */.5
        JNC     ??OnBoard_KeyCallback_2
        SETB    B.0
        SJMP    ??OnBoard_KeyCallback_3
??OnBoard_KeyCallback_2:
        CLR     B.0
??OnBoard_KeyCallback_3:
        MOV     C,B.0
        CLR     A
        MOV     0xE0 /* A   */.0,C
        MOV     R3,A
??OnBoard_KeyCallback_1:
        MOV     A,R3
        MOV     R2,A
//  277 
//  278   if ( OnBoard_SendKeys( keys, shift ) != ZSuccess )
        ; Setup parameters for call to function OnBoard_SendKeys
        LCALL   ??OnBoard_SendKeys?relay
//  279   {
//  280     // Process SW1 here
//  281     if ( keys & HAL_KEY_SW_1 )  // Switch 1
//  282     {
//  283     }
//  284     // Process SW2 here
//  285     if ( keys & HAL_KEY_SW_2 )  // Switch 2
//  286     {
//  287     }
//  288     // Process SW3 here
//  289     if ( keys & HAL_KEY_SW_3 )  // Switch 3
//  290     {
//  291     }
//  292     // Process SW4 here
//  293     if ( keys & HAL_KEY_SW_4 )  // Switch 4
//  294     {
//  295     }
//  296     // Process SW5 here
//  297     if ( keys & HAL_KEY_SW_5 )  // Switch 5
//  298     {
//  299     }
//  300     // Process SW6 here
//  301     if ( keys & HAL_KEY_SW_6 )  // Switch 6
//  302     {
//  303     }
//  304   }
//  305 }
        SJMP    ?Subroutine1
        CFI EndBlock cfiBlock4
//  306 
//  307 /*********************************************************************
//  308  *                    SLEEP MANAGEMENT FUNCTIONS
//  309  *
//  310  * These functions support processing of MAC and ZStack power mode
//  311  * transitions, used when the system goes into or awakes from sleep.
//  312  */
//  313 
//  314  /*********************************************************************
//  315  * @fn      OnBoard_stack_used()
//  316  *
//  317  * @brief
//  318  *
//  319  *   Runs through the stack looking for touched memory.
//  320  *
//  321  * @param   none
//  322  *
//  323  * @return  number of bytes used by the stack
//  324  *********************************************************************/

        RSEG BANKED_CODE:CODE:NOROOT(0)
//  325 uint16 OnBoard_stack_used( void )
OnBoard_stack_used:
        CFI Block cfiBlock5 Using cfiCommon0
        CFI Function OnBoard_stack_used
//  326 {
        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
//  327   byte *pStack = (byte*)MCU_RAM_END;
        MOV     R0,#-0x1
        MOV     R1,#-0x1
//  328   byte *pHold;
//  329   byte found = false;
//  330   byte x;
//  331 
//  332   // Look from the end of RAM for MIN_RAM_INIT number of "pattern" bytes
//  333   // This should be the high water stack mark.
//  334   while ( !found && pStack )
//  335   {
//  336     // Found an init value?
//  337     if ( *pStack == STACK_INIT_VALUE )
??OnBoard_stack_used_0:
        MOV     DPL,R0
        MOV     DPH,R1
        MOVX    A,@DPTR
        XRL     A,#0xcd
        JNZ     ??OnBoard_stack_used_1
//  338     {
//  339       // Look for a bunch in a row
//  340       pHold = pStack;
//  341       for ( x = 0; x < MIN_RAM_INIT; x++ )
        MOV     R2,#0x0
//  342       {
//  343         if ( *pHold != STACK_INIT_VALUE )
??OnBoard_stack_used_2:
        MOVX    A,@DPTR
        XRL     A,#0xcd
        JNZ     ??OnBoard_stack_used_3
//  344           break;
//  345         else
//  346           pHold--;
        MOV     A,DPL
        ADD     A,#-0x1
        MOV     DPL,A
        MOV     A,DPH
        ADDC    A,#-0x1
        MOV     DPH,A
//  347       }
        INC     R2
        MOV     A,R2
        CLR     C
        SUBB    A,#0xc
        JC      ??OnBoard_stack_used_2
//  348       // Did we find the needed minimum number in a row
//  349       if ( x >= MIN_RAM_INIT )
??OnBoard_stack_used_3:
        MOV     A,R2
        CLR     C
        SUBB    A,#0xc
        JNC     ??OnBoard_stack_used_4
//  350         found = true;
//  351     }
//  352     if ( !found )
//  353       pStack--;
??OnBoard_stack_used_1:
        MOV     A,R0
        ADD     A,#-0x1
        DEC     R0
        MOV     A,R1
        ADDC    A,#-0x1
        MOV     R1,A
        MOV     A,R0
        JNZ     ??OnBoard_stack_used_5
        MOV     A,R1
??OnBoard_stack_used_5:
        JNZ     ??OnBoard_stack_used_0
//  354   }
//  355 
//  356   if ( pStack )
//  357     return ( (uint16)((byte*)MCU_RAM_END - pStack) );
//  358   else
//  359     return ( 0 );
        MOV     R2,#0x0
        MOV     R3,#0x0
        SJMP    ??OnBoard_stack_used_6
??OnBoard_stack_used_4:
        MOV     A,#-0x1
        CLR     C
        SUBB    A,R0
        MOV     R2,A
        MOV     A,#-0x1
        SUBB    A,R1
        MOV     R3,A
        CFI EndBlock cfiBlock5
??OnBoard_stack_used_6:
        REQUIRE ?Subroutine1
        ; // Fall through to label ?Subroutine1
//  360 }

        RSEG BANKED_CODE:CODE:NOROOT(0)
?Subroutine1:
        CFI Block cfiBlock6 Using cfiCommon0
        CFI NoFunction
        CFI CFA_SP SP+-5
        CFI DPL0 Frame(CFA_SP, 4)
        CFI DPH0 Frame(CFA_SP, 5)
        POP     DPH
        CFI CFA_SP SP+-4
        CFI DPH0 SameValue
        POP     DPL
        CFI CFA_SP SP+-3
        CFI DPL0 SameValue
        LJMP    ?BRET
        CFI EndBlock cfiBlock6
//  361 
//  362 /*********************************************************************
//  363  * @fn      _itoa
//  364  *
//  365  * @brief   convert a 16bit number to ASCII
//  366  *
//  367  * @param   num -
//  368  *          buf -
//  369  *          radix -
//  370  *
//  371  * @return  void
//  372  *
//  373  *********************************************************************/

        RSEG BANKED_CODE:CODE:NOROOT(0)
//  374 void _itoa(uint16 num, byte *buf, byte radix)
_itoa:
        CFI Block cfiBlock7 Using cfiCommon0
        CFI Function _itoa
//  375 {
        MOV     A,#-0xe
        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 V5 load(1, XDATA, add(CFA_XSP16, literal(-7)))
        CFI V4 load(1, XDATA, add(CFA_XSP16, literal(-8)))
        CFI V3 load(1, XDATA, add(CFA_XSP16, literal(-9)))
        CFI V2 load(1, XDATA, add(CFA_XSP16, literal(-10)))
        CFI V1 load(1, XDATA, add(CFA_XSP16, literal(-11)))
        CFI V0 load(1, XDATA, add(CFA_XSP16, literal(-12)))
        CFI VB load(1, XDATA, add(CFA_XSP16, literal(-13)))
        CFI R6 load(1, XDATA, add(CFA_XSP16, literal(-14)))
        CFI CFA_SP SP+0
        CFI CFA_XSP16 add(XSP16, 14)
        ; Saved register size: 14
        ; Auto size: 5
        MOV     A,#-0x5
        LCALL   ?ALLOC_XSTACK8
        CFI CFA_XSP16 add(XSP16, 19)
        MOV     A,R2
        MOV     R6,A
        MOV     A,R3
        MOV     R7,A
        MOV     ?V0 + 0,R4
        MOV     ?V0 + 1,R5
        MOV     ?V0 + 5,R1
//  376   char c,i;
//  377   byte *p, rst[5];
//  378 
//  379   p = rst;
        MOV     DPL,?XSP + 0
        MOV     DPH,?XSP + 1
        MOV     R4,DPL
        MOV     R5,DPH
//  380   for ( i=0; i<5; i++,p++ )
        MOV     ?V0 + 4,#0x0
//  381   {
//  382     c = num % radix;  // Isolate a digit
??_itoa_0:
        MOV     A,R6
        MOV     R0,A
        MOV     A,R7
        MOV     R1,A
        MOV     A,?V0 + 5
        MOV     ?V0 + 2,A
        MOV     R2,A
        MOV     R3,#0x0
        LCALL   ?US_DIV_MOD
        MOV     A,R2
//  383     *p = c + (( c < 10 ) ? '0' : '7');  // Convert to Ascii
        SUBB    A,#0xa
        JNC     ??_itoa_1
        MOV     R0,#0x30
        SJMP    ??_itoa_2
??_itoa_1:
        MOV     R0,#0x37
??_itoa_2:
        MOV     A,R0
        ADD     A,R2
        MOV     DPL,R4
        MOV     DPH,R5
        MOVX    @DPTR,A
//  384     num /= radix;
        MOV     A,R6
        MOV     R0,A
        MOV     A,R7
        MOV     R1,A
        MOV     R2,?V0 + 2
        MOV     R3,#0x0
        LCALL   ?US_DIV_MOD
        MOV     ?V0 + 2,R0
        MOV     ?V0 + 3,R1
        MOV     R6,?V0 + 2
        MOV     R7,?V0 + 3
//  385     if ( !num )
        MOV     A,R6
        JNZ     ??_itoa_3
        MOV     A,R7
??_itoa_3:
        JZ      ??_itoa_4
//  386       break;
//  387   }
        INC     ?V0 + 4
        INC     DPTR
        MOV     R4,DPL
        MOV     R5,DPH
        MOV     A,?V0 + 4
        SUBB    A,#0x5
        JC      ??_itoa_0
//  388 
//  389   for ( c=0 ; c<=i; c++ )
??_itoa_4:
        MOV     R2,#0x0
//  390     *buf++ = *p--;  // Reverse character order
??_itoa_5:
        MOV     DPL,R4
        MOV     DPH,R5
        MOVX    A,@DPTR
        MOV     DPL,?V0 + 0
        MOV     DPH,?V0 + 1
        MOVX    @DPTR,A
        MOV     A,R4
        ADD     A,#-0x1
        DEC     R4
        MOV     A,R5
        ADDC    A,#-0x1
        MOV     R5,A
        INC     DPTR
        MOV     ?V0 + 0,DPL
        MOV     ?V0 + 1,DPH
        INC     R2
        MOV     A,?V0 + 4
        CLR     C
        SUBB    A,R2
        JNC     ??_itoa_5
//  391 
//  392   *buf = '\0';
        CLR     A
        MOVX    @DPTR,A
//  393 }
        MOV     A,#0x5
        LCALL   ?DEALLOC_XSTACK8
        CFI CFA_XSP16 add(XSP16, 14)
        MOV     R7,#0x6
        LJMP    ?BANKED_LEAVE_XDATA
        CFI EndBlock cfiBlock7
//  394 
//  395 /*********************************************************************
//  396  * @fn        Onboard_rand
//  397  *
//  398  * @brief    Random number generator
//  399  *
//  400  * @param   none
//  401  *
//  402  * @return  uint16 - new random number
//  403  *
//  404  *********************************************************************/

        RSEG BANKED_CODE:CODE:NOROOT(0)
//  405 uint16 Onboard_rand( void )
Onboard_rand:
        CFI Block cfiBlock8 Using cfiCommon0
        CFI Function Onboard_rand
//  406 {
        FUNCALL Onboard_rand, macMcuRandomByte
        LOCFRAME ISTACK, 0, STACK
        LOCFRAME PSTACK, 0, STACK
        LOCFRAME XSTACK, 9, STACK
        LOCFRAME IOVERLAY, 0, STATIC
        LOCFRAME DOVERLAY, 0, STATIC
        ARGFRAME ISTACK, 0, STACK
        ARGFRAME PSTACK, 0, STACK
        ARGFRAME XSTACK, 9, STACK
        ARGFRAME IOVERLAY, 0, STATIC
        ARGFRAME DOVERLAY, 0, STATIC
        FUNCALL Onboard_rand, macMcuRandomByte
        LOCFRAME ISTACK, 0, STACK
        LOCFRAME PSTACK, 0, STACK
        LOCFRAME XSTACK, 9, STACK
        LOCFRAME IOVERLAY, 0, STATIC
        LOCFRAME DOVERLAY, 0, STATIC
        ARGFRAME ISTACK, 0, STACK
        ARGFRAME PSTACK, 0, STACK
        ARGFRAME XSTACK, 9, STACK
        ARGFRAME IOVERLAY, 0, STATIC
        ARGFRAME DOVERLAY, 0, STATIC
        MOV     A,#-0x9
        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 V0 load(1, XDATA, add(CFA_XSP16, literal(-7)))
        CFI VB load(1, XDATA, add(CFA_XSP16, literal(-8)))
        CFI R6 load(1, XDATA, add(CFA_XSP16, literal(-9)))
        CFI CFA_SP SP+0
        CFI CFA_XSP16 add(XSP16, 9)
        ; Saved register size: 9
        ; Auto size: 0
//  407   uint16 randNum;
//  408 
//  409   randNum = macMcuRandomByte();
        ; Setup parameters for call to function macMcuRandomByte
        LCALL   ??macMcuRandomByte?relay
        MOV     A,R1
        MOV     R6,A
//  410   randNum += (macMcuRandomByte() << 8);
        ; Setup parameters for call to function macMcuRandomByte
        LCALL   ??macMcuRandomByte?relay
        MOV     A,R6
        ADD     A,#0x0
        CLR     A
        ADDC    A,R1
        MOV     R7,A
//  411   return ( randNum );
        MOV     A,R6
        MOV     R2,A
        MOV     A,R7
        MOV     R3,A
        MOV     R7,#0x1
        LJMP    ?BANKED_LEAVE_XDATA
        CFI EndBlock cfiBlock8
//  412 }
//  413 
//  414 /*********************************************************************
//  415  * @fn        Onboard_wait
//  416  *
//  417  * @brief    Random number generator
//  418  *
//  419  * @param   uint16 - time to wait
//  420  *
//  421  * @return  none
//  422  *
//  423  *********************************************************************/

        RSEG BANKED_CODE:CODE:NOROOT(0)
//  424 void Onboard_wait( uint16 timeout )
Onboard_wait:
        CFI Block cfiBlock9 Using cfiCommon0
        CFI Function Onboard_wait
//  425 {
        ; Saved register size: 0
        ; Auto size: 0
        SJMP    ??Onboard_wait_0
//  426   while (timeout--)
//  427   {
//  428     asm("NOP");
??Onboard_wait_1:
        NOP
//  429     asm("NOP");
        NOP
//  430     asm("NOP");
        NOP
//  431   }
??Onboard_wait_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     ??Onboard_wait_2
        MOV     A,R1
??Onboard_wait_2:
        JNZ     ??Onboard_wait_1
//  432 }
        LJMP    ?BRET
        CFI EndBlock cfiBlock9
//  433 
//  434 /*********************************************************************
//  435  * @fn      Osal_TimerCallBack()
//  436  *
//  437  * @brief   Update the timer per tick
//  438  *
//  439  * @param   none
//  440  *
//  441  * @return  local clock in milliseconds
//  442  **********************************************************************/

        RSEG BANKED_CODE:CODE:NOROOT(0)
//  443 void Onboard_TimerCallBack ( uint8 timerId, uint8 channel, uint8 channelMode)
Onboard_TimerCallBack:
        CFI Block cfiBlock10 Using cfiCommon0
        CFI Function Onboard_TimerCallBack
//  444 {
        FUNCALL Onboard_TimerCallBack, osal_update_timers
        LOCFRAME ISTACK, 2, STACK
        LOCFRAME PSTACK, 0, STACK
        LOCFRAME XSTACK, 0, STACK
        LOCFRAME IOVERLAY, 0, STATIC
        LOCFRAME DOVERLAY, 0, STATIC
        ARGFRAME ISTACK, 2, STACK
        ARGFRAME PSTACK, 0, STACK
        ARGFRAME XSTACK, 0, STACK
        ARGFRAME IOVERLAY, 0, STATIC
        ARGFRAME DOVERLAY, 0, STATIC
        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
//  445 
//  446   if ((timerId == OSAL_TIMER) && (channelMode == HAL_TIMER_CH_MODE_OUTPUT_COMPARE))
        MOV     A,#0x2
        XRL     A,R1
        JNZ     ??Onboard_TimerCallBack_0
        MOV     A,#0x2
        XRL     A,R3
        JNZ     ??Onboard_TimerCallBack_0
//  447   {
//  448     osal_update_timers();
        ; Setup parameters for call to function osal_update_timers
        LCALL   ??osal_update_timers?relay
//  449   }
//  450 }
??Onboard_TimerCallBack_0:
        LJMP    ?Subroutine1 & 0xFFFF
        CFI EndBlock cfiBlock10
//  451 
//  452 /*********************************************************************
//  453  *                    EXTERNAL I/O FUNCTIONS
//  454  *
//  455  * User defined functions to control external devices. Add your code
//  456  * to the following functions to control devices wired to DB outputs.
//  457  *
//  458  *********************************************************************/
//  459 

        RSEG BANKED_CODE:CODE:NOROOT(0)
//  460 void BigLight_On( void )
BigLight_On:
        CFI Block cfiBlock11 Using cfiCommon0
        CFI Function BigLight_On
//  461 {
        ; Saved register size: 0
        ; Auto size: 0
//  462   // Put code here to turn on an external light
//  463 }
        LJMP    ?BRET
        CFI EndBlock cfiBlock11
//  464 

        RSEG BANKED_CODE:CODE:NOROOT(0)
//  465 void BigLight_Off( void )
BigLight_Off:
        CFI Block cfiBlock12 Using cfiCommon0
        CFI Function BigLight_Off
//  466 {
        ; Saved register size: 0
        ; Auto size: 0
//  467   // Put code here to turn off an external light
//  468 }
        LJMP    ?BRET
        CFI EndBlock cfiBlock12
//  469 

        RSEG BANKED_CODE:CODE:NOROOT(0)
//  470 void BuzzerControl( byte on )
BuzzerControl:
        CFI Block cfiBlock13 Using cfiCommon0
        CFI Function BuzzerControl
//  471 {
        ; Saved register size: 0
        ; Auto size: 0
//  472   // Put code here to turn a buzzer on/off
//  473 }
        LJMP    ?BRET
        CFI EndBlock cfiBlock13
//  474 

        RSEG BANKED_CODE:CODE:NOROOT(0)
//  475 void Dimmer( byte lvl )
Dimmer:
        CFI Block cfiBlock14 Using cfiCommon0
        CFI Function Dimmer
//  476 {
        ; Saved register size: 0
        ; Auto size: 0
//  477   // Put code here to control a dimmer
//  478 }
        LJMP    ?BRET
        CFI EndBlock cfiBlock14
//  479 
//  480 // No dip switches on this board

        RSEG BANKED_CODE:CODE:NOROOT(0)
//  481 byte GetUserDipSw( void )
GetUserDipSw:
        CFI Block cfiBlock15 Using cfiCommon0
        CFI Function GetUserDipSw
//  482 {
        ; Saved register size: 0
        ; Auto size: 0
//  483   return 0;
        MOV     R1,#0x0
        LJMP    ?BRET
        CFI EndBlock cfiBlock15
//  484 }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        END
//  485 
//  486 /*********************************************************************
//  487 *********************************************************************/
// 
// 606 bytes in segment BANKED_CODE
//  84 bytes in segment BANK_RELAYS
//   2 bytes in segment SFR_AN
//   1 byte  in segment XDATA_I
//   1 byte  in segment XDATA_ID
//  10 bytes in segment XDATA_Z
// 
// 691 bytes of CODE  memory
//   0 bytes of DATA  memory (+ 2 bytes shared)
//  11 bytes of XDATA memory
//
//Errors: none
//Warnings: none
