###############################################################################
#                                                                             #
# IAR 8051 C/C++ Compiler V7.30B/W32                    21/Jun/2010  17:13: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\z #
#                          stack\Project\Location\Source\SampleApp.c          #
#    Command line       =  -f "C:\Texas Instruments\ZStack-1.4.3-1.2.1\Projec #
#                          ts\zstack\Project\Location\CC2430DB\..\..\..\Tools #
#                          \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\CC #
#                          2430DB\f8wConfig.cfg" (-DSECURE=1                  #
#                          -DDEFAULT_CHANLIST=0x04000000                      #
#                          -DZDAPP_CONFIG_PAN_ID=0x00FF                       #
#                          -DNWK_START_DELAY=100 -DEXTENDED_JOINING_RANDOM_MA #
#                          SK=0x007F -DBEACON_REQUEST_DELAY=100               #
#                          -DBEACON_REQ_DELAY_MASK=0x00FF                     #
#                          -DROUTE_EXPIRY_TIME=30 -DAPSC_ACK_WAIT_DURATION_PO #
#                          LLED=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\Pro #
#                          ject\Location\Source\SampleApp.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\Pro #
#                          ject\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\Projec #
#                          ts\zstack\Project\Location\CC2430DB\LocDongle\Obj\ #
#                          " -e --require_prototypes -z9 --no_code_motion     #
#                          --debug --core=plain --dptr=16,1                   #
#                          --data_model=large --code_model=banked             #
#                          --calling_convention=xdata_reentrant               #
#                          --place_constants=data --nr_virtual_regs 8 -I      #
#                          "C:\Texas Instruments\ZStack-1.4.3-1.2.1\Projects\ #
#                          zstack\Project\Location\CC2430DB\" -I "C:\Texas    #
#                          Instruments\ZStack-1.4.3-1.2.1\Projects\zstack\Pro #
#                          ject\Location\CC2430DB\..\SOURCE\" -I "C:\Texas    #
#                          Instruments\ZStack-1.4.3-1.2.1\Projects\zstack\Pro #
#                          ject\Location\CC2430DB\..\..\..\ZMAIN\TI2430DB\"   #
#                          -I "C:\Texas Instruments\ZStack-1.4.3-1.2.1\Projec #
#                          ts\zstack\Project\Location\CC2430DB\..\..\..\..\WX #
#                          L\INCLUDE\" -I "C:\Texas                           #
#                          Instruments\ZStack-1.4.3-1.2.1\Projects\zstack\Pro #
#                          ject\Location\CC2430DB\..\..\..\..\..\COMPONENTS\M #
#                          T\" -I "C:\Texas Instruments\ZStack-1.4.3-1.2.1\Pr #
#                          ojects\zstack\Project\Location\CC2430DB\..\..\..\. #
#                          .\..\COMPONENTS\HAL\INCLUDE\" -I "C:\Texas         #
#                          Instruments\ZStack-1.4.3-1.2.1\Projects\zstack\Pro #
#                          ject\Location\CC2430DB\..\..\..\..\..\COMPONENTS\H #
#                          AL\TARGET\CC2430EB\" -I "C:\Texas                  #
#                          Instruments\ZStack-1.4.3-1.2.1\Projects\zstack\Pro #
#                          ject\Location\CC2430DB\..\..\..\..\..\COMPONENTS\O #
#                          SAL\MCU\CCSOC\" -I "C:\Texas                       #
#                          Instruments\ZStack-1.4.3-1.2.1\Projects\zstack\Pro #
#                          ject\Location\CC2430DB\..\..\..\..\..\COMPONENTS\O #
#                          SAL\INCLUDE\" -I "C:\Texas                         #
#                          Instruments\ZStack-1.4.3-1.2.1\Projects\zstack\Pro #
#                          ject\Location\CC2430DB\..\..\..\..\..\COMPONENTS\S #
#                          TACK\AF\" -I "C:\Texas Instruments\ZStack-1.4.3-1. #
#                          2.1\Projects\zstack\Project\Location\CC2430DB\..\. #
#                          .\..\..\..\COMPONENTS\STACK\NWK\" -I "C:\Texas     #
#                          Instruments\ZStack-1.4.3-1.2.1\Projects\zstack\Pro #
#                          ject\Location\CC2430DB\..\..\..\..\..\COMPONENTS\S #
#                          TACK\SEC\" -I "C:\Texas Instruments\ZStack-1.4.3-1 #
#                          .2.1\Projects\zstack\Project\Location\CC2430DB\..\ #
#                          ..\..\..\..\COMPONENTS\STACK\SYS\" -I "C:\Texas    #
#                          Instruments\ZStack-1.4.3-1.2.1\Projects\zstack\Pro #
#                          ject\Location\CC2430DB\..\..\..\..\..\COMPONENTS\S #
#                          TACK\ZDO\" -I "C:\Texas Instruments\ZStack-1.4.3-1 #
#                          .2.1\Projects\zstack\Project\Location\CC2430DB\..\ #
#                          ..\..\..\..\COMPONENTS\ZMAC\F8W\" -I "C:\Texas     #
#                          Instruments\ZStack-1.4.3-1.2.1\Projects\zstack\Pro #
#                          ject\Location\CC2430DB\..\..\..\..\..\COMPONENTS\Z #
#                          MAC\" -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\Pro #
#                          ject\Location\CC2430DB\..\..\..\..\..\COMPONENTS\S #
#                          ERVICES\SDATA\" -I "C:\Texas                       #
#                          Instruments\ZStack-1.4.3-1.2.1\Projects\zstack\Pro #
#                          ject\Location\CC2430DB\..\..\..\..\..\COMPONENTS\M #
#                          AC\INCLUDE\" -I "C:\Texas                          #
#                          Instruments\ZStack-1.4.3-1.2.1\Projects\zstack\Pro #
#                          ject\Location\CC2430DB\..\..\..\..\..\COMPONENTS\M #
#                          AC\HIGH_LEVEL\" -I "C:\Texas                       #
#                          Instruments\ZStack-1.4.3-1.2.1\Projects\zstack\Pro #
#                          ject\Location\CC2430DB\..\..\..\..\..\COMPONENTS\M #
#                          AC\LOW_LEVEL\SRF03\" -I "C:\Texas                  #
#                          Instruments\ZStack-1.4.3-1.2.1\Projects\zstack\Pro #
#                          ject\Location\CC2430DB\..\..\..\..\..\COMPONENTS\M #
#                          AC\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\z #
#                          stack\Project\Location\CC2430DB\LocDongle\List\Sam #
#                          pleApp.lst                                         #
#    Object file        =  C:\Texas Instruments\ZStack-1.4.3-1.2.1\Projects\z #
#                          stack\Project\Location\CC2430DB\LocDongle\Obj\Samp #
#                          leApp.r51                                          #
#                                                                             #
#                                                                             #
###############################################################################

C:\Texas Instruments\ZStack-1.4.3-1.2.1\Projects\zstack\Project\Location\Source\SampleApp.c
      1          /**************************************************************************************************
      2            Filename:       SampleApp.c
      3            Revised:        $Date: 2007-10-27 17:16:54 -0700 (Sat, 27 Oct 2007) $
      4            Revision:       $Revision: 15793 $
      5          
      6            Description:    Sample Application for incorporating the Z-Stack Location
      7                            Profile into another Application.
      8          
      9          
     10            Copyright 2006-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          
     45          #include "ZComDef.h"
     46          #include "SampleApp.h"
     47          #include "LocationProfile.h"
     48          
     49          #include "AF.h"
     50          #if !defined( NONWK )
     51            #include "APS.h"
     52            #include "nwk.h"
     53            #include "ZDApp.h"
     54          #endif
     55          #include "OSAL.h"
     56          #include "OSAL_Custom.h"
     57          #include "OSAL_Nv.h"
     58          #if defined( POWER_SAVING )
     59          #include "OSAL_PwrMgr.h"
     60          #endif
     61          #include "OSAL_Tasks.h"
     62          
     63          #include "hal_drivers.h"
     64          #include "hal_key.h"
     65          #include "hal_led.h"
     66          #include "OnBoard.h"
     67          
     68          #if defined ( MT_TASK )
     69            #include "MTEL.h"
     70          #endif
     71          
     72          /*********************************************************************
     73           * CONSTANTS
     74           */
     75          
     76          #define SAMPLE_APP_ENDPOINT                 10
     77          #define SAMPLE_APP_PROFID                   0x2001
     78          #define SAMPLE_APP_DEVICEID                 13
     79          #define SAMPLE_APP_VERSION                  31
     80          #define SAMPLE_APP_FLAGS                    0
     81          
     82          #define SAMPLE_APP_GENERIC_ID               0x0001
     83          #define SAMPLE_APP_ON_OFF_ID                0x0010
     84          
     85          #define SAMPLE_APP_ON                       0xFF
     86          #define SAMPLE_APP_OFF                      0x00
     87          #define SAMPLE_APP_TOGGLE                   0xF0
     88          
     89          /*********************************************************************
     90           * TYPEDEFS
     91           */
     92          
     93          /*********************************************************************
     94           * GLOBAL VARIABLES
     95           */
     96          

   \                                 In  segment XDATA_Z, align 1, keep-with-next
     97          uint8 SampleApp_TaskID;
   \                     SampleApp_TaskID:
   \   000000                DS 1
   \   000001                REQUIRE __INIT_XDATA_Z
     98          
     99          // The order in this table must be identical to the task initialization calls below in osalInitTask.

   \                                 In  segment XDATA_I, align 1, keep-with-next
    100          const pTaskEventHandlerFn tasksArr[] = {
   \                     tasksArr:
   \   000000                DS 16
   \   000010                REQUIRE `?<Initializer for tasksArr>`
   \   000010                REQUIRE __INIT_XDATA_I
    101          #if defined( ZMAC_F8W )
    102            macEventLoop,
    103          #endif
    104          #if !defined( NONWK )
    105            nwk_event_loop,
    106          #endif
    107            Hal_ProcessEvent,
    108          #if defined( MT_TASK )
    109            MT_ProcessEvent,
    110          #endif
    111          #if !defined( NONWK )
    112            APS_event_loop,
    113            ZDApp_event_loop,
    114          #endif
    115            SampleApp_ProcessEvent,
    116          #if defined ( LOCATION_REFNODE )
    117            RefNode_ProcessEvent
    118          #endif
    119          #if defined ( LOCATION_BLINDNODE )
    120            BlindNode_ProcessEvent
    121          #endif
    122          #if defined ( LOCATION_DONGLE )
    123            LocDongle_ProcessEvent
    124          #endif
    125          };
    126          

   \                                 In  segment XDATA_I, align 1, keep-with-next
    127          const uint8 tasksCnt = sizeof( tasksArr ) / sizeof( tasksArr[0] );
   \                     tasksCnt:
   \   000000                DS 1
   \   000001                REQUIRE `?<Initializer for tasksCnt>`
   \   000001                REQUIRE __INIT_XDATA_I

   \                                 In  segment XDATA_Z, align 1, keep-with-next
    128          uint16 *tasksEvents;
   \                     tasksEvents:
   \   000000                DS 2
   \   000002                REQUIRE __INIT_XDATA_Z
    129          
    130          /*********************************************************************
    131           * LOCAL VARIABLES
    132           */
    133          
    134          #if defined ( LOCATION_REFNODE )
    135          static const cId_t SampleApp_InputClusterList[] =
    136          {
    137            SAMPLE_APP_GENERIC_ID,
    138            SAMPLE_APP_ON_OFF_ID
    139          };
    140          
    141          static const cId_t SampleApp_OutputClusterList[] =
    142          {
    143            SAMPLE_APP_GENERIC_ID
    144          };
    145          #endif
    146          
    147          #if defined ( LOCATION_BLINDNODE )
    148          static const cId_t SampleApp_InputClusterList[] =
    149          {
    150            SAMPLE_APP_GENERIC_ID
    151          };
    152          
    153          static const cId_t SampleApp_OutputClusterList[] =
    154          {
    155            SAMPLE_APP_GENERIC_ID,
    156            SAMPLE_APP_ON_OFF_ID
    157          };
    158          #endif
    159          
    160          #if defined ( LOCATION_DONGLE )

   \                                 In  segment XDATA_I, align 1, keep-with-next
    161          static const cId_t SampleApp_InputClusterList[] =
   \                     SampleApp_InputClusterList:
   \   000000                DS 4
   \   000004                REQUIRE `?<Initializer for SampleApp_InputClusterList>`
   \   000004                REQUIRE __INIT_XDATA_I
    162          {
    163            SAMPLE_APP_GENERIC_ID,
    164            SAMPLE_APP_ON_OFF_ID
    165          };
    166          

   \                                 In  segment XDATA_I, align 1, keep-with-next
    167          static const cId_t SampleApp_OutputClusterList[] =
   \                     SampleApp_OutputClusterList:
   \   000000                DS 2
   \   000002                REQUIRE `?<Initializer for SampleApp_OutputClusterList>`
   \   000002                REQUIRE __INIT_XDATA_I
    168          {
    169            SAMPLE_APP_GENERIC_ID
    170          };
    171          #endif
    172          

   \                                 In  segment XDATA_I, align 1, keep-with-next
    173          static const SimpleDescriptionFormat_t SampleApp_SimpleDesc =
   \                     SampleApp_SimpleDesc:
   \   000000                DS 12
   \   00000C                REQUIRE `?<Initializer for SampleApp_SimpleDesc>`
   \   00000C                REQUIRE __INIT_XDATA_I
    174          {
    175            SAMPLE_APP_ENDPOINT,
    176            SAMPLE_APP_PROFID,
    177          
    178            SAMPLE_APP_DEVICEID,
    179          
    180            SAMPLE_APP_VERSION,
    181            SAMPLE_APP_FLAGS,
    182          
    183            sizeof( SampleApp_InputClusterList ),
    184            (cId_t*)SampleApp_InputClusterList,
    185          
    186            sizeof( SampleApp_OutputClusterList ),
    187            (cId_t*)SampleApp_OutputClusterList
    188          };
    189          

   \                                 In  segment XDATA_I, align 1, keep-with-next
    190          static const endPointDesc_t SampleApp_epDesc =
   \                     SampleApp_epDesc:
   \   000000                DS 6
   \   000006                REQUIRE `?<Initializer for SampleApp_epDesc>`
   \   000006                REQUIRE __INIT_XDATA_I
    191          {
    192            SAMPLE_APP_ENDPOINT,
    193            &SampleApp_TaskID,
    194            (SimpleDescriptionFormat_t *)&SampleApp_SimpleDesc,
    195            noLatencyReqs
    196          };
    197          
    198          #if defined( POWER_SAVING )
    199          /* The ZDO_STATE_CHANGE event will be received twice after initiating the
    200           * rejoin process, only act on one of them.
    201           */
    202          static uint8 rejoinPending;
    203          #endif
    204          
    205          /*********************************************************************
    206           * LOCAL FUNCTIONS
    207           */
    208          
    209          static void SampleApp_Init( uint8 task_id );
    210          
    211          /*********************************************************************
    212           * FUNCTIONS
    213           *********************************************************************/
    214          
    215          /*********************************************************************
    216           * @fn      osalInitTasks
    217           *
    218           * @brief   This function invokes the initialization function for each task.
    219           *
    220           * @param   void
    221           *
    222           * @return  none
    223           */

   \                                 In  segment BANKED_CODE, align 1, keep-with-next
    224          void osalInitTasks( void )
   \                     osalInitTasks:
    225          {
   \   000000   C082         PUSH    DPL
   \   000002   C083         PUSH    DPH
   \   000004                ; Saved register size: 2
   \   000004                ; Auto size: 0
    226            uint8 taskID = 0;
    227          
    228            tasksEvents = (uint16 *)osal_mem_alloc( sizeof( uint16 ) * tasksCnt);
   \   000004                ; Setup parameters for call to function osal_mem_alloc
   \   000004   7A10         MOV     R2,#0x10
   \   000006   7B00         MOV     R3,#0x0
   \   000008   12....       LCALL   ??osal_mem_alloc?relay
   \   00000B   90....       MOV     DPTR,#tasksEvents
   \   00000E   EA           MOV     A,R2
   \   00000F   F0           MOVX    @DPTR,A
   \   000010   A3           INC     DPTR
   \   000011   EB           MOV     A,R3
   \   000012   F0           MOVX    @DPTR,A
    229            osal_memset( tasksEvents, 0, (sizeof( uint16 ) * tasksCnt));
   \   000013                ; Setup parameters for call to function osal_memset
   \   000013   7C10         MOV     R4,#0x10
   \   000015   7D00         MOV     R5,#0x0
   \   000017   7900         MOV     R1,#0x0
   \   000019   12....       LCALL   ??osal_memset?relay
    230          
    231          #if defined( ZMAC_F8W )
    232            macTaskInit( taskID++ );
   \   00001C                ; Setup parameters for call to function macTaskInit
   \   00001C   7900         MOV     R1,#0x0
   \   00001E   12....       LCALL   ??macTaskInit?relay
    233          #endif
    234          #if !defined( NONWK )
    235            nwk_init( taskID++ );
   \   000021                ; Setup parameters for call to function nwk_init
   \   000021   7901         MOV     R1,#0x1
   \   000023   12....       LCALL   ??nwk_init?relay
    236          #endif
    237            Hal_Init( taskID++ );
   \   000026                ; Setup parameters for call to function Hal_Init
   \   000026   7902         MOV     R1,#0x2
   \   000028   12....       LCALL   ??Hal_Init?relay
    238          #if defined( MT_TASK )
    239            MT_TaskInit( taskID++ );
   \   00002B                ; Setup parameters for call to function MT_TaskInit
   \   00002B   7903         MOV     R1,#0x3
   \   00002D   12....       LCALL   ??MT_TaskInit?relay
    240          #endif
    241          #if !defined( NONWK )
    242            APS_Init( taskID++ );
   \   000030                ; Setup parameters for call to function APS_Init
   \   000030   7904         MOV     R1,#0x4
   \   000032   12....       LCALL   ??APS_Init?relay
    243            ZDApp_Init( taskID++ );
   \   000035                ; Setup parameters for call to function ZDApp_Init
   \   000035   7905         MOV     R1,#0x5
   \   000037   12....       LCALL   ??ZDApp_Init?relay
    244          #endif
    245            SampleApp_Init( taskID++ );
   \   00003A   7406         MOV     A,#0x6
   \   00003C   90....       MOV     DPTR,#SampleApp_TaskID
   \   00003F   F0           MOVX    @DPTR,A
   \   000040                ; Setup parameters for call to function afRegister
   \   000040   7A..         MOV     R2,#(SampleApp_epDesc & 0xff)
   \   000042   7B..         MOV     R3,#((SampleApp_epDesc >> 8) & 0xff)
   \   000044   12....       LCALL   ??afRegister?relay
   \   000047                ; Setup parameters for call to function RegisterForKeys
   \   000047   90....       MOV     DPTR,#SampleApp_TaskID
   \   00004A   E0           MOVX    A,@DPTR
   \   00004B   F9           MOV     R1,A
   \   00004C   12....       LCALL   ??RegisterForKeys?relay
    246          #if defined ( LOCATION_REFNODE )
    247            RefNode_Init( taskID );
    248          #endif
    249          #if defined ( LOCATION_BLINDNODE )
    250            BlindNode_Init( taskID );
    251          #endif
    252          #if defined ( LOCATION_DONGLE )
    253            LocDongle_Init( taskID );
   \   00004F                ; Setup parameters for call to function LocDongle_Init
   \   00004F   7907         MOV     R1,#0x7
   \   000051   12....       LCALL   ??LocDongle_Init?relay
    254          #endif
    255          }
   \   000054   D083         POP     DPH
   \   000056   D082         POP     DPL
   \   000058   02....       LJMP    ?BRET
    256          
    257          /*********************************************************************
    258           * @fn      SampleApp_Init
    259           *
    260           * @brief   Initialization function for the SampleApp OSAL task.
    261           *
    262           * @param   task_id - the ID assigned by OSAL.
    263           *
    264           * @return  none
    265           */
    266          static void SampleApp_Init( uint8 task_id )
    267          {
    268            SampleApp_TaskID = task_id;
    269          
    270            /* Sample NV Restore.
    271            if ( ZSUCCESS == osal_nv_item_init( SAMPLE_APP_NV_ITEM,
    272                                      sizeof( sampleAppNV_Item_t ), &sampleAppNV_Item ) )
    273            {
    274              osal_nv_read( SAMPLE_APP_NV_ITEM, 0,
    275                                      sizeof( sampleAppNV_Item_t ), &sampleAppNV_Item ) )
    276            }
    277            else
    278            {
    279              osal_nv_read( SAMPLE_APP_NV_ITEM, 0,
    280                                      sizeof( sampleAppNV_Item_t ), &sampleAppNV_Item ) )
    281            }
    282             */
    283          
    284            // Register the endpoint/interface description with the AF.
    285            afRegister( (endPointDesc_t *)&SampleApp_epDesc );
    286          
    287            // Register for all key events - This app will handle all key events.
    288            RegisterForKeys( SampleApp_TaskID );
    289          
    290          }
    291          
    292          /*********************************************************************
    293           * @fn      SampleApp_ProcessEvent
    294           *
    295           * @brief   Generic Application Task event processor.
    296           *
    297           * @param   task_id  - The OSAL assigned task ID.
    298           * @param   events - Bit map of events to process.
    299           *
    300           * @return  none
    301           */

   \                                 In  segment BANKED_CODE, align 1, keep-with-next
    302          uint16 SampleApp_ProcessEvent( uint8 task_id, uint16 events )
   \                     SampleApp_ProcessEvent:
    303          {
   \   000000   74F6         MOV     A,#-0xa
   \   000002   12....       LCALL   ?BANKED_ENTER_XDATA
   \   000005                ; Saved register size: 10
   \   000005                ; Auto size: 0
   \   000005   EA           MOV     A,R2
   \   000006   FE           MOV     R6,A
   \   000007   EB           MOV     A,R3
   \   000008   FF           MOV     R7,A
    304            if ( events & SYS_EVENT_MSG )
   \   000009   7480         MOV     A,#-0x80
   \   00000B   5F           ANL     A,R7
   \   00000C   F9           MOV     R1,A
   \   00000D   E4           CLR     A
   \   00000E   7001         JNZ     ??SampleApp_ProcessEvent_0
   \   000010   E9           MOV     A,R1
   \                     ??SampleApp_ProcessEvent_0:
   \   000011   601B         JZ      ??SampleApp_ProcessEvent_1
    305            {
    306              afIncomingMSGPacket_t *MSGpkt = (afIncomingMSGPacket_t *)osal_msg_receive(
    307                                                                       SampleApp_TaskID );
   \   000013                ; Setup parameters for call to function osal_msg_receive
   \   000013   8003         SJMP    ??SampleApp_ProcessEvent_2
    308          
    309              while ( MSGpkt != NULL )
    310              {
    311                switch ( MSGpkt->hdr.event )
    312                {
    313          
    314                case AF_DATA_CONFIRM_CMD:
    315          
    316                  break;
    317          
    318                case AF_INCOMING_MSG_CMD:
    319                  break;
    320          
    321                case ZDO_STATE_CHANGE:
    322          
    323          #if defined( POWER_SAVING )
    324                    // Ok to resume power saving ops.
    325                    SampleApp_Sleep( TRUE );
    326          #endif
    327                  break;
    328          
    329                default:
    330                  break;
    331                }
    332          
    333                osal_msg_deallocate( (uint8 *)MSGpkt );
   \                     ??SampleApp_ProcessEvent_3:
   \   000015                ; Setup parameters for call to function osal_msg_deallocate
   \   000015   12....       LCALL   ??osal_msg_deallocate?relay
    334                MSGpkt = (afIncomingMSGPacket_t *)osal_msg_receive( SampleApp_TaskID );
   \   000018                ; Setup parameters for call to function osal_msg_receive
   \                     ??SampleApp_ProcessEvent_2:
   \   000018   90....       MOV     DPTR,#SampleApp_TaskID
   \   00001B   E0           MOVX    A,@DPTR
   \   00001C   F9           MOV     R1,A
   \   00001D   12....       LCALL   ??osal_msg_receive?relay
    335              }
   \   000020   EA           MOV     A,R2
   \   000021   7001         JNZ     ??SampleApp_ProcessEvent_4
   \   000023   EB           MOV     A,R3
   \                     ??SampleApp_ProcessEvent_4:
   \   000024   70EF         JNZ     ??SampleApp_ProcessEvent_3
    336          
    337              // Return unprocessed events.
    338              return ( events ^ SYS_EVENT_MSG );
   \   000026   EE           MOV     A,R6
   \   000027   FA           MOV     R2,A
   \   000028   7480         MOV     A,#-0x80
   \   00002A   6F           XRL     A,R7
   \   00002B   FB           MOV     R3,A
   \   00002C   8004         SJMP    ??SampleApp_ProcessEvent_5
    339            }
    340          
    341            return 0;  // Discard unknown events
   \                     ??SampleApp_ProcessEvent_1:
   \   00002E   7A00         MOV     R2,#0x0
   \   000030   7B00         MOV     R3,#0x0
   \                     ??SampleApp_ProcessEvent_5:
   \   000032   7F02         MOV     R7,#0x2
   \   000034   02....       LJMP    ?BANKED_LEAVE_XDATA
    342          }
    343          
    344          /*********************************************************************
    345           * @fn      SampleApp_NoACK
    346           *
    347           * @brief   Sample Application recovery from getting a ZMacNoAck.
    348           *
    349           * @return  none
    350           */

   \                                 In  segment BANKED_CODE, align 1, keep-with-next
    351          void SampleApp_NoACK( void )
   \                     SampleApp_NoACK:
    352          {
   \   000000                ; Saved register size: 0
   \   000000                ; Auto size: 0
    353          #if defined( POWER_SAVING )
    354            rejoinPending = TRUE;
    355            ZDApp_SendEventMsg( ZDO_NWK_JOIN_REQ, 0, NULL );
    356          
    357            SampleApp_Sleep( FALSE );
    358          #endif
    359          }
   \   000000   02....       LJMP    ?BRET
    360          
    361          /*********************************************************************
    362           * @fn      SampleApp_Sleep
    363           *
    364           * @brief   Sample Application set allow/disallow sleep mode.
    365           *
    366           * @return  none
    367           */

   \                                 In  segment BANKED_CODE, align 1, keep-with-next
    368          void SampleApp_Sleep( uint8 allow )
   \                     SampleApp_Sleep:
    369          {
   \   000000                ; Saved register size: 0
   \   000000                ; Auto size: 0
    370          #if defined( POWER_SAVING )
    371            if ( allow )
    372            {
    373              osal_pwrmgr_task_state( NWK_TaskID, PWRMGR_CONSERVE );
    374              NLME_SetPollRate( 0 );
    375            }
    376            else
    377            {
    378              osal_pwrmgr_task_state( NWK_TaskID, PWRMGR_HOLD );
    379              NLME_SetPollRate( 1000 );
    380            }
    381          #endif
    382          }
   \   000000   02....       LJMP    ?BRET
    383          
    384          
    385          /*********************************************************************
    386           * @fn      Debug_HalUARTWrite
    387           *
    388           * @brief   For debug use only.
    389           *
    390           * @return  none
    391           */

   \                                 In  segment BANKED_CODE, align 1, keep-with-next
    392          uint16 Debug_HalUARTWrite( uint8 port, uint8 *buf, uint16 len )
   \                     Debug_HalUARTWrite:
    393          {
   \   000000                ; Saved register size: 0
   \   000000                ; Auto size: 0
    394            #if 0
    395            HalUARTWrite(port, buf, len );
    396            #endif
    397            return len;
   \   000000   EC           MOV     A,R4
   \   000001   FA           MOV     R2,A
   \   000002   ED           MOV     A,R5
   \   000003   FB           MOV     R3,A
   \   000004   02....       LJMP    ?BRET
    398          }

   \                                 In  segment XDATA_ID, align 1, keep-with-next
   \                     `?<Initializer for tasksArr>`:
   \   000000   ........     DW ??macEventLoop?relay, ??nwk_event_loop?relay
   \   000004   ........     DW ??Hal_ProcessEvent?relay, ??MT_ProcessEvent?relay
   \   000008   ........     DW ??APS_event_loop?relay, ??ZDApp_event_loop?relay
   \   00000C   ........     DW ??SampleApp_ProcessEvent?relay, ??LocDongle_ProcessEvent?relay

   \                                 In  segment XDATA_ID, align 1, keep-with-next
   \                     `?<Initializer for tasksCnt>`:
   \   000000   08           DB 8

   \                                 In  segment XDATA_ID, align 1, keep-with-next
   \                     `?<Initializer for SampleApp_InputClusterList>`:
   \   000000   01001000     DW 1, 16

   \                                 In  segment XDATA_ID, align 1, keep-with-next
   \                     `?<Initializer for SampleApp_OutputClusterList>`:
   \   000000   0100         DW 1

   \                                 In  segment XDATA_ID, align 1, keep-with-next
   \                     `?<Initializer for SampleApp_SimpleDesc>`:
   \   000000   0A           DB 10
   \   000001   01200D00     DW 8193, 13
   \   000005   0F04         DB 15, 4
   \   000007   ....         DW SampleApp_InputClusterList
   \   000009   02           DB 2
   \   00000A   ....         DW SampleApp_OutputClusterList

   \                                 In  segment XDATA_ID, align 1, keep-with-next
   \                     `?<Initializer for SampleApp_epDesc>`:
   \   000000   0A           DB 10
   \   000001   ........     DW SampleApp_TaskID, SampleApp_SimpleDesc
   \   000005   00           DB 0

   \                                 In  segment BANK_RELAYS, align 1
   \                     ??osalInitTasks?relay:
   \   000000   12....       LCALL   ?BDISPATCH
   \   000003   ......       DC24    osalInitTasks

   \                                 In  segment BANK_RELAYS, align 1
   \                     ??SampleApp_ProcessEvent?relay:
   \   000000   12....       LCALL   ?BDISPATCH
   \   000003   ......       DC24    SampleApp_ProcessEvent

   \                                 In  segment BANK_RELAYS, align 1
   \                     ??SampleApp_NoACK?relay:
   \   000000   12....       LCALL   ?BDISPATCH
   \   000003   ......       DC24    SampleApp_NoACK

   \                                 In  segment BANK_RELAYS, align 1
   \                     ??SampleApp_Sleep?relay:
   \   000000   12....       LCALL   ?BDISPATCH
   \   000003   ......       DC24    SampleApp_Sleep

   \                                 In  segment BANK_RELAYS, align 1
   \                     ??Debug_HalUARTWrite?relay:
   \   000000   12....       LCALL   ?BDISPATCH
   \   000003   ......       DC24    Debug_HalUARTWrite
    399          
    400          /*********************************************************************
    401          *********************************************************************/

   Maximum stack usage in bytes:

     Function                 ISTACK PSTACK XSTACK
     --------                 ------ ------ ------
     Debug_HalUARTWrite           0      0      0
     SampleApp_NoACK              0      0      0
     SampleApp_ProcessEvent       0      0     10
       -> osal_msg_receive        0      0     20
       -> osal_msg_deallocate     0      0     20
       -> osal_msg_receive        0      0     20
     SampleApp_Sleep              0      0      0
     osalInitTasks                2      0      0
       -> osal_mem_alloc          4      0      0
       -> osal_memset             4      0      0
       -> macTaskInit             4      0      0
       -> nwk_init                4      0      0
       -> Hal_Init                4      0      0
       -> MT_TaskInit             4      0      0
       -> APS_Init                4      0      0
       -> ZDApp_Init              4      0      0
       -> afRegister              4      0      0
       -> RegisterForKeys         4      0      0
       -> LocDongle_Init          4      0      0


   Segment part sizes:

     Function/Label                 Bytes
     --------------                 -----
     SampleApp_TaskID                  1
     tasksArr                         16
     tasksCnt                          1
     tasksEvents                       2
     SampleApp_InputClusterList        4
     SampleApp_OutputClusterList       2
     SampleApp_SimpleDesc             12
     SampleApp_epDesc                  6
     osalInitTasks                    91
     SampleApp_ProcessEvent           55
     SampleApp_NoACK                   3
     SampleApp_Sleep                   3
     Debug_HalUARTWrite                7
     ?<Initializer for tasksArr>      16
     ?<Initializer for tasksCnt>       1
     ?<Initializer for SampleApp_InputClusterList>
                                       4
     ?<Initializer for SampleApp_OutputClusterList>
                                       2
     ?<Initializer for SampleApp_SimpleDesc>
                                      12
     ?<Initializer for SampleApp_epDesc>
                                       6
     ??osalInitTasks?relay             6
     ??SampleApp_ProcessEvent?relay    6
     ??SampleApp_NoACK?relay           6
     ??SampleApp_Sleep?relay           6
     ??Debug_HalUARTWrite?relay        6

 
 159 bytes in segment BANKED_CODE
  30 bytes in segment BANK_RELAYS
  41 bytes in segment XDATA_I
  41 bytes in segment XDATA_ID
   3 bytes in segment XDATA_Z
 
 230 bytes of CODE  memory
  44 bytes of XDATA memory

Errors: none
Warnings: none
