///////////////////////////////////////////////////////////////////////////////
//                                                                            /
// IAR 8051 C/C++ Compiler V7.30B/W32                   13/May/2010  22:05:38 /
// 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\Samples\Location\Source\LocDongle.c        /
//    Command line       =  -f "C:\Texas Instruments\ZStack-1.4.3-1.2.1\Proje /
//                          cts\zstack\Samples\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\Samples\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\Samples\Location\Source\LocDongle.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\Sa /
//                          mples\Location\CC2430DB\LocDongle\List\" -lA      /
//                          "C:\Texas Instruments\ZStack-1.4.3-1.2.1\Projects /
//                          \zstack\Samples\Location\CC2430DB\LocDongle\List\ /
//                          " --diag_suppress Pe001,Pa010 --diag_remark       /
//                          pe550 -o "C:\Texas Instruments\ZStack-1.4.3-1.2.1 /
//                          \Projects\zstack\Samples\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\Samples\Location\CC2430DB\" -I       /
//                          "C:\Texas Instruments\ZStack-1.4.3-1.2.1\Projects /
//                          \zstack\Samples\Location\CC2430DB\..\SOURCE\" -I  /
//                          "C:\Texas Instruments\ZStack-1.4.3-1.2.1\Projects /
//                          \zstack\Samples\Location\CC2430DB\..\..\..\ZMAIN\ /
//                          TI2430DB\" -I "C:\Texas                           /
//                          Instruments\ZStack-1.4.3-1.2.1\Projects\zstack\Sa /
//                          mples\Location\CC2430DB\..\..\..\..\WXL\INCLUDE\" /
//                           -I "C:\Texas Instruments\ZStack-1.4.3-1.2.1\Proj /
//                          ects\zstack\Samples\Location\CC2430DB\..\..\..\.. /
//                          \..\COMPONENTS\MT\" -I "C:\Texas                  /
//                          Instruments\ZStack-1.4.3-1.2.1\Projects\zstack\Sa /
//                          mples\Location\CC2430DB\..\..\..\..\..\COMPONENTS /
//                          \HAL\INCLUDE\" -I "C:\Texas                       /
//                          Instruments\ZStack-1.4.3-1.2.1\Projects\zstack\Sa /
//                          mples\Location\CC2430DB\..\..\..\..\..\COMPONENTS /
//                          \HAL\TARGET\CC2430EB\" -I "C:\Texas               /
//                          Instruments\ZStack-1.4.3-1.2.1\Projects\zstack\Sa /
//                          mples\Location\CC2430DB\..\..\..\..\..\COMPONENTS /
//                          \OSAL\MCU\CCSOC\" -I "C:\Texas                    /
//                          Instruments\ZStack-1.4.3-1.2.1\Projects\zstack\Sa /
//                          mples\Location\CC2430DB\..\..\..\..\..\COMPONENTS /
//                          \OSAL\INCLUDE\" -I "C:\Texas                      /
//                          Instruments\ZStack-1.4.3-1.2.1\Projects\zstack\Sa /
//                          mples\Location\CC2430DB\..\..\..\..\..\COMPONENTS /
//                          \STACK\AF\" -I "C:\Texas                          /
//                          Instruments\ZStack-1.4.3-1.2.1\Projects\zstack\Sa /
//                          mples\Location\CC2430DB\..\..\..\..\..\COMPONENTS /
//                          \STACK\NWK\" -I "C:\Texas                         /
//                          Instruments\ZStack-1.4.3-1.2.1\Projects\zstack\Sa /
//                          mples\Location\CC2430DB\..\..\..\..\..\COMPONENTS /
//                          \STACK\SEC\" -I "C:\Texas                         /
//                          Instruments\ZStack-1.4.3-1.2.1\Projects\zstack\Sa /
//                          mples\Location\CC2430DB\..\..\..\..\..\COMPONENTS /
//                          \STACK\SYS\" -I "C:\Texas                         /
//                          Instruments\ZStack-1.4.3-1.2.1\Projects\zstack\Sa /
//                          mples\Location\CC2430DB\..\..\..\..\..\COMPONENTS /
//                          \STACK\ZDO\" -I "C:\Texas                         /
//                          Instruments\ZStack-1.4.3-1.2.1\Projects\zstack\Sa /
//                          mples\Location\CC2430DB\..\..\..\..\..\COMPONENTS /
//                          \ZMAC\F8W\" -I "C:\Texas                          /
//                          Instruments\ZStack-1.4.3-1.2.1\Projects\zstack\Sa /
//                          mples\Location\CC2430DB\..\..\..\..\..\COMPONENTS /
//                          \ZMAC\" -I "C:\Texas Instruments\ZStack-1.4.3-1.2 /
//                          .1\Projects\zstack\Samples\Location\CC2430DB\..\. /
//                          .\..\..\..\COMPONENTS\SERVICES\SADDR\" -I         /
//                          "C:\Texas Instruments\ZStack-1.4.3-1.2.1\Projects /
//                          \zstack\Samples\Location\CC2430DB\..\..\..\..\..\ /
//                          COMPONENTS\SERVICES\SDATA\" -I "C:\Texas          /
//                          Instruments\ZStack-1.4.3-1.2.1\Projects\zstack\Sa /
//                          mples\Location\CC2430DB\..\..\..\..\..\COMPONENTS /
//                          \MAC\INCLUDE\" -I "C:\Texas                       /
//                          Instruments\ZStack-1.4.3-1.2.1\Projects\zstack\Sa /
//                          mples\Location\CC2430DB\..\..\..\..\..\COMPONENTS /
//                          \MAC\HIGH_LEVEL\" -I "C:\Texas                    /
//                          Instruments\ZStack-1.4.3-1.2.1\Projects\zstack\Sa /
//                          mples\Location\CC2430DB\..\..\..\..\..\COMPONENTS /
//                          \MAC\LOW_LEVEL\SRF03\" -I "C:\Texas               /
//                          Instruments\ZStack-1.4.3-1.2.1\Projects\zstack\Sa /
//                          mples\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\Samples\Location\CC2430DB\LocDongle\List\L /
//                          ocDongle.s51                                      /
//                                                                            /
//                                                                            /
///////////////////////////////////////////////////////////////////////////////

        NAME LocDongle

        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 ??LocDongle_MTMsg?relay
        EXTERN ??LocDongle_ProcessMSGCmd?relay
        EXTERN ?ALLOC_XSTACK8
        EXTERN ?BANKED_ENTER_XDATA
        EXTERN ?BANKED_LEAVE_XDATA
        EXTERN ?BDISPATCH
        EXTERN ?BRET
        EXTERN ?DEALLOC_XSTACK8
        EXTERN ?PUSH_XSTACK_I_ONE
        EXTERN ?PUSH_XSTACK_I_TWO
        EXTERN ?UC_SWITCH_SPARSE
        EXTERN ?V0
        EXTERN ?XSP
        EXTERN ?XSTACK_DISP0_8
        EXTERN __INIT_XDATA_I
        EXTERN __INIT_XDATA_Z

        PUBLIC ??LocDongle_Init?relay
        FUNCTION ??LocDongle_Init?relay,0203H
        FUNCTION ??LocDongle_MTMsg?relay,0203H
        PUBLIC ??LocDongle_ProcessEvent?relay
        FUNCTION ??LocDongle_ProcessEvent?relay,0203H
        FUNCTION ??LocDongle_ProcessMSGCmd?relay,0203H
        PUBLIC ??LocationHandleKeys?relay
        FUNCTION ??LocationHandleKeys?relay,0203H
        PUBLIC LocDongle_Init
        FUNCTION LocDongle_Init,021203H
        ARGFRAME XSTACK, 0, STACK
        LOCFRAME ISTACK, 2, STACK
        FUNCTION LocDongle_MTMsg,021203H
        ARGFRAME XSTACK, 12, STACK
        ARGFRAME IOVERLAY, 0, STATIC
        ARGFRAME DOVERLAY, 0, STATIC
        LOCFRAME ISTACK, 1, STACK
        LOCFRAME XSTACK, 27, STACK
        PUBLIC LocDongle_ProcessEvent
        FUNCTION LocDongle_ProcessEvent,0a1203H
        ARGFRAME XSTACK, 0, STACK
        LOCFRAME XSTACK, 12, STACK
        FUNCTION LocDongle_ProcessMSGCmd,021203H
        ARGFRAME XSTACK, 12, STACK
        ARGFRAME IOVERLAY, 0, STATIC
        ARGFRAME DOVERLAY, 0, STATIC
        LOCFRAME ISTACK, 1, STACK
        LOCFRAME XSTACK, 24, STACK
        PUBLIC LocDongle_TaskID
        PUBLIC LocDongle_TransID
        PUBLIC LocationHandleKeys
        FUNCTION LocationHandleKeys,0203H
        ARGFRAME XSTACK, 0, STACK
        
        CFI Names cfiNames0
        CFI StackFrame CFA_SP SP DATA
        CFI StackFrame CFA_PSP16 PSP16 XDATA
        CFI StackFrame CFA_XSP16 XSP16 XDATA
        CFI StaticOverlayFrame CFA_IOVERLAY IOVERLAY
        CFI StaticOverlayFrame CFA_DOVERLAY DOVERLAY
        CFI Resource `PSW.CY`:1, `B.BR0`:1, `B.BR1`:1, `B.BR2`:1, `B.BR3`:1
        CFI Resource `B.BR4`:1, `B.BR5`:1, `B.BR6`:1, `B.BR7`:1, `VB.BR8`:1
        CFI Resource `VB.BR9`:1, `VB.BR10`:1, `VB.BR11`:1, `VB.BR12`:1
        CFI Resource `VB.BR13`:1, `VB.BR14`:1, `VB.BR15`:1, VB:8, B:8, A:8
        CFI Resource PSW:8, DPL0:8, DPH0:8, R0:8, R1:8, R2:8, R3:8, R4:8, R5:8
        CFI Resource R6:8, R7:8, V0:8, V1:8, V2:8, V3:8, V4:8, V5:8, V6:8, V7:8
        CFI Resource SP:8, PSPH:8, PSPL:8, PSP16:16, XSPH:8, XSPL:8, XSP16:16
        CFI VirtualResource ?RET:24
        CFI Resource ?BRET_EXT:8
        CFI VirtualResource ?RET_HIGH:8, ?RET_LOW:8
        CFI ResourceParts PSP16 PSPH, PSPL
        CFI ResourceParts XSP16 XSPH, XSPL
        CFI ResourceParts ?RET ?BRET_EXT, ?RET_HIGH, ?RET_LOW
        CFI EndNames cfiNames0
        
        CFI Common cfiCommon0 Using cfiNames0
        CFI CodeAlign 1
        CFI DataAlign -1
        CFI ReturnAddress ?RET CODE
        CFI CFA_DOVERLAY Used
        CFI CFA_IOVERLAY Used
        CFI CFA_SP SP+-3
        CFI CFA_PSP16 PSP16+0
        CFI CFA_XSP16 XSP16+0
        CFI `PSW.CY` SameValue
        CFI `B.BR0` SameValue
        CFI `B.BR1` SameValue
        CFI `B.BR2` SameValue
        CFI `B.BR3` SameValue
        CFI `B.BR4` SameValue
        CFI `B.BR5` SameValue
        CFI `B.BR6` SameValue
        CFI `B.BR7` SameValue
        CFI `VB.BR8` SameValue
        CFI `VB.BR9` SameValue
        CFI `VB.BR10` SameValue
        CFI `VB.BR11` SameValue
        CFI `VB.BR12` SameValue
        CFI `VB.BR13` SameValue
        CFI `VB.BR14` SameValue
        CFI `VB.BR15` SameValue
        CFI VB SameValue
        CFI B Undefined
        CFI A Undefined
        CFI PSW SameValue
        CFI DPL0 SameValue
        CFI DPH0 SameValue
        CFI R0 Undefined
        CFI R1 Undefined
        CFI R2 Undefined
        CFI R3 Undefined
        CFI R4 Undefined
        CFI R5 Undefined
        CFI R6 SameValue
        CFI R7 SameValue
        CFI V0 SameValue
        CFI V1 SameValue
        CFI V2 SameValue
        CFI V3 SameValue
        CFI V4 SameValue
        CFI V5 SameValue
        CFI V6 SameValue
        CFI V7 SameValue
        CFI PSPH Undefined
        CFI PSPL Undefined
        CFI XSPH Undefined
        CFI XSPL Undefined
        CFI ?RET Concat
        CFI ?BRET_EXT Frame(CFA_SP, 3)
        CFI ?RET_HIGH Frame(CFA_SP, 2)
        CFI ?RET_LOW Frame(CFA_SP, 1)
        CFI EndCommon cfiCommon0
        
        
        CFI Common cfiCommon1 Using cfiNames0
        CFI CodeAlign 1
        CFI DataAlign -1
        CFI ReturnAddress ?RET CODE
        CFI CFA_DOVERLAY Used
        CFI CFA_IOVERLAY Used
        CFI CFA_SP SP+-2
        CFI CFA_PSP16 PSP16+0
        CFI CFA_XSP16 XSP16+0
        CFI `PSW.CY` SameValue
        CFI `B.BR0` SameValue
        CFI `B.BR1` SameValue
        CFI `B.BR2` SameValue
        CFI `B.BR3` SameValue
        CFI `B.BR4` SameValue
        CFI `B.BR5` SameValue
        CFI `B.BR6` SameValue
        CFI `B.BR7` SameValue
        CFI `VB.BR8` SameValue
        CFI `VB.BR9` SameValue
        CFI `VB.BR10` SameValue
        CFI `VB.BR11` SameValue
        CFI `VB.BR12` SameValue
        CFI `VB.BR13` SameValue
        CFI `VB.BR14` SameValue
        CFI `VB.BR15` SameValue
        CFI VB SameValue
        CFI B SameValue
        CFI A SameValue
        CFI PSW SameValue
        CFI DPL0 SameValue
        CFI DPH0 SameValue
        CFI R0 SameValue
        CFI R1 SameValue
        CFI R2 SameValue
        CFI R3 SameValue
        CFI R4 SameValue
        CFI R5 SameValue
        CFI R6 SameValue
        CFI R7 SameValue
        CFI V0 SameValue
        CFI V1 SameValue
        CFI V2 SameValue
        CFI V3 SameValue
        CFI V4 SameValue
        CFI V5 SameValue
        CFI V6 SameValue
        CFI V7 SameValue
        CFI PSPH Undefined
        CFI PSPL Undefined
        CFI XSPH Undefined
        CFI XSPL Undefined
        CFI ?RET Concat
        CFI ?BRET_EXT SameValue
        CFI ?RET_HIGH Frame(CFA_SP, 2)
        CFI ?RET_LOW Frame(CFA_SP, 1)
        CFI EndCommon cfiCommon1
        
afRegister          SYMBOL "afRegister"
osal_msg_receive    SYMBOL "osal_msg_receive"
osal_msg_deallocate SYMBOL "osal_msg_deallocate"
HalUARTWrite        SYMBOL "HalUARTWrite"
SPIMgr_CalcFCS      SYMBOL "SPIMgr_CalcFCS"
AF_DataRequest      SYMBOL "AF_DataRequest"
??AF_DataRequest?relay SYMBOL "?relay", AF_DataRequest
??HalUARTWrite?relay SYMBOL "?relay", HalUARTWrite
??SPIMgr_CalcFCS?relay SYMBOL "?relay", SPIMgr_CalcFCS
??afRegister?relay  SYMBOL "?relay", afRegister
??osal_msg_deallocate?relay SYMBOL "?relay", osal_msg_deallocate
??osal_msg_receive?relay SYMBOL "?relay", osal_msg_receive
LocDongle_Init      SYMBOL "LocDongle_Init"
??LocDongle_Init?relay SYMBOL "?relay", LocDongle_Init
LocDongle_ProcessEvent SYMBOL "LocDongle_ProcessEvent"
??LocDongle_ProcessEvent?relay SYMBOL "?relay", LocDongle_ProcessEvent
LocationHandleKeys  SYMBOL "LocationHandleKeys"
??LocationHandleKeys?relay SYMBOL "?relay", LocationHandleKeys

        EXTERN afRegister
        FUNCTION afRegister,0202H
        ARGFRAME ISTACK, 2, STACK
        ARGFRAME PSTACK, 0, STACK
        ARGFRAME XSTACK, 0, STACK
        ARGFRAME IOVERLAY, 0, STATIC
        ARGFRAME DOVERLAY, 0, STATIC
        EXTERN osal_msg_receive
        FUNCTION osal_msg_receive,0202H
        ARGFRAME ISTACK, 0, STACK
        ARGFRAME PSTACK, 0, STACK
        ARGFRAME XSTACK, 12, STACK
        ARGFRAME IOVERLAY, 0, STATIC
        ARGFRAME DOVERLAY, 0, STATIC
        EXTERN osal_msg_deallocate
        FUNCTION osal_msg_deallocate,0202H
        ARGFRAME ISTACK, 0, STACK
        ARGFRAME PSTACK, 0, STACK
        ARGFRAME XSTACK, 12, STACK
        ARGFRAME IOVERLAY, 0, STATIC
        ARGFRAME DOVERLAY, 0, STATIC
        EXTERN HalUARTWrite
        FUNCTION HalUARTWrite,0202H
        ARGFRAME ISTACK, 0, STACK
        ARGFRAME PSTACK, 0, STACK
        ARGFRAME XSTACK, 24, STACK
        ARGFRAME IOVERLAY, 0, STATIC
        ARGFRAME DOVERLAY, 0, STATIC
        EXTERN SPIMgr_CalcFCS
        FUNCTION SPIMgr_CalcFCS,0202H
        ARGFRAME ISTACK, 0, STACK
        ARGFRAME PSTACK, 0, STACK
        ARGFRAME XSTACK, 24, STACK
        ARGFRAME IOVERLAY, 0, STATIC
        ARGFRAME DOVERLAY, 0, STATIC
        EXTERN AF_DataRequest
        FUNCTION AF_DataRequest,0202H
        ARGFRAME ISTACK, 0, STACK
        ARGFRAME PSTACK, 0, STACK
        ARGFRAME XSTACK, 27, STACK
        ARGFRAME IOVERLAY, 0, STATIC
        ARGFRAME DOVERLAY, 0, STATIC
        EXTERN ??AF_DataRequest?relay
        FUNCTION ??AF_DataRequest?relay,00H
        EXTERN ??HalUARTWrite?relay
        FUNCTION ??HalUARTWrite?relay,00H
        EXTERN ??SPIMgr_CalcFCS?relay
        FUNCTION ??SPIMgr_CalcFCS?relay,00H
        EXTERN ??afRegister?relay
        FUNCTION ??afRegister?relay,00H
        EXTERN ??osal_msg_deallocate?relay
        FUNCTION ??osal_msg_deallocate?relay,00H
        EXTERN ??osal_msg_receive?relay
        FUNCTION ??osal_msg_receive?relay,00H

// C:\Texas Instruments\ZStack-1.4.3-1.2.1\Projects\zstack\Samples\Location\Source\LocDongle.c
//    1 /**************************************************************************************************
//    2   Filename:       LocDongle.c
//    3   Revised:        $Date: 2007-10-27 17:16:54 -0700 (Sat, 27 Oct 2007) $
//    4   Revision:       $Revision: 15793 $
//    5 
//    6   Description:    This application resides in a dongle and enables a PC GUI or
//    7                   other application to send and recieve OTA location messages.
//    8 
//    9 
//   10   Copyright 2007 Texas Instruments Incorporated. All rights reserved.
//   11 
//   12   IMPORTANT: Your use of this Software is limited to those specific rights
//   13   granted under the terms of a software license agreement between the user
//   14   who downloaded the software, his/her employer (which must be your employer)
//   15   and Texas Instruments Incorporated (the "License").  You may not use this
//   16   Software unless you agree to abide by the terms of the License. The License
//   17   limits your use, and you acknowledge, that the Software may not be modified,
//   18   copied or distributed unless embedded on a Texas Instruments microcontroller
//   19   or used solely and exclusively in conjunction with a Texas Instruments radio
//   20   frequency transceiver, which is integrated into your product.  Other than for
//   21   the foregoing purpose, you may not use, reproduce, copy, prepare derivative
//   22   works of, modify, distribute, perform, display or sell this Software and/or
//   23   its documentation for any purpose.
//   24 
//   25   YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
//   26   PROVIDED “AS IS?WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
//   27   INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
//   28   NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
//   29   TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
//   30   NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
//   31   LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
//   32   INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
//   33   OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
//   34   OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
//   35   (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
//   36 
//   37   Should you have any questions regarding your right to use this Software,
//   38   contact Texas Instruments Incorporated at www.TI.com.
//   39 **************************************************************************************************/
//   40 
//   41 /*********************************************************************
//   42  * INCLUDES
//   43  */
//   44 #include "OSAL.h"
//   45 #include "MTEL.h"
//   46 #include "AF.h"
//   47 #include "ZDApp.h"
//   48 
//   49 #include "OnBoard.h"
//   50 #include "hal_key.h"
//   51 #if defined ( LCD_SUPPORTED )
//   52 #include "hal_lcd.h"
//   53 #endif
//   54 
//   55 #include "LocationProfile.h"
//   56 #include "LocDongle.h"
//   57 
//   58 #if !defined ( MT_TASK )
//   59   #error      // No need for this module if MT_TASK isn't defined
//   60 #endif
//   61 
//   62 /*********************************************************************
//   63  * MACROS
//   64  */
//   65 
//   66 /*********************************************************************
//   67  * CONSTANTS
//   68  */
//   69 
//   70 //#define ZBIT  //ggg
//   71  // #define DONGLE_TIMER_EVT  0x0001
//   72 
//   73 #define LOCDONGLE_TX_OPTIONS          AF_MSG_ACK_REQUEST
//   74 
//   75 #if defined ( ZBIT )
//   76   #define DONGLE_TIMER_DLY  1000
//   77 #endif
//   78 
//   79 

        RSEG XDATA_I:XDATA:NOROOT(0)
        DATA
//   80 static const cId_t LocDongle_InputClusterList[] =
LocDongle_InputClusterList:
        DS 8
        REQUIRE `?<Initializer for LocDongle_InputClusterList>`
        REQUIRE __INIT_XDATA_I
//   81 {
//   82   LOCATION_XY_RSSI_RESPONSE,
//   83   LOCATION_BLINDNODE_FIND_RESPONSE,
//   84   LOCATION_BLINDNODE_CONFIG,
//   85   LOCATION_REFNODE_CONFIG
//   86 };
//   87 

        RSEG XDATA_I:XDATA:NOROOT(0)
        DATA
//   88 static const cId_t LocDongle_OutputClusterList[] =
LocDongle_OutputClusterList:
        DS 12
        REQUIRE `?<Initializer for LocDongle_OutputClusterList>`
        REQUIRE __INIT_XDATA_I
//   89 {
//   90   LOCATION_XY_RSSI_REQUEST,
//   91   LOCATION_BLINDNODE_FIND_REQUEST,
//   92   LOCATION_REFNODE_CONFIG,
//   93   LOCATION_BLINDNODE_CONFIG,
//   94   LOCATION_REFNODE_REQUEST_CONFIG,
//   95   LOCATION_BLINDNODE_REQUEST_CONFIG
//   96 };
//   97 

        RSEG XDATA_I:XDATA:NOROOT(0)
        DATA
//   98 static const SimpleDescriptionFormat_t LocDongle_SimpleDesc =
LocDongle_SimpleDesc:
        DS 12
        REQUIRE `?<Initializer for LocDongle_SimpleDesc>`
        REQUIRE __INIT_XDATA_I
//   99 {
//  100   LOCATION_DONGLE_ENDPOINT,
//  101   LOCATION_PROFID,
//  102 
//  103   LOCATION_DONGLE_DEVICEID,
//  104 
//  105   LOCATION_DEVICE_VERSION,
//  106   LOCATION_FLAGS,
//  107 
//  108   sizeof(LocDongle_InputClusterList),
//  109   (cId_t *)LocDongle_InputClusterList,
//  110 
//  111   sizeof(LocDongle_OutputClusterList),
//  112   (cId_t *)LocDongle_OutputClusterList
//  113 };
//  114 

        RSEG XDATA_I:XDATA:NOROOT(0)
        DATA
//  115 static const endPointDesc_t epDesc =
epDesc:
        DS 6
        REQUIRE `?<Initializer for epDesc>`
        REQUIRE __INIT_XDATA_I
//  116 {
//  117   LOCATION_DONGLE_ENDPOINT,
//  118   &LocDongle_TaskID,
//  119   (SimpleDescriptionFormat_t *)&LocDongle_SimpleDesc,
//  120   noLatencyReqs
//  121 };
//  122 
//  123 /*********************************************************************
//  124  * TYPEDEFS
//  125  */
//  126 
//  127 #if defined ( ZBIT )
//  128   typedef struct
//  129   {
//  130     uint16 addr;
//  131     uint8  ep;
//  132   } Node_t;
//  133 #endif
//  134 
//  135 /*********************************************************************
//  136  * GLOBAL VARIABLES
//  137  */
//  138 

        RSEG XDATA_Z:XDATA:NOROOT(0)
//  139 uint8 LocDongle_TaskID;
LocDongle_TaskID:
        DS 1
        REQUIRE __INIT_XDATA_Z
//  140 
//  141 /*********************************************************************
//  142  * LOCAL VARIABLES
//  143  */
//  144 

        RSEG XDATA_Z:XDATA:NOROOT(0)
//  145 uint8 LocDongle_TransID;  // This is the unique message ID (counter)
LocDongle_TransID:
        DS 1
        REQUIRE __INIT_XDATA_Z
//  146 
//  147 #if defined ( ZBIT )
//  148   static Node_t blindNodes[1];
//  149 #endif
//  150 
//  151 /*********************************************************************
//  152  * LOCAL FUNCTIONS
//  153  */
//  154 
//  155 static void LocDongle_ProcessMSGCmd( afIncomingMSGPacket_t *pckt );
//  156 static void LocDongle_MTMsg( uint8 len, uint8 *msg );
//  157 
//  158 #if defined ( ZBIT )
//  159   static void processTimerEvt( void );
//  160 #endif
//  161 
//  162 /*********************************************************************
//  163  * @fn      LocDongle_Init
//  164  *
//  165  * @brief   Initialization function for the Generic App Task.
//  166  *          This is called during initialization and should contain
//  167  *          any application specific initialization (ie. hardware
//  168  *          initialization/setup, table initialization, power up
//  169  *          notificaiton ... ).
//  170  *
//  171  * @param   task_id - the ID assigned by OSAL.  This ID should be
//  172  *                    used to send messages and set timers.
//  173  *
//  174  * @return  none
//  175  */

        RSEG BANKED_CODE:CODE:NOROOT(0)
//  176 void LocDongle_Init( uint8 task_id )
LocDongle_Init:
        CFI Block cfiBlock0 Using cfiCommon0
        CFI Function LocDongle_Init
//  177 {
        FUNCALL LocDongle_Init, afRegister
        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
//  178   LocDongle_TaskID = task_id;
        MOV     A,R1
        MOV     DPTR,#LocDongle_TaskID
        MOVX    @DPTR,A
//  179   LocDongle_TransID = 0;
        CLR     A
        MOV     DPTR,#LocDongle_TransID
        MOVX    @DPTR,A
//  180 
//  181   // Register the endpoint/interface description with the AF
//  182   afRegister( (endPointDesc_t *)&epDesc );
        ; Setup parameters for call to function afRegister
        MOV     R2,#(epDesc & 0xff)
        MOV     R3,#((epDesc >> 8) & 0xff)
        LCALL   ??afRegister?relay
//  183 
//  184   // Register for all key events - This app will handle all key events
//  185   // RegisterForKeys( LocDongle_TaskID );
//  186 
//  187   // Update the display
//  188 #if defined ( LCD_SUPPORTED )
//  189   //HalLcdWriteString( "Location-Dongle", HAL_LCD_LINE_2 );
//  190    Print8(HAL_LCD_LINE_2,0,"                ",1) ;
//  191    Print8(HAL_LCD_LINE_2,0,"Location-Dongle",1) ;
//  192 #endif
//  193 }
        POP     DPH
        CFI DPH0 SameValue
        CFI CFA_SP SP+-4
        POP     DPL
        CFI DPL0 SameValue
        CFI CFA_SP SP+-3
        LJMP    ?BRET
        CFI EndBlock cfiBlock0
//  194 
//  195 /*********************************************************************
//  196  * @fn      LocDongle_ProcessEvent
//  197  *
//  198  * @brief   Generic Application Task event processor.  This function
//  199  *          is called to process all events for the task.  Events
//  200  *          include timers, messages and any other user defined events.
//  201  *
//  202  * @param   task_id  - The OSAL assigned task ID.
//  203  * @param   events - events to process.  This is a bit map and can
//  204  *                   contain more than one event.
//  205  *
//  206  * @return  none
//  207  */

        RSEG BANKED_CODE:CODE:NOROOT(0)
//  208 UINT16 LocDongle_ProcessEvent( uint8 task_id, UINT16 events )
LocDongle_ProcessEvent:
        CFI Block cfiBlock1 Using cfiCommon0
        CFI Function LocDongle_ProcessEvent
//  209 {
        FUNCALL LocDongle_ProcessEvent, osal_msg_receive
        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 LocDongle_ProcessEvent, LocDongle_ProcessMSGCmd
        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 LocDongle_ProcessEvent, osal_msg_deallocate
        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 LocDongle_ProcessEvent, osal_msg_receive
        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 LocDongle_ProcessEvent, LocDongle_MTMsg
        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
        MOV     A,#-0xc
        LCALL   ?BANKED_ENTER_XDATA
        CFI DPH0 load(1, XDATA, add(CFA_XSP16, literal(-1)))
        CFI DPL0 load(1, XDATA, add(CFA_XSP16, literal(-2)))
        CFI ?BRET_EXT load(1, XDATA, add(CFA_XSP16, literal(-3)))
        CFI ?RET_HIGH load(1, XDATA, add(CFA_XSP16, literal(-4)))
        CFI ?RET_LOW load(1, XDATA, add(CFA_XSP16, literal(-5)))
        CFI R7 load(1, XDATA, add(CFA_XSP16, literal(-6)))
        CFI V3 load(1, XDATA, add(CFA_XSP16, literal(-7)))
        CFI V2 load(1, XDATA, add(CFA_XSP16, literal(-8)))
        CFI V1 load(1, XDATA, add(CFA_XSP16, literal(-9)))
        CFI V0 load(1, XDATA, add(CFA_XSP16, literal(-10)))
        CFI VB load(1, XDATA, add(CFA_XSP16, literal(-11)))
        CFI R6 load(1, XDATA, add(CFA_XSP16, literal(-12)))
        CFI CFA_SP SP+0
        CFI CFA_XSP16 add(XSP16, 12)
        ; Saved register size: 12
        ; Auto size: 0
        MOV     ?V0 + 0,R2
        MOV     ?V0 + 1,R3
//  210   afIncomingMSGPacket_t *MSGpkt;
//  211 
//  212   if ( events & SYS_EVENT_MSG )
        MOV     A,#-0x80
        ANL     A,?V0 + 1
        MOV     R1,A
        CLR     A
        JNZ     ??LocDongle_ProcessEvent_0
        MOV     A,R1
??LocDongle_ProcessEvent_0:
        JZ      ??LocDongle_ProcessEvent_1
//  213   {
//  214     MSGpkt = (afIncomingMSGPacket_t *)osal_msg_receive( LocDongle_TaskID );
        ; Setup parameters for call to function osal_msg_receive
        SJMP    ??LocDongle_ProcessEvent_2
//  215     while ( MSGpkt )
//  216     {
//  217       switch ( MSGpkt->hdr.event )
//  218       {
//  219       case MT_SYS_APP_MSG:  // Z-Architect Messages
//  220           LocDongle_MTMsg( ((mtSysAppMsg_t *)MSGpkt)->appDataLen, ((mtSysAppMsg_t *)MSGpkt)->appData );
//  221           break;
//  222 
//  223         case KEY_CHANGE:
//  224           //keyChange( ((keyChange_t *)MSGpkt)->state, ((keyChange_t *)MSGpkt)->keys );
//  225           break;
//  226 
//  227         case AF_INCOMING_MSG_CMD:
//  228           LocDongle_ProcessMSGCmd( MSGpkt );
??LocDongle_ProcessEvent_3:
        ; Setup parameters for call to function LocDongle_ProcessMSGCmd
        MOV     A,R6
        MOV     R2,A
        MOV     A,R7
        MOV     R3,A
        LCALL   ??LocDongle_ProcessMSGCmd?relay
//  229           break;
//  230 
//  231         default:
//  232           break;
//  233       }
//  234 
//  235       osal_msg_deallocate( (uint8 *)MSGpkt );
??LocDongle_ProcessEvent_4:
        ; Setup parameters for call to function osal_msg_deallocate
        MOV     A,R6
        MOV     R2,A
        MOV     A,R7
        MOV     R3,A
        LCALL   ??osal_msg_deallocate?relay
//  236       MSGpkt = (afIncomingMSGPacket_t *)osal_msg_receive( LocDongle_TaskID );
        ; Setup parameters for call to function osal_msg_receive
??LocDongle_ProcessEvent_2:
        MOV     DPTR,#LocDongle_TaskID
        MOVX    A,@DPTR
        MOV     R1,A
        LCALL   ??osal_msg_receive?relay
        MOV     ?V0 + 2,R2
        MOV     ?V0 + 3,R3
        MOV     R6,?V0 + 2
        MOV     R7,?V0 + 3
        MOV     A,R6
        JNZ     ??LocDongle_ProcessEvent_5
        MOV     A,R7
??LocDongle_ProcessEvent_5:
        JZ      ??LocDongle_ProcessEvent_6
        MOV     DPL,R6
        MOV     DPH,R7
        MOVX    A,@DPTR
        LCALL   ?UC_SWITCH_SPARSE
`?<Jumptable for LocDongle_ProcessEvent>_0`:
        DATA
        DB        0
        DB        2
        DB        26
        DW        ??LocDongle_ProcessEvent_3
        DB        35
        DW        ??LocDongle_ProcessEvent_7
        DW        ??LocDongle_ProcessEvent_4
        CODE
??LocDongle_ProcessEvent_7:
        ; Setup parameters for call to function LocDongle_MTMsg
        MOV     DPL,R6
        MOV     DPH,R7
        INC     DPTR
        INC     DPTR
        INC     DPTR
        INC     DPTR
        MOVX    A,@DPTR
        MOV     R2,A
        INC     DPTR
        MOVX    A,@DPTR
        MOV     R3,A
        MOV     DPL,R6
        MOV     DPH,R7
        INC     DPTR
        INC     DPTR
        INC     DPTR
        MOVX    A,@DPTR
        MOV     R1,A
        LCALL   ??LocDongle_MTMsg?relay
        SJMP    ??LocDongle_ProcessEvent_4
//  237     }
//  238 
//  239     // Return unprocessed events
//  240     return ( events ^ SYS_EVENT_MSG );
??LocDongle_ProcessEvent_6:
        MOV     R2,?V0 + 0
        MOV     A,#-0x80
        XRL     A,?V0 + 1
        MOV     R3,A
        SJMP    ??LocDongle_ProcessEvent_8
//  241   }
//  242 
//  243 #if defined ( ZBIT )
//  244   if ( events & DONGLE_TIMER_EVT )
//  245   {
//  246     processTimerEvt();
//  247 
//  248     // Return unprocessed events.
//  249     return ( events ^ DONGLE_TIMER_EVT );
//  250   }
//  251 #endif
//  252 
//  253   // Discard unknown events
//  254   return 0;
??LocDongle_ProcessEvent_1:
        MOV     R2,#0x0
        MOV     R3,#0x0
??LocDongle_ProcessEvent_8:
        MOV     R7,#0x4
        LJMP    ?BANKED_LEAVE_XDATA
        CFI EndBlock cfiBlock1
//  255 }
//  256 
//  257 /*********************************************************************
//  258  * Event Generation Functions
//  259  */
//  260 /*********************************************************************
//  261  * @fn      keyChange
//  262  *
//  263  * @brief   Handles all key events for this device.
//  264  *
//  265  * @param   keys - bit field for key events. Valid entries:
//  266  *                 EVAL_SW4
//  267  *                 EVAL_SW3
//  268  *                 EVAL_SW2
//  269  *                 EVAL_SW1
//  270  *
//  271  * @return  none
//  272  */

        RSEG BANKED_CODE:CODE:NOROOT(0)
//  273 void LocationHandleKeys( uint8 keys )
LocationHandleKeys:
        CFI Block cfiBlock2 Using cfiCommon0
        CFI Function LocationHandleKeys
//  274 {
        ; Saved register size: 0
        ; Auto size: 0
//  275   if ( keys & HAL_KEY_SW_1 )
//  276   {
//  277 #if defined ( ZBIT )
//  278     osal_start_timerEx(LocDongle_TaskID, DONGLE_TIMER_EVT, DONGLE_TIMER_DLY);
//  279 #endif
//  280   }
//  281 
//  282   if ( keys & HAL_KEY_SW_2 )
//  283   {
//  284   }
//  285 
//  286   if ( keys & HAL_KEY_SW_3 )
//  287   {
//  288   }
//  289 
//  290   if ( keys & HAL_KEY_SW_4 )
//  291   {
//  292   }
//  293 }
        LJMP    ?BRET
        CFI EndBlock cfiBlock2
//  294 
//  295 /*********************************************************************
//  296  * @fn      LocDongle_ProcessMSGCmd
//  297  *
//  298  * @brief   All incoming messages are sent out the serial port
//  299  *          as an MT SYS_APP_MSG.
//  300  *
//  301  * @param   Raw incoming MSG packet structure pointer.
//  302  *
//  303  * @return  none
//  304  */

        RSEG BANKED_CODE:CODE:NOROOT(0)
//  305 static void LocDongle_ProcessMSGCmd( afIncomingMSGPacket_t *pkt )
LocDongle_ProcessMSGCmd:
        CFI Block cfiBlock3 Using cfiCommon0
        CFI Function LocDongle_ProcessMSGCmd
//  306 {
        FUNCALL LocDongle_ProcessMSGCmd, HalUARTWrite
        LOCFRAME ISTACK, 0, STACK
        LOCFRAME PSTACK, 0, STACK
        LOCFRAME XSTACK, 24, STACK
        LOCFRAME IOVERLAY, 0, STATIC
        LOCFRAME DOVERLAY, 0, STATIC
        ARGFRAME ISTACK, 0, STACK
        ARGFRAME PSTACK, 0, STACK
        ARGFRAME XSTACK, 24, STACK
        ARGFRAME IOVERLAY, 0, STATIC
        ARGFRAME DOVERLAY, 0, STATIC
        FUNCALL LocDongle_ProcessMSGCmd, HalUARTWrite
        LOCFRAME ISTACK, 0, STACK
        LOCFRAME PSTACK, 0, STACK
        LOCFRAME XSTACK, 24, STACK
        LOCFRAME IOVERLAY, 0, STATIC
        LOCFRAME DOVERLAY, 0, STATIC
        ARGFRAME ISTACK, 0, STACK
        ARGFRAME PSTACK, 0, STACK
        ARGFRAME XSTACK, 24, STACK
        ARGFRAME IOVERLAY, 0, STATIC
        ARGFRAME DOVERLAY, 0, STATIC
        FUNCALL LocDongle_ProcessMSGCmd, SPIMgr_CalcFCS
        LOCFRAME ISTACK, 0, STACK
        LOCFRAME PSTACK, 0, STACK
        LOCFRAME XSTACK, 24, STACK
        LOCFRAME IOVERLAY, 0, STATIC
        LOCFRAME DOVERLAY, 0, STATIC
        ARGFRAME ISTACK, 0, STACK
        ARGFRAME PSTACK, 0, STACK
        ARGFRAME XSTACK, 24, STACK
        ARGFRAME IOVERLAY, 0, STATIC
        ARGFRAME DOVERLAY, 0, STATIC
        FUNCALL LocDongle_ProcessMSGCmd, SPIMgr_CalcFCS
        LOCFRAME ISTACK, 0, STACK
        LOCFRAME PSTACK, 0, STACK
        LOCFRAME XSTACK, 24, STACK
        LOCFRAME IOVERLAY, 0, STATIC
        LOCFRAME DOVERLAY, 0, STATIC
        ARGFRAME ISTACK, 0, STACK
        ARGFRAME PSTACK, 0, STACK
        ARGFRAME XSTACK, 24, STACK
        ARGFRAME IOVERLAY, 0, STATIC
        ARGFRAME DOVERLAY, 0, STATIC
        FUNCALL LocDongle_ProcessMSGCmd, HalUARTWrite
        LOCFRAME ISTACK, 0, STACK
        LOCFRAME PSTACK, 0, STACK
        LOCFRAME XSTACK, 24, STACK
        LOCFRAME IOVERLAY, 0, STATIC
        LOCFRAME DOVERLAY, 0, STATIC
        ARGFRAME ISTACK, 0, STACK
        ARGFRAME PSTACK, 0, STACK
        ARGFRAME XSTACK, 24, 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: 14
        MOV     A,#-0xe
        LCALL   ?ALLOC_XSTACK8
        CFI CFA_XSP16 add(XSP16, 24)
        MOV     A,R2
        MOV     R6,A
        MOV     A,R3
        MOV     R7,A
//  307 #if defined ( ZBIT )
//  308   switch ( pkt->clusterId )
//  309   {
//  310     case LOCATION_BLINDNODE_RESPONSE:
//  311     case LOCATION_BLINDNODE_CONFIG:
//  312       blindNodes[0].addr = pkt->srcAddr.addr.shortAddr;
//  313       blindNodes[0].ep = pkt->srcAddr.endPoint;
//  314       break;
//  315 
//  316     default:
//  317       break;
//  318   }
//  319 #else
//  320   #include "SPIMgr.h"
//  321   // All incoming messages are sent out the serial port as a SYS_APP_MSG.
//  322   uint16 cmd = SPI_RESPONSE_BIT | SPI_CMD_SYS_APP_MSG;
        MOV     DPL,?XSP + 0
        MOV     DPH,?XSP + 1
        MOV     A,#0x18
        MOVX    @DPTR,A
        INC     DPTR
        MOV     A,#0x10
        MOVX    @DPTR,A
//  323   // DstEP + SrcAddr + SrcEP + cId + len = 1+2+1+2+1
//  324   uint8 buf[SPI_0DATA_MSG_LEN + 7];
//  325   uint8 *pBuf = buf;
//  326   uint8 succ = FALSE;
//  327 
//  328   *pBuf++ = SOP_VALUE;
        MOV     A,#0x2
        LCALL   ?XSTACK_DISP0_8
        MOV     A,#0x2
        MOVX    @DPTR,A
//  329   *pBuf++ = (uint8)(HI_UINT16( cmd ));
        MOV     A,#0x3
        LCALL   ?XSTACK_DISP0_8
        MOV     A,#0x10
        MOVX    @DPTR,A
//  330   *pBuf++ = (uint8)(LO_UINT16( cmd ));
        MOV     A,#0x4
        LCALL   ?XSTACK_DISP0_8
        MOV     A,#0x18
        MOVX    @DPTR,A
//  331   *pBuf++ = pkt->cmd.DataLength + 7;
        MOV     A,R6
        ADD     A,#0x13
        MOV     R0,A
        MOV     A,R7
        ADDC    A,#0x0
        MOV     R1,A
        MOV     DPL,R0
        MOV     DPH,R1
        MOVX    A,@DPTR
        ADD     A,#0x7
        PUSH    A
        CFI CFA_SP SP+-1
        MOV     A,#0x5
        LCALL   ?XSTACK_DISP0_8
        POP     A
        CFI CFA_SP SP+0
        MOVX    @DPTR,A
//  332 
//  333   *pBuf++ = LOCATION_DONGLE_ENDPOINT;
        MOV     A,#0x6
        LCALL   ?XSTACK_DISP0_8
        MOV     A,#-0x35
        MOVX    @DPTR,A
//  334   *pBuf++ = LO_UINT16( pkt->srcAddr.addr.shortAddr );
        MOV     A,R6
        ADD     A,#0x6
        MOV     R2,A
        LCALL   ?Subroutine2 & 0xFFFF
??CrossCallReturnLabel_4:
        PUSH    A
        CFI CFA_SP SP+-1
        MOV     A,#0x7
        LCALL   ?XSTACK_DISP0_8
        POP     A
        CFI CFA_SP SP+0
        MOVX    @DPTR,A
//  335   *pBuf++ = HI_UINT16( pkt->srcAddr.addr.shortAddr );
        MOV     DPL,R2
        MOV     DPH,R3
        INC     DPTR
        MOVX    A,@DPTR
        PUSH    A
        CFI CFA_SP SP+-1
        MOV     A,#0x8
        LCALL   ?XSTACK_DISP0_8
        POP     A
        CFI CFA_SP SP+0
        MOVX    @DPTR,A
//  336   *pBuf++ = pkt->srcAddr.endPoint;
        MOV     DPL,R6
        MOV     DPH,R7
        INC     DPTR
        INC     DPTR
        INC     DPTR
        INC     DPTR
        INC     DPTR
        INC     DPTR
        INC     DPTR
        INC     DPTR
        INC     DPTR
        MOVX    A,@DPTR
        PUSH    A
        CFI CFA_SP SP+-1
        MOV     A,#0x9
        LCALL   ?XSTACK_DISP0_8
        POP     A
        CFI CFA_SP SP+0
        MOVX    @DPTR,A
//  337   *pBuf++ = LO_UINT16( pkt->clusterId );
        MOV     A,R6
        ADD     A,#0x4
        DEC     R2
        DEC     R2
        LCALL   ?Subroutine2 & 0xFFFF
??CrossCallReturnLabel_5:
        PUSH    A
        CFI CFA_SP SP+-1
        MOV     A,#0xa
        LCALL   ?XSTACK_DISP0_8
        POP     A
        CFI CFA_SP SP+0
        MOVX    @DPTR,A
//  338   *pBuf++ = HI_UINT16( pkt->clusterId );
        MOV     DPL,R2
        MOV     DPH,R3
        INC     DPTR
        MOVX    A,@DPTR
        PUSH    A
        CFI CFA_SP SP+-1
        MOV     A,#0xb
        LCALL   ?XSTACK_DISP0_8
        POP     A
        CFI CFA_SP SP+0
        MOVX    @DPTR,A
//  339   *pBuf++ = pkt->cmd.DataLength;
        MOV     DPL,R0
        MOV     DPH,R1
        MOVX    A,@DPTR
        PUSH    A
        CFI CFA_SP SP+-1
        MOV     A,#0xc
        LCALL   ?XSTACK_DISP0_8
        POP     A
        CFI CFA_SP SP+0
        MOVX    @DPTR,A
//  340 
//  341   //(void)HalUARTWrite( SPI_MGR_DEFAULT_PORT, buf, 11 );
//  342   if ( HalUARTWrite( SPI_MGR_DEFAULT_PORT, buf, 11 ) )
        ; Setup parameters for call to function HalUARTWrite
        MOV     R4,#0xb
        MOV     R5,#0x0
        MOV     A,#0x2
        LCALL   ?XSTACK_DISP0_8
        MOV     R2,DPL
        MOV     R3,DPH
        MOV     R1,#0x0
        LCALL   ??HalUARTWrite?relay
        MOV     A,R2
        JNZ     ??LocDongle_ProcessMSGCmd_0
        MOV     A,R3
??LocDongle_ProcessMSGCmd_0:
        JZ      ??LocDongle_ProcessMSGCmd_1
//  343   {
//  344     //(void)HalUARTWrite( SPI_MGR_DEFAULT_PORT, pkt->cmd.Data, pkt->cmd.DataLength);
//  345     if ( HalUARTWrite( SPI_MGR_DEFAULT_PORT, pkt->cmd.Data, pkt->cmd.DataLength) )
        ; Setup parameters for call to function HalUARTWrite
        LCALL   ?Subroutine1 & 0xFFFF
??CrossCallReturnLabel_2:
        MOV     R4,A
        INC     DPTR
        MOVX    A,@DPTR
        MOV     R5,A
        LCALL   ?Subroutine0 & 0xFFFF
??CrossCallReturnLabel_0:
        MOV     R1,#0x0
        LCALL   ??HalUARTWrite?relay
        MOV     A,R2
        JNZ     ??LocDongle_ProcessMSGCmd_2
        MOV     A,R3
??LocDongle_ProcessMSGCmd_2:
        JZ      ??LocDongle_ProcessMSGCmd_1
//  346     {
//  347       cmd = SPIMgr_CalcFCS( buf+1, 10 ) ^
//  348             SPIMgr_CalcFCS( pkt->cmd.Data, pkt->cmd.DataLength );
        ; Setup parameters for call to function SPIMgr_CalcFCS
        MOV     R1,#0xa
        MOV     A,#0x3
        LCALL   ?XSTACK_DISP0_8
        MOV     R2,DPL
        MOV     R3,DPH
        LCALL   ??SPIMgr_CalcFCS?relay
        MOV     A,R1
        MOV     ?V0 + 0,A
        ; Setup parameters for call to function SPIMgr_CalcFCS
        LCALL   ?Subroutine1 & 0xFFFF
??CrossCallReturnLabel_3:
        MOV     R1,A
        LCALL   ?Subroutine0 & 0xFFFF
??CrossCallReturnLabel_1:
        LCALL   ??SPIMgr_CalcFCS?relay
        MOV     A,R1
        XRL     A,?V0 + 0
        MOV     R1,#0x0
        MOV     DPL,?XSP + 0
        MOV     DPH,?XSP + 1
        MOVX    @DPTR,A
        INC     DPTR
        CLR     A
        MOVX    @DPTR,A
//  349       //(void)HalUARTWrite( SPI_MGR_DEFAULT_PORT, (uint8 *)(&cmd), 1 );
//  350       if ( HalUARTWrite( SPI_MGR_DEFAULT_PORT, (uint8 *)(&cmd), 1 ) )
        ; Setup parameters for call to function HalUARTWrite
        MOV     R4,#0x1
        MOV     R5,A
        MOV     DPL,?XSP + 0
        MOV     DPH,?XSP + 1
        MOV     R2,DPL
        MOV     R3,DPH
        LCALL   ??HalUARTWrite?relay
//  351       {
//  352         succ = TRUE;
//  353       }
//  354     }
//  355   }
//  356 #endif
//  357 }
??LocDongle_ProcessMSGCmd_1:
        MOV     A,#0xe
        LCALL   ?DEALLOC_XSTACK8
        CFI CFA_XSP16 add(XSP16, 10)
        MOV     R7,#0x2
        LJMP    ?BANKED_LEAVE_XDATA
        CFI EndBlock cfiBlock3

        RSEG BANKED_CODE:CODE:NOROOT(0)
?Subroutine2:
        CFI Block cfiCond4 Using cfiCommon0
        CFI NoFunction
        CFI Conditional ??CrossCallReturnLabel_4
        CFI R6 load(1, XDATA, add(CFA_XSP16, literal(-10)))
        CFI VB load(1, XDATA, add(CFA_XSP16, literal(-9)))
        CFI V0 load(1, XDATA, add(CFA_XSP16, literal(-8)))
        CFI V1 load(1, XDATA, add(CFA_XSP16, literal(-7)))
        CFI R7 load(1, XDATA, add(CFA_XSP16, literal(-6)))
        CFI ?RET_LOW load(1, XDATA, add(CFA_XSP16, literal(-5)))
        CFI ?RET_HIGH load(1, XDATA, add(CFA_XSP16, literal(-4)))
        CFI ?BRET_EXT load(1, XDATA, add(CFA_XSP16, literal(-3)))
        CFI DPL0 load(1, XDATA, add(CFA_XSP16, literal(-2)))
        CFI DPH0 load(1, XDATA, add(CFA_XSP16, literal(-1)))
        CFI CFA_SP SP+0
        CFI CFA_XSP16 add(XSP16, 24)
        CFI Block cfiCond5 Using cfiCommon0
        CFI (cfiCond5) NoFunction
        CFI (cfiCond5) Conditional ??CrossCallReturnLabel_5
        CFI (cfiCond5) R6 load(1, XDATA, add(CFA_XSP16, literal(-10)))
        CFI (cfiCond5) VB load(1, XDATA, add(CFA_XSP16, literal(-9)))
        CFI (cfiCond5) V0 load(1, XDATA, add(CFA_XSP16, literal(-8)))
        CFI (cfiCond5) V1 load(1, XDATA, add(CFA_XSP16, literal(-7)))
        CFI (cfiCond5) R7 load(1, XDATA, add(CFA_XSP16, literal(-6)))
        CFI (cfiCond5) ?RET_LOW load(1, XDATA, add(CFA_XSP16, literal(-5)))
        CFI (cfiCond5) ?RET_HIGH load(1, XDATA, add(CFA_XSP16, literal(-4)))
        CFI (cfiCond5) ?BRET_EXT load(1, XDATA, add(CFA_XSP16, literal(-3)))
        CFI (cfiCond5) DPL0 load(1, XDATA, add(CFA_XSP16, literal(-2)))
        CFI (cfiCond5) DPH0 load(1, XDATA, add(CFA_XSP16, literal(-1)))
        CFI (cfiCond5) CFA_SP SP+0
        CFI (cfiCond5) CFA_XSP16 add(XSP16, 24)
        CFI Block cfiPicker6 Using cfiCommon1
        CFI (cfiPicker6) NoFunction
        CFI (cfiPicker6) Picker
        MOV     A,R7
        ADDC    A,#0x0
        MOV     R3,A
        MOV     DPL,R2
        MOV     DPH,R3
        MOVX    A,@DPTR
        RET
        CFI EndBlock cfiCond4
        CFI EndBlock cfiCond5
        CFI EndBlock cfiPicker6

        RSEG BANKED_CODE:CODE:NOROOT(0)
?Subroutine1:
        CFI Block cfiCond7 Using cfiCommon0
        CFI NoFunction
        CFI Conditional ??CrossCallReturnLabel_2
        CFI R6 load(1, XDATA, add(CFA_XSP16, literal(-10)))
        CFI VB load(1, XDATA, add(CFA_XSP16, literal(-9)))
        CFI V0 load(1, XDATA, add(CFA_XSP16, literal(-8)))
        CFI V1 load(1, XDATA, add(CFA_XSP16, literal(-7)))
        CFI R7 load(1, XDATA, add(CFA_XSP16, literal(-6)))
        CFI ?RET_LOW load(1, XDATA, add(CFA_XSP16, literal(-5)))
        CFI ?RET_HIGH load(1, XDATA, add(CFA_XSP16, literal(-4)))
        CFI ?BRET_EXT load(1, XDATA, add(CFA_XSP16, literal(-3)))
        CFI DPL0 load(1, XDATA, add(CFA_XSP16, literal(-2)))
        CFI DPH0 load(1, XDATA, add(CFA_XSP16, literal(-1)))
        CFI CFA_SP SP+0
        CFI CFA_XSP16 add(XSP16, 24)
        CFI Block cfiCond8 Using cfiCommon0
        CFI (cfiCond8) NoFunction
        CFI (cfiCond8) Conditional ??CrossCallReturnLabel_3
        CFI (cfiCond8) R6 load(1, XDATA, add(CFA_XSP16, literal(-10)))
        CFI (cfiCond8) VB load(1, XDATA, add(CFA_XSP16, literal(-9)))
        CFI (cfiCond8) V0 load(1, XDATA, add(CFA_XSP16, literal(-8)))
        CFI (cfiCond8) V1 load(1, XDATA, add(CFA_XSP16, literal(-7)))
        CFI (cfiCond8) R7 load(1, XDATA, add(CFA_XSP16, literal(-6)))
        CFI (cfiCond8) ?RET_LOW load(1, XDATA, add(CFA_XSP16, literal(-5)))
        CFI (cfiCond8) ?RET_HIGH load(1, XDATA, add(CFA_XSP16, literal(-4)))
        CFI (cfiCond8) ?BRET_EXT load(1, XDATA, add(CFA_XSP16, literal(-3)))
        CFI (cfiCond8) DPL0 load(1, XDATA, add(CFA_XSP16, literal(-2)))
        CFI (cfiCond8) DPH0 load(1, XDATA, add(CFA_XSP16, literal(-1)))
        CFI (cfiCond8) CFA_SP SP+0
        CFI (cfiCond8) CFA_XSP16 add(XSP16, 24)
        CFI Block cfiPicker9 Using cfiCommon1
        CFI (cfiPicker9) NoFunction
        CFI (cfiPicker9) Picker
        MOV     A,R6
        ADD     A,#0x13
        MOV     DPL,A
        MOV     A,R7
        ADDC    A,#0x0
        MOV     DPH,A
        MOVX    A,@DPTR
        RET
        CFI EndBlock cfiCond7
        CFI EndBlock cfiCond8
        CFI EndBlock cfiPicker9

        RSEG BANKED_CODE:CODE:NOROOT(0)
?Subroutine0:
        CFI Block cfiCond10 Using cfiCommon0
        CFI NoFunction
        CFI Conditional ??CrossCallReturnLabel_0
        CFI R6 load(1, XDATA, add(CFA_XSP16, literal(-10)))
        CFI VB load(1, XDATA, add(CFA_XSP16, literal(-9)))
        CFI V0 load(1, XDATA, add(CFA_XSP16, literal(-8)))
        CFI V1 load(1, XDATA, add(CFA_XSP16, literal(-7)))
        CFI R7 load(1, XDATA, add(CFA_XSP16, literal(-6)))
        CFI ?RET_LOW load(1, XDATA, add(CFA_XSP16, literal(-5)))
        CFI ?RET_HIGH load(1, XDATA, add(CFA_XSP16, literal(-4)))
        CFI ?BRET_EXT load(1, XDATA, add(CFA_XSP16, literal(-3)))
        CFI DPL0 load(1, XDATA, add(CFA_XSP16, literal(-2)))
        CFI DPH0 load(1, XDATA, add(CFA_XSP16, literal(-1)))
        CFI CFA_SP SP+0
        CFI CFA_XSP16 add(XSP16, 24)
        CFI Block cfiCond11 Using cfiCommon0
        CFI (cfiCond11) NoFunction
        CFI (cfiCond11) Conditional ??CrossCallReturnLabel_1
        CFI (cfiCond11) R6 load(1, XDATA, add(CFA_XSP16, literal(-10)))
        CFI (cfiCond11) VB load(1, XDATA, add(CFA_XSP16, literal(-9)))
        CFI (cfiCond11) V0 load(1, XDATA, add(CFA_XSP16, literal(-8)))
        CFI (cfiCond11) V1 load(1, XDATA, add(CFA_XSP16, literal(-7)))
        CFI (cfiCond11) R7 load(1, XDATA, add(CFA_XSP16, literal(-6)))
        CFI (cfiCond11) ?RET_LOW load(1, XDATA, add(CFA_XSP16, literal(-5)))
        CFI (cfiCond11) ?RET_HIGH load(1, XDATA, add(CFA_XSP16, literal(-4)))
        CFI (cfiCond11) ?BRET_EXT load(1, XDATA, add(CFA_XSP16, literal(-3)))
        CFI (cfiCond11) DPL0 load(1, XDATA, add(CFA_XSP16, literal(-2)))
        CFI (cfiCond11) DPH0 load(1, XDATA, add(CFA_XSP16, literal(-1)))
        CFI (cfiCond11) CFA_SP SP+0
        CFI (cfiCond11) CFA_XSP16 add(XSP16, 24)
        CFI Block cfiPicker12 Using cfiCommon1
        CFI (cfiPicker12) NoFunction
        CFI (cfiPicker12) Picker
        MOV     A,R6
        ADD     A,#0x15
        MOV     DPL,A
        MOV     A,R7
        ADDC    A,#0x0
        MOV     DPH,A
        MOVX    A,@DPTR
        MOV     R2,A
        INC     DPTR
        MOVX    A,@DPTR
        MOV     R3,A
        RET
        CFI EndBlock cfiCond10
        CFI EndBlock cfiCond11
        CFI EndBlock cfiPicker12
//  358 
//  359 /*********************************************************************
//  360  * @fn      LocDongle_MTMsg
//  361  *
//  362  * @brief   Process Monitor and Test messages
//  363  *
//  364  * @param   len - number of bytes
//  365  * @param   msg - pointer to message
//  366  *          0 - Lo byte destination address
//  367  *          1 - Hi byte destination address
//  368  *          2 - endpoint
//  369  *          3 - lo byte cluster ID
//  370  *          4 - hi byte cluster ID
//  371  *          5 - data length
//  372  *          6 - first byte of data
//  373  *
//  374  * @return  none
//  375  */

        RSEG BANKED_CODE:CODE:NOROOT(0)
//  376 static void LocDongle_MTMsg( uint8 len, uint8 *msg )
LocDongle_MTMsg:
        CFI Block cfiBlock13 Using cfiCommon0
        CFI Function LocDongle_MTMsg
//  377 {
        FUNCALL LocDongle_MTMsg, AF_DataRequest
        LOCFRAME ISTACK, 0, STACK
        LOCFRAME PSTACK, 0, STACK
        LOCFRAME XSTACK, 27, STACK
        LOCFRAME IOVERLAY, 0, STATIC
        LOCFRAME DOVERLAY, 0, STATIC
        ARGFRAME ISTACK, 0, STACK
        ARGFRAME PSTACK, 0, STACK
        ARGFRAME XSTACK, 27, STACK
        ARGFRAME IOVERLAY, 0, STATIC
        ARGFRAME DOVERLAY, 0, STATIC
        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: 4
        MOV     A,#-0x4
        LCALL   ?ALLOC_XSTACK8
        CFI CFA_XSP16 add(XSP16, 18)
        MOV     ?V0 + 0,R2
//  378   afAddrType_t dstAddr;
//  379   cId_t clusterID;
//  380   uint8 dataLen;
//  381 
//  382   dstAddr.addrMode = afAddr16Bit;
        MOV     A,#0x2
        LCALL   ?XSTACK_DISP0_8
        MOV     A,#0x2
        MOVX    @DPTR,A
//  383   dstAddr.addr.shortAddr = BUILD_UINT16( msg[0], msg[1] );
        MOV     DPL,R2
        MOV     DPH,R3
        MOVX    A,@DPTR
        MOV     R2,A
        INC     DPTR
        MOVX    A,@DPTR
        MOV     R1,A
        MOV     A,R2
        MOV     DPL,?XSP + 0
        MOV     DPH,?XSP + 1
        MOVX    @DPTR,A
        INC     DPTR
        MOV     A,R1
        MOVX    @DPTR,A
//  384   msg += 2;
        MOV     A,?V0 + 0
        ADD     A,#0x2
        MOV     ?V0 + 0,A
        MOV     A,R3
        ADDC    A,#0x0
        MOV     ?V0 + 1,A
//  385   dstAddr.endPoint = *msg++;
        MOV     DPL,?V0 + 0
        MOV     DPH,A
        MOVX    A,@DPTR
        PUSH    A
        CFI CFA_SP SP+-1
        MOV     A,#0x3
        LCALL   ?XSTACK_DISP0_8
        POP     A
        CFI CFA_SP SP+0
        MOVX    @DPTR,A
        MOV     DPL,?V0 + 0
        MOV     DPH,?V0 + 1
        INC     DPTR
        MOV     ?V0 + 0,DPL
        MOV     ?V0 + 1,DPH
//  386   clusterID = BUILD_UINT16( msg[0], msg[1] );
        MOVX    A,@DPTR
        MOV     R2,A
        INC     DPTR
        MOVX    A,@DPTR
        MOV     R1,A
        MOV     A,R2
        MOV     ?V0 + 2,A
        MOV     A,R1
        MOV     ?V0 + 3,A
//  387   msg += 2;
        MOV     A,?V0 + 0
        ADD     A,#0x2
        MOV     ?V0 + 0,A
        MOV     A,?V0 + 1
        ADDC    A,#0x0
//  388   dataLen = *msg++;
        MOV     DPL,?V0 + 0
        MOV     DPH,A
        MOVX    A,@DPTR
        MOV     R2,A
        INC     DPTR
        MOV     ?V0 + 0,DPL
        MOV     ?V0 + 1,DPH
//  389 
//  390   if ( (clusterID == LOCATION_XY_RSSI_REQUEST) ||
//  391        (clusterID == LOCATION_REFNODE_CONFIG)  ||
//  392        (clusterID == LOCATION_REFNODE_REQUEST_CONFIG) )
        MOV     A,#0x11
        XRL     A,?V0 + 2
        JNZ     ??LocDongle_MTMsg_0
        MOV     A,R1
??LocDongle_MTMsg_0:
        JZ      ??LocDongle_MTMsg_1
        MOV     A,#0x15
        XRL     A,?V0 + 2
        JNZ     ??LocDongle_MTMsg_2
        MOV     A,R1
??LocDongle_MTMsg_2:
        JZ      ??LocDongle_MTMsg_1
        MOV     A,#0x17
        XRL     A,?V0 + 2
        JNZ     ??LocDongle_MTMsg_3
        MOV     A,R1
??LocDongle_MTMsg_3:
        JNZ     ??LocDongle_MTMsg_4
//  393   {
//  394     dstAddr.endPoint = LOCATION_REFNODE_ENDPOINT;
??LocDongle_MTMsg_1:
        MOV     A,#0x3
        LCALL   ?XSTACK_DISP0_8
        MOV     A,#-0x2e
        SJMP    ??LocDongle_MTMsg_5
//  395   }
//  396   else
//  397   {
//  398     dstAddr.endPoint = LOCATION_BLINDNODE_ENDPOINT;
??LocDongle_MTMsg_4:
        MOV     A,#0x3
        LCALL   ?XSTACK_DISP0_8
        MOV     A,#-0x2d
??LocDongle_MTMsg_5:
        MOVX    @DPTR,A
//  399   }
//  400 
//  401   (void)AF_DataRequest( &dstAddr, (endPointDesc_t*)&epDesc, clusterID,
//  402                          dataLen, msg,
//  403                         &LocDongle_TransID, 0, AF_DEFAULT_RADIUS );
        ; Setup parameters for call to function AF_DataRequest
        MOV     ?V0 + 4,#0xa
        MOV     R0,#?V0 + 4
        LCALL   ?PUSH_XSTACK_I_ONE
        CFI CFA_XSP16 add(XSP16, 19)
        MOV     ?V0 + 4,#(LocDongle_TransID & 0xff)
        MOV     ?V0 + 5,#((LocDongle_TransID >> 8) & 0xff)
        MOV     R0,#?V0 + 4
        LCALL   ?PUSH_XSTACK_I_TWO
        CFI CFA_XSP16 add(XSP16, 21)
        MOV     R0,#?V0 + 0
        LCALL   ?PUSH_XSTACK_I_TWO
        CFI CFA_XSP16 add(XSP16, 23)
        MOV     ?V0 + 0,R2
        MOV     ?V0 + 1,#0x0
        MOV     R0,#?V0 + 0
        LCALL   ?PUSH_XSTACK_I_TWO
        CFI CFA_XSP16 add(XSP16, 25)
        MOV     R0,#?V0 + 2
        LCALL   ?PUSH_XSTACK_I_TWO
        CFI CFA_XSP16 add(XSP16, 27)
        MOV     R1,#0x0
        MOV     R4,#(epDesc & 0xff)
        MOV     R5,#((epDesc >> 8) & 0xff)
        MOV     A,#0x9
        LCALL   ?XSTACK_DISP0_8
        MOV     R2,DPL
        MOV     R3,DPH
        LCALL   ??AF_DataRequest?relay
        MOV     A,#0x9
        LCALL   ?DEALLOC_XSTACK8
        CFI CFA_XSP16 add(XSP16, 18)
//  404 }
        MOV     A,#0x4
        LCALL   ?DEALLOC_XSTACK8
        CFI CFA_XSP16 add(XSP16, 14)
        MOV     R7,#0x6
        LJMP    ?BANKED_LEAVE_XDATA
        CFI EndBlock cfiBlock13

        RSEG XDATA_ID:CODE:NOROOT(0)
        DATA
`?<Initializer for LocDongle_InputClusterList>`:
        DW 18, 20, 22, 21

        RSEG XDATA_ID:CODE:NOROOT(0)
        DATA
`?<Initializer for LocDongle_OutputClusterList>`:
        DW 17, 19, 21, 22, 23, 24

        RSEG XDATA_ID:CODE:NOROOT(0)
        DATA
`?<Initializer for LocDongle_SimpleDesc>`:
        DB 203
        DW 49155, 18
        DB 0, 8
        DW LocDongle_InputClusterList
        DB 12
        DW LocDongle_OutputClusterList

        RSEG XDATA_ID:CODE:NOROOT(0)
        DATA
`?<Initializer for epDesc>`:
        DB 203
        DW LocDongle_TaskID, LocDongle_SimpleDesc
        DB 0

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

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

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

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

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

        END
//  405 
//  406 #if defined ( ZBIT )
//  407 /*********************************************************************
//  408  * @fn      processTimerEvt
//  409  *
//  410  * @brief   Process the timer event to simulate OTA traffic normally driven by
//  411  *          the Location PC App.
//  412  *
//  413  * @param   none
//  414  *
//  415  * @return  none
//  416  */
//  417 static void processTimerEvt( void )
//  418 {
//  419   static uint8 state = 0;
//  420 
//  421   const uint16 delay1 = 1000;  // Delay after broadcast request for node info.
//  422   const uint16 delay2 = 3000;  // Delay after unicast request for position.
//  423 
//  424   uint16 delay = delay1;
//  425   afAddrType_t dstAddr;
//  426   cId_t cId;
//  427 
//  428   dstAddr.endPoint = LOCATION_ENDPOINT;
//  429   dstAddr.addrMode = afAddrBroadcast;
//  430   dstAddr.addr.shortAddr = NWK_BROADCAST_SHORTADDR;
//  431 
//  432   switch ( state )
//  433   {
//  434   case 0:
//  435     cId = LOCATION_BLINDNODE_REQUEST_CONFIG;
//  436     break;
//  437 
//  438   case 1:
//  439     cId = LOCATION_REFNODE_REQUEST_CONFIG;
//  440     break;
//  441 
//  442   case 2:
//  443     cId = LOCATION_BLINDNODE_REQUEST;
//  444     delay = delay2;
//  445     dstAddr.addrMode = afAddr16Bit;
//  446     dstAddr.addr.shortAddr = blindNodes[0].addr;
//  447     dstAddr.endPoint = blindNodes[0].ep;
//  448     break;
//  449 
//  450   default:
//  451     break;
//  452   }
//  453 
//  454   if ( afStatus_SUCCESS == AF_DataRequest( &dstAddr, (endPointDesc_t *)&epDesc,
//  455                                             cId, 0, NULL, &LocDongle_TransID,
//  456                                             AF_TX_OPTIONS_NONE,
//  457                                             AF_DEFAULT_RADIUS ) )
//  458   {
//  459     if ( ++state >= 3 )
//  460     {
//  461       state = 0;
//  462     }
//  463   }
//  464 
//  465   osal_start_timerEx( LocDongle_TaskID, DONGLE_TIMER_EVT, delay );
//  466 }
//  467 #endif
//  468 
//  469 //#undef ZBIT  //ggg
//  470 /*********************************************************************
//  471 *********************************************************************/
// 
// 724 bytes in segment BANKED_CODE
//  30 bytes in segment BANK_RELAYS
//  38 bytes in segment XDATA_I
//  38 bytes in segment XDATA_ID
//   2 bytes in segment XDATA_Z
// 
// 792 bytes of CODE  memory
//  40 bytes of XDATA memory
//
//Errors: none
//Warnings: none
