###############################################################################
#                                                                             #
# IAR 8051 C/C++ Compiler V7.30B/W32                    21/Jun/2010  17:06:54 #
# Copyright 2004-2007 IAR Systems. All rights reserved.                       #
#                                                                             #
#    Core               =  plain                                              #
#    Code model         =  banked                                             #
#    Data model         =  large                                              #
#    Calling convention =  xdata reentrant                                    #
#    Constant location  =  data                                               #
#    Dptr setup         =  1,16                                               #
#    Source file        =  C:\Texas Instruments\ZStack-1.4.3-1.2.1\Projects\z #
#                          stack\ZMain\TI2430DB\OnBoard.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\ZMa #
#                          in\TI2430DB\OnBoard.c" -D CC2430EB -D ZTOOL_P1 -D  #
#                          LOCATION_DONGLE -D MT_TASK -D xNV_RESTORE -D       #
#                          INT_HEAP_LEN=4608 -D HAL_UART_BIG_TX_BUF=1 -D      #
#                          SPI_MGR_DEFAULT_MAX_TX_BUFF=1024 -D                #
#                          SPI_MGR_DEFAULT_OVERFLOW=1 -lC "C:\Texas           #
#                          Instruments\ZStack-1.4.3-1.2.1\Projects\zstack\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\OnB #
#                          oard.lst                                           #
#    Object file        =  C:\Texas Instruments\ZStack-1.4.3-1.2.1\Projects\z #
#                          stack\Project\Location\CC2430DB\LocDongle\Obj\OnBo #
#                          ard.r51                                            #
#                                                                             #
#                                                                             #
###############################################################################

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

   \                                 In  segment SFR_AN, at 0xa8
   \   union <unnamed> volatile __sfr _A_IEN0
   \                     _A_IEN0:
   \   000000                DS 1

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

   \                                 In  segment XDATA_Z, align 1, keep-with-next
     85          uint8 OnboardKeyIntEnable;
   \                     OnboardKeyIntEnable:
   \   000000                DS 1
   \   000001                REQUIRE __INIT_XDATA_Z

   \                                 In  segment XDATA_Z, align 1, keep-with-next
     86          uint8 OnboardTimerIntEnable;
   \                     OnboardTimerIntEnable:
   \   000000                DS 1
   \   000001                REQUIRE __INIT_XDATA_Z
     87          
     88          // 64-bit Extended Address of this device

   \                                 In  segment XDATA_Z, align 1, keep-with-next
     89          uint8 aExtendedAddress[8];
   \                     aExtendedAddress:
   \   000000                DS 8
   \   000008                REQUIRE __INIT_XDATA_Z
     90          
     91          /*********************************************************************
     92           * EXTERNAL VARIABLES
     93           */
     94          
     95          /*********************************************************************
     96           * EXTERNAL FUNCTIONS
     97           */
     98          
     99          extern uint8 macMcuRandomByte(void);
    100          
    101          /*********************************************************************
    102           * LOCAL VARIABLES
    103           */
    104          
    105          // Registered keys task ID, initialized to NOT USED.

   \                                 In  segment XDATA_I, align 1, keep-with-next
    106          static byte registeredKeysTaskID = NO_TASK_ID;
   \                     registeredKeysTaskID:
   \   000000                DS 1
   \   000001                REQUIRE `?<Initializer for registeredKeysTaskID>`
   \   000001                REQUIRE __INIT_XDATA_I
    107          
    108          /*********************************************************************
    109           * LOCAL FUNCTIONS
    110           */
    111          
    112          static void ChkReset( void );
    113          
    114          /*********************************************************************
    115           * @fn      InitBoard()
    116           * @brief   Initialize the CC2420DB Board Peripherals
    117           * @param   level: COLD,WARM,READY
    118           * @return  None
    119           */

   \                                 In  segment BANKED_CODE, align 1, keep-with-next
    120          void InitBoard( byte level )
   \                     InitBoard:
    121          {
   \   000000   74F6         MOV     A,#-0xa
   \   000002   12....       LCALL   ?BANKED_ENTER_XDATA
   \   000005                ; Saved register size: 10
   \   000005                ; Auto size: 0
    122            if ( level == OB_COLD )
   \   000005   E9           MOV     A,R1
   \   000006   7079         JNZ     ??InitBoard_0
    123            {
    124              // Interrupts off
    125              osal_int_disable( INTS_ALL );
   \   000008                ; Setup parameters for call to function osal_int_disable
   \   000008   79FF         MOV     R1,#-0x1
   \   00000A   12....       LCALL   ??osal_int_disable?relay
    126              // Turn all LEDs off
    127              HalLedSet( HAL_LED_ALL, HAL_LED_MODE_OFF );
   \   00000D                ; Setup parameters for call to function HalLedSet
   \   00000D   7A00         MOV     R2,#0x0
   \   00000F   790F         MOV     R1,#0xf
   \   000011   12....       LCALL   ??HalLedSet?relay
    128              // Check for Brown-Out reset
    129              ChkReset();
   \   000014   7418         MOV     A,#0x18
   \   000016   55BE         ANL     A,0xbe
   \   000018   FA           MOV     R2,A
   \   000019   6042         JZ      ??InitBoard_1
   \   00001B   7408         MOV     A,#0x8
   \   00001D   6A           XRL     A,R2
   \   00001E   603D         JZ      ??InitBoard_1
   \   000020   7410         MOV     A,#0x10
   \   000022   6A           XRL     A,R2
   \   000023   6038         JZ      ??InitBoard_1
   \   000025   C2AF         CLR     0xa8.7
   \   000027   8030         SJMP    ??InitBoard_2
   \                     ??InitBoard_3:
   \   000029                ; Setup parameters for call to function HalLedSet
   \   000029   7A01         MOV     R2,#0x1
   \   00002B   EE           MOV     A,R6
   \   00002C   F9           MOV     R1,A
   \   00002D   12....       LCALL   ??HalLedSet?relay
   \   000030                ; Setup parameters for call to function Onboard_wait
   \   000030   7A24         MOV     R2,#0x24
   \   000032   7BF4         MOV     R3,#-0xc
   \   000034   12....       LCALL   ??Onboard_wait?relay
   \   000037                ; Setup parameters for call to function Onboard_wait
   \   000037   7A24         MOV     R2,#0x24
   \   000039   7BF4         MOV     R3,#-0xc
   \   00003B   12....       LCALL   ??Onboard_wait?relay
   \   00003E                ; Setup parameters for call to function HalLedSet
   \   00003E   7A00         MOV     R2,#0x0
   \   000040   EE           MOV     A,R6
   \   000041   F9           MOV     R1,A
   \   000042   12....       LCALL   ??HalLedSet?relay
   \   000045                ; Setup parameters for call to function Onboard_wait
   \   000045   7A7C         MOV     R2,#0x7c
   \   000047   7B92         MOV     R3,#-0x6e
   \   000049   12....       LCALL   ??Onboard_wait?relay
   \   00004C                ; Setup parameters for call to function Onboard_wait
   \   00004C   7A7C         MOV     R2,#0x7c
   \   00004E   7B92         MOV     R3,#-0x6e
   \   000050   12....       LCALL   ??Onboard_wait?relay
   \   000053   EE           MOV     A,R6
   \   000054   C3           CLR     C
   \   000055   13           RRC     A
   \   000056   FE           MOV     R6,A
   \   000057   70D0         JNZ     ??InitBoard_3
   \                     ??InitBoard_2:
   \   000059   7E08         MOV     R6,#0x8
   \   00005B   80CC         SJMP    ??InitBoard_3
    130          
    131            /* Timer2 for Osal timer
    132             * This development board uses ATmega128 Timer/Counter3 to provide
    133             * system clock ticks for the OSAL scheduler. These functions perform
    134             * the hardware specific actions required by the OSAL_Timers module.
    135             */
    136             OnboardTimerIntEnable = FALSE;
   \                     ??InitBoard_1:
   \   00005D   E4           CLR     A
   \   00005E   90....       MOV     DPTR,#OnboardTimerIntEnable
   \   000061   F0           MOVX    @DPTR,A
    137           	 HalTimerConfig (OSAL_TIMER,                        // 8bit timer2
    138                            HAL_TIMER_MODE_CTC,                 // Clear Timer on Compare
    139                            HAL_TIMER_CHANNEL_SINGLE,           // Channel 1 - default
    140                            HAL_TIMER_CH_MODE_OUTPUT_COMPARE,   // Output Compare mode
    141                            OnboardTimerIntEnable,              // Use interrupt
    142                            Onboard_TimerCallBack);             // Channel Mode
   \   000062                ; Setup parameters for call to function HalTimerConfig
   \   000062   75....       MOV     ?V0 + 0,#(??Onboard_TimerCallBack?relay & 0xff)
   \   000065   75....       MOV     ?V0 + 1,#((??Onboard_TimerCallBack?relay >> 8) & 0xff)
   \   000068   78..         MOV     R0,#?V0 + 0
   \   00006A   12....       LCALL   ?PUSH_XSTACK_I_TWO
   \   00006D   7D00         MOV     R5,#0x0
   \   00006F   7C02         MOV     R4,#0x2
   \   000071   7B01         MOV     R3,#0x1
   \   000073   7A02         MOV     R2,#0x2
   \   000075   7902         MOV     R1,#0x2
   \   000077   12....       LCALL   ??HalTimerConfig?relay
   \   00007A   7402         MOV     A,#0x2
   \   00007C   12....       LCALL   ?DEALLOC_XSTACK8
   \   00007F   8010         SJMP    ??InitBoard_4
    143          
    144            }
    145            else  // !OB_COLD
    146            {
    147          #ifdef ZTOOL_PORT
    148              MT_IndReset();
   \                     ??InitBoard_0:
   \   000081                ; Setup parameters for call to function MT_IndReset
   \   000081   12....       LCALL   ??MT_IndReset?relay
    149          #endif
    150          
    151               /* Initialize Key stuff */
    152              OnboardKeyIntEnable = HAL_KEY_INTERRUPT_DISABLE;
   \   000084   E4           CLR     A
   \   000085   90....       MOV     DPTR,#OnboardKeyIntEnable
   \   000088   F0           MOVX    @DPTR,A
    153              HalKeyConfig( OnboardKeyIntEnable, OnBoard_KeyCallback);
   \   000089                ; Setup parameters for call to function HalKeyConfig
   \   000089   7A..         MOV     R2,#(??OnBoard_KeyCallback?relay & 0xff)
   \   00008B   7B..         MOV     R3,#((??OnBoard_KeyCallback?relay >> 8) & 0xff)
   \   00008D   F9           MOV     R1,A
   \   00008E   12....       LCALL   ??HalKeyConfig?relay
    154            }
    155          }
   \                     ??InitBoard_4:
   \   000091                REQUIRE ?Subroutine0
   \   000091                REQUIRE _A_IEN0
   \   000091                REQUIRE SLEEP
   \   000091                ; // Fall through to label ?Subroutine0

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

   \                                 In  segment BANKED_CODE, align 1, keep-with-next
    216          byte RegisterForKeys( byte task_id )
   \                     RegisterForKeys:
    217          {
   \   000000   C082         PUSH    DPL
   \   000002   C083         PUSH    DPH
   \   000004                ; Saved register size: 2
   \   000004                ; Auto size: 0
    218            // Allow only the first task
    219            if ( registeredKeysTaskID == NO_TASK_ID )
   \   000004   90....       MOV     DPTR,#registeredKeysTaskID
   \   000007   E0           MOVX    A,@DPTR
   \   000008   64FF         XRL     A,#0xff
   \   00000A   7006         JNZ     ??RegisterForKeys_0
    220            {
    221              registeredKeysTaskID = task_id;
   \   00000C   E9           MOV     A,R1
   \   00000D   F0           MOVX    @DPTR,A
    222              return ( true );
   \   00000E   7901         MOV     R1,#0x1
   \   000010   8002         SJMP    ??RegisterForKeys_1
    223            }
    224            else
    225              return ( false );
   \                     ??RegisterForKeys_0:
   \   000012   7900         MOV     R1,#0x0
   \                     ??RegisterForKeys_1:
   \   000014   02....       LJMP    ?Subroutine1 & 0xFFFF
    226          }

   \                                 In  segment BANKED_CODE, align 1, keep-with-next
   \                     ?Subroutine1:
   \   000000   D083         POP     DPH
   \   000002   D082         POP     DPL
   \   000004   02....       LJMP    ?BRET
    227          
    228          /*********************************************************************
    229           * @fn      OnBoard_SendKeys
    230           *
    231           * @brief   Send "Key Pressed" message to application.
    232           *
    233           * @param   keys  - keys that were pressed
    234           *          state - shifted
    235           *
    236           * @return  status
    237           *********************************************************************/

   \                                 In  segment BANKED_CODE, align 1, keep-with-next
    238          byte OnBoard_SendKeys( byte keys, byte state )
   \                     OnBoard_SendKeys:
    239          {
   \   000000   74F6         MOV     A,#-0xa
   \   000002   12....       LCALL   ?BANKED_ENTER_XDATA
   \   000005                ; Saved register size: 10
   \   000005                ; Auto size: 0
   \   000005   E9           MOV     A,R1
   \   000006   FE           MOV     R6,A
   \   000007   EA           MOV     A,R2
   \   000008   FF           MOV     R7,A
    240            keyChange_t *msgPtr;
    241          
    242            if ( registeredKeysTaskID != NO_TASK_ID )
   \   000009   90....       MOV     DPTR,#registeredKeysTaskID
   \   00000C   E0           MOVX    A,@DPTR
   \   00000D   64FF         XRL     A,#0xff
   \   00000F   602D         JZ      ??OnBoard_SendKeys_0
    243            {
    244              // Send the address to the task
    245              msgPtr = (keyChange_t *)osal_msg_allocate( sizeof(keyChange_t) );
   \   000011                ; Setup parameters for call to function osal_msg_allocate
   \   000011   7A04         MOV     R2,#0x4
   \   000013   7B00         MOV     R3,#0x0
   \   000015   12....       LCALL   ??osal_msg_allocate?relay
    246              if ( msgPtr )
   \   000018   EA           MOV     A,R2
   \   000019   7001         JNZ     ??OnBoard_SendKeys_1
   \   00001B   EB           MOV     A,R3
   \                     ??OnBoard_SendKeys_1:
   \   00001C   601C         JZ      ??OnBoard_SendKeys_2
    247              {
    248                msgPtr->hdr.event = KEY_CHANGE;
   \   00001E   74C0         MOV     A,#-0x40
   \   000020   8A82         MOV     DPL,R2
   \   000022   8B83         MOV     DPH,R3
   \   000024   F0           MOVX    @DPTR,A
    249                msgPtr->state = state;
   \   000025   EF           MOV     A,R7
   \   000026   A3           INC     DPTR
   \   000027   A3           INC     DPTR
   \   000028   F0           MOVX    @DPTR,A
    250                msgPtr->keys = keys;
   \   000029   EE           MOV     A,R6
   \   00002A   8A82         MOV     DPL,R2
   \   00002C   8B83         MOV     DPH,R3
   \   00002E   A3           INC     DPTR
   \   00002F   A3           INC     DPTR
   \   000030   A3           INC     DPTR
   \   000031   F0           MOVX    @DPTR,A
    251          
    252                osal_msg_send( registeredKeysTaskID, (uint8 *)msgPtr );
   \   000032                ; Setup parameters for call to function osal_msg_send
   \   000032   90....       MOV     DPTR,#registeredKeysTaskID
   \   000035   E0           MOVX    A,@DPTR
   \   000036   F9           MOV     R1,A
   \   000037   12....       LCALL   ??osal_msg_send?relay
    253              }
    254              return ( ZSuccess );
   \                     ??OnBoard_SendKeys_2:
   \   00003A   7900         MOV     R1,#0x0
   \   00003C   8002         SJMP    ??OnBoard_SendKeys_3
    255            }
    256            else
    257              return ( ZFailure );
   \                     ??OnBoard_SendKeys_0:
   \   00003E   7901         MOV     R1,#0x1
   \                     ??OnBoard_SendKeys_3:
   \   000040   80..         SJMP    ?Subroutine0
    258          }
    259          
    260          /*********************************************************************
    261           * @fn      OnBoard_KeyCallback
    262           *
    263           * @brief   Callback service for keys
    264           *
    265           * @param   keys  - keys that were pressed
    266           *          state - shifted
    267           *
    268           * @return  void
    269           *********************************************************************/

   \                                 In  segment BANKED_CODE, align 1, keep-with-next
    270          void OnBoard_KeyCallback ( uint8 keys, uint8 state )
   \                     OnBoard_KeyCallback:
    271          {
   \   000000   C082         PUSH    DPL
   \   000002   C083         PUSH    DPH
   \   000004                ; Saved register size: 2
   \   000004                ; Auto size: 0
    272            uint8 shift;
    273          
    274            // shift key (S1) is used to generate key interrupt
    275            // applications should not use S1 when key interrupt is enabled
    276            shift = (OnboardKeyIntEnable == HAL_KEY_INTERRUPT_ENABLE) ? false : ((keys & HAL_KEY_SW_6) ? true : false);
   \   000004   90....       MOV     DPTR,#OnboardKeyIntEnable
   \   000007   E0           MOVX    A,@DPTR
   \   000008   6401         XRL     A,#0x1
   \   00000A   7004         JNZ     ??OnBoard_KeyCallback_0
   \   00000C   7B00         MOV     R3,#0x0
   \   00000E   8011         SJMP    ??OnBoard_KeyCallback_1
   \                     ??OnBoard_KeyCallback_0:
   \   000010   E9           MOV     A,R1
   \   000011   A2E5         MOV     C,0xE0 /* A   */.5
   \   000013   5004         JNC     ??OnBoard_KeyCallback_2
   \   000015   D2F0         SETB    B.0
   \   000017   8002         SJMP    ??OnBoard_KeyCallback_3
   \                     ??OnBoard_KeyCallback_2:
   \   000019   C2F0         CLR     B.0
   \                     ??OnBoard_KeyCallback_3:
   \   00001B   A2F0         MOV     C,B.0
   \   00001D   E4           CLR     A
   \   00001E   92E0         MOV     0xE0 /* A   */.0,C
   \   000020   FB           MOV     R3,A
   \                     ??OnBoard_KeyCallback_1:
   \   000021   EB           MOV     A,R3
   \   000022   FA           MOV     R2,A
    277          
    278            if ( OnBoard_SendKeys( keys, shift ) != ZSuccess )
   \   000023                ; Setup parameters for call to function OnBoard_SendKeys
   \   000023   12....       LCALL   ??OnBoard_SendKeys?relay
    279            {
    280              // Process SW1 here
    281              if ( keys & HAL_KEY_SW_1 )  // Switch 1
    282              {
    283              }
    284              // Process SW2 here
    285              if ( keys & HAL_KEY_SW_2 )  // Switch 2
    286              {
    287              }
    288              // Process SW3 here
    289              if ( keys & HAL_KEY_SW_3 )  // Switch 3
    290              {
    291              }
    292              // Process SW4 here
    293              if ( keys & HAL_KEY_SW_4 )  // Switch 4
    294              {
    295              }
    296              // Process SW5 here
    297              if ( keys & HAL_KEY_SW_5 )  // Switch 5
    298              {
    299              }
    300              // Process SW6 here
    301              if ( keys & HAL_KEY_SW_6 )  // Switch 6
    302              {
    303              }
    304            }
    305          }
   \   000026   80..         SJMP    ?Subroutine1
    306          
    307          /*********************************************************************
    308           *                    SLEEP MANAGEMENT FUNCTIONS
    309           *
    310           * These functions support processing of MAC and ZStack power mode
    311           * transitions, used when the system goes into or awakes from sleep.
    312           */
    313          
    314           /*********************************************************************
    315           * @fn      OnBoard_stack_used()
    316           *
    317           * @brief
    318           *
    319           *   Runs through the stack looking for touched memory.
    320           *
    321           * @param   none
    322           *
    323           * @return  number of bytes used by the stack
    324           *********************************************************************/

   \                                 In  segment BANKED_CODE, align 1, keep-with-next
    325          uint16 OnBoard_stack_used( void )
   \                     OnBoard_stack_used:
    326          {
   \   000000   C082         PUSH    DPL
   \   000002   C083         PUSH    DPH
   \   000004                ; Saved register size: 2
   \   000004                ; Auto size: 0
    327            byte *pStack = (byte*)MCU_RAM_END;
   \   000004   78FF         MOV     R0,#-0x1
   \   000006   79FF         MOV     R1,#-0x1
    328            byte *pHold;
    329            byte found = false;
    330            byte x;
    331          
    332            // Look from the end of RAM for MIN_RAM_INIT number of "pattern" bytes
    333            // This should be the high water stack mark.
    334            while ( !found && pStack )
    335            {
    336              // Found an init value?
    337              if ( *pStack == STACK_INIT_VALUE )
   \                     ??OnBoard_stack_used_0:
   \   000008   8882         MOV     DPL,R0
   \   00000A   8983         MOV     DPH,R1
   \   00000C   E0           MOVX    A,@DPTR
   \   00000D   64CD         XRL     A,#0xcd
   \   00000F   7020         JNZ     ??OnBoard_stack_used_1
    338              {
    339                // Look for a bunch in a row
    340                pHold = pStack;
    341                for ( x = 0; x < MIN_RAM_INIT; x++ )
   \   000011   7A00         MOV     R2,#0x0
    342                {
    343                  if ( *pHold != STACK_INIT_VALUE )
   \                     ??OnBoard_stack_used_2:
   \   000013   E0           MOVX    A,@DPTR
   \   000014   64CD         XRL     A,#0xcd
   \   000016   7013         JNZ     ??OnBoard_stack_used_3
    344                    break;
    345                  else
    346                    pHold--;
   \   000018   E582         MOV     A,DPL
   \   00001A   24FF         ADD     A,#-0x1
   \   00001C   F582         MOV     DPL,A
   \   00001E   E583         MOV     A,DPH
   \   000020   34FF         ADDC    A,#-0x1
   \   000022   F583         MOV     DPH,A
    347                }
   \   000024   0A           INC     R2
   \   000025   EA           MOV     A,R2
   \   000026   C3           CLR     C
   \   000027   940C         SUBB    A,#0xc
   \   000029   40E8         JC      ??OnBoard_stack_used_2
    348                // Did we find the needed minimum number in a row
    349                if ( x >= MIN_RAM_INIT )
   \                     ??OnBoard_stack_used_3:
   \   00002B   EA           MOV     A,R2
   \   00002C   C3           CLR     C
   \   00002D   940C         SUBB    A,#0xc
   \   00002F   5014         JNC     ??OnBoard_stack_used_4
    350                  found = true;
    351              }
    352              if ( !found )
    353                pStack--;
   \                     ??OnBoard_stack_used_1:
   \   000031   E8           MOV     A,R0
   \   000032   24FF         ADD     A,#-0x1
   \   000034   18           DEC     R0
   \   000035   E9           MOV     A,R1
   \   000036   34FF         ADDC    A,#-0x1
   \   000038   F9           MOV     R1,A
   \   000039   E8           MOV     A,R0
   \   00003A   7001         JNZ     ??OnBoard_stack_used_5
   \   00003C   E9           MOV     A,R1
   \                     ??OnBoard_stack_used_5:
   \   00003D   70C9         JNZ     ??OnBoard_stack_used_0
    354            }
    355          
    356            if ( pStack )
    357              return ( (uint16)((byte*)MCU_RAM_END - pStack) );
    358            else
    359              return ( 0 );
   \   00003F   7A00         MOV     R2,#0x0
   \   000041   7B00         MOV     R3,#0x0
   \   000043   8009         SJMP    ??OnBoard_stack_used_6
   \                     ??OnBoard_stack_used_4:
   \   000045   74FF         MOV     A,#-0x1
   \   000047   C3           CLR     C
   \   000048   98           SUBB    A,R0
   \   000049   FA           MOV     R2,A
   \   00004A   74FF         MOV     A,#-0x1
   \   00004C   99           SUBB    A,R1
   \   00004D   FB           MOV     R3,A
   \                     ??OnBoard_stack_used_6:
   \   00004E                REQUIRE ?Subroutine1
   \   00004E                ; // Fall through to label ?Subroutine1
    360          }
    361          
    362          /*********************************************************************
    363           * @fn      _itoa
    364           *
    365           * @brief   convert a 16bit number to ASCII
    366           *
    367           * @param   num -
    368           *          buf -
    369           *          radix -
    370           *
    371           * @return  void
    372           *
    373           *********************************************************************/

   \                                 In  segment BANKED_CODE, align 1, keep-with-next
    374          void _itoa(uint16 num, byte *buf, byte radix)
   \                     _itoa:
    375          {
   \   000000   74F2         MOV     A,#-0xe
   \   000002   12....       LCALL   ?BANKED_ENTER_XDATA
   \   000005                ; Saved register size: 14
   \   000005                ; Auto size: 5
   \   000005   74FB         MOV     A,#-0x5
   \   000007   12....       LCALL   ?ALLOC_XSTACK8
   \   00000A   EA           MOV     A,R2
   \   00000B   FE           MOV     R6,A
   \   00000C   EB           MOV     A,R3
   \   00000D   FF           MOV     R7,A
   \   00000E   8C..         MOV     ?V0 + 0,R4
   \   000010   8D..         MOV     ?V0 + 1,R5
   \   000012   89..         MOV     ?V0 + 5,R1
    376            char c,i;
    377            byte *p, rst[5];
    378          
    379            p = rst;
   \   000014   85..82       MOV     DPL,?XSP + 0
   \   000017   85..83       MOV     DPH,?XSP + 1
   \   00001A   AC82         MOV     R4,DPL
   \   00001C   AD83         MOV     R5,DPH
    380            for ( i=0; i<5; i++,p++ )
   \   00001E   75..00       MOV     ?V0 + 4,#0x0
    381            {
    382              c = num % radix;  // Isolate a digit
   \                     ??_itoa_0:
   \   000021   EE           MOV     A,R6
   \   000022   F8           MOV     R0,A
   \   000023   EF           MOV     A,R7
   \   000024   F9           MOV     R1,A
   \   000025   E5..         MOV     A,?V0 + 5
   \   000027   F5..         MOV     ?V0 + 2,A
   \   000029   FA           MOV     R2,A
   \   00002A   7B00         MOV     R3,#0x0
   \   00002C   12....       LCALL   ?US_DIV_MOD
   \   00002F   EA           MOV     A,R2
    383              *p = c + (( c < 10 ) ? '0' : '7');  // Convert to Ascii
   \   000030   940A         SUBB    A,#0xa
   \   000032   5004         JNC     ??_itoa_1
   \   000034   7830         MOV     R0,#0x30
   \   000036   8002         SJMP    ??_itoa_2
   \                     ??_itoa_1:
   \   000038   7837         MOV     R0,#0x37
   \                     ??_itoa_2:
   \   00003A   E8           MOV     A,R0
   \   00003B   2A           ADD     A,R2
   \   00003C   8C82         MOV     DPL,R4
   \   00003E   8D83         MOV     DPH,R5
   \   000040   F0           MOVX    @DPTR,A
    384              num /= radix;
   \   000041   EE           MOV     A,R6
   \   000042   F8           MOV     R0,A
   \   000043   EF           MOV     A,R7
   \   000044   F9           MOV     R1,A
   \   000045   AA..         MOV     R2,?V0 + 2
   \   000047   7B00         MOV     R3,#0x0
   \   000049   12....       LCALL   ?US_DIV_MOD
   \   00004C   88..         MOV     ?V0 + 2,R0
   \   00004E   89..         MOV     ?V0 + 3,R1
   \   000050   AE..         MOV     R6,?V0 + 2
   \   000052   AF..         MOV     R7,?V0 + 3
    385              if ( !num )
   \   000054   EE           MOV     A,R6
   \   000055   7001         JNZ     ??_itoa_3
   \   000057   EF           MOV     A,R7
   \                     ??_itoa_3:
   \   000058   600D         JZ      ??_itoa_4
    386                break;
    387            }
   \   00005A   05..         INC     ?V0 + 4
   \   00005C   A3           INC     DPTR
   \   00005D   AC82         MOV     R4,DPL
   \   00005F   AD83         MOV     R5,DPH
   \   000061   E5..         MOV     A,?V0 + 4
   \   000063   9405         SUBB    A,#0x5
   \   000065   40BA         JC      ??_itoa_0
    388          
    389            for ( c=0 ; c<=i; c++ )
   \                     ??_itoa_4:
   \   000067   7A00         MOV     R2,#0x0
    390              *buf++ = *p--;  // Reverse character order
   \                     ??_itoa_5:
   \   000069   8C82         MOV     DPL,R4
   \   00006B   8D83         MOV     DPH,R5
   \   00006D   E0           MOVX    A,@DPTR
   \   00006E   85..82       MOV     DPL,?V0 + 0
   \   000071   85..83       MOV     DPH,?V0 + 1
   \   000074   F0           MOVX    @DPTR,A
   \   000075   EC           MOV     A,R4
   \   000076   24FF         ADD     A,#-0x1
   \   000078   1C           DEC     R4
   \   000079   ED           MOV     A,R5
   \   00007A   34FF         ADDC    A,#-0x1
   \   00007C   FD           MOV     R5,A
   \   00007D   A3           INC     DPTR
   \   00007E   8582..       MOV     ?V0 + 0,DPL
   \   000081   8583..       MOV     ?V0 + 1,DPH
   \   000084   0A           INC     R2
   \   000085   E5..         MOV     A,?V0 + 4
   \   000087   C3           CLR     C
   \   000088   9A           SUBB    A,R2
   \   000089   50DE         JNC     ??_itoa_5
    391          
    392            *buf = '\0';
   \   00008B   E4           CLR     A
   \   00008C   F0           MOVX    @DPTR,A
    393          }
   \   00008D   7405         MOV     A,#0x5
   \   00008F   12....       LCALL   ?DEALLOC_XSTACK8
   \   000092   7F06         MOV     R7,#0x6
   \   000094   02....       LJMP    ?BANKED_LEAVE_XDATA
    394          
    395          /*********************************************************************
    396           * @fn        Onboard_rand
    397           *
    398           * @brief    Random number generator
    399           *
    400           * @param   none
    401           *
    402           * @return  uint16 - new random number
    403           *
    404           *********************************************************************/

   \                                 In  segment BANKED_CODE, align 1, keep-with-next
    405          uint16 Onboard_rand( void )
   \                     Onboard_rand:
    406          {
   \   000000   74F7         MOV     A,#-0x9
   \   000002   12....       LCALL   ?BANKED_ENTER_XDATA
   \   000005                ; Saved register size: 9
   \   000005                ; Auto size: 0
    407            uint16 randNum;
    408          
    409            randNum = macMcuRandomByte();
   \   000005                ; Setup parameters for call to function macMcuRandomByte
   \   000005   12....       LCALL   ??macMcuRandomByte?relay
   \   000008   E9           MOV     A,R1
   \   000009   FE           MOV     R6,A
    410            randNum += (macMcuRandomByte() << 8);
   \   00000A                ; Setup parameters for call to function macMcuRandomByte
   \   00000A   12....       LCALL   ??macMcuRandomByte?relay
   \   00000D   EE           MOV     A,R6
   \   00000E   2400         ADD     A,#0x0
   \   000010   E4           CLR     A
   \   000011   39           ADDC    A,R1
   \   000012   FF           MOV     R7,A
    411            return ( randNum );
   \   000013   EE           MOV     A,R6
   \   000014   FA           MOV     R2,A
   \   000015   EF           MOV     A,R7
   \   000016   FB           MOV     R3,A
   \   000017   7F01         MOV     R7,#0x1
   \   000019   02....       LJMP    ?BANKED_LEAVE_XDATA
    412          }
    413          
    414          /*********************************************************************
    415           * @fn        Onboard_wait
    416           *
    417           * @brief    Random number generator
    418           *
    419           * @param   uint16 - time to wait
    420           *
    421           * @return  none
    422           *
    423           *********************************************************************/

   \                                 In  segment BANKED_CODE, align 1, keep-with-next
    424          void Onboard_wait( uint16 timeout )
   \                     Onboard_wait:
    425          {
   \   000000                ; Saved register size: 0
   \   000000                ; Auto size: 0
   \   000000   8003         SJMP    ??Onboard_wait_0
    426            while (timeout--)
    427            {
    428              asm("NOP");
   \                     ??Onboard_wait_1:
   \   000002   00           NOP
    429              asm("NOP");
   \   000003   00           NOP
    430              asm("NOP");
   \   000004   00           NOP
    431            }
   \                     ??Onboard_wait_0:
   \   000005   EA           MOV     A,R2
   \   000006   F8           MOV     R0,A
   \   000007   EB           MOV     A,R3
   \   000008   F9           MOV     R1,A
   \   000009   74FF         MOV     A,#-0x1
   \   00000B   28           ADD     A,R0
   \   00000C   1A           DEC     R2
   \   00000D   74FF         MOV     A,#-0x1
   \   00000F   39           ADDC    A,R1
   \   000010   FB           MOV     R3,A
   \   000011   E8           MOV     A,R0
   \   000012   7001         JNZ     ??Onboard_wait_2
   \   000014   E9           MOV     A,R1
   \                     ??Onboard_wait_2:
   \   000015   70EB         JNZ     ??Onboard_wait_1
    432          }
   \   000017   02....       LJMP    ?BRET
    433          
    434          /*********************************************************************
    435           * @fn      Osal_TimerCallBack()
    436           *
    437           * @brief   Update the timer per tick
    438           *
    439           * @param   none
    440           *
    441           * @return  local clock in milliseconds
    442           **********************************************************************/

   \                                 In  segment BANKED_CODE, align 1, keep-with-next
    443          void Onboard_TimerCallBack ( uint8 timerId, uint8 channel, uint8 channelMode)
   \                     Onboard_TimerCallBack:
    444          {
   \   000000   C082         PUSH    DPL
   \   000002   C083         PUSH    DPH
   \   000004                ; Saved register size: 2
   \   000004                ; Auto size: 0
    445          
    446            if ((timerId == OSAL_TIMER) && (channelMode == HAL_TIMER_CH_MODE_OUTPUT_COMPARE))
   \   000004   7402         MOV     A,#0x2
   \   000006   69           XRL     A,R1
   \   000007   7008         JNZ     ??Onboard_TimerCallBack_0
   \   000009   7402         MOV     A,#0x2
   \   00000B   6B           XRL     A,R3
   \   00000C   7003         JNZ     ??Onboard_TimerCallBack_0
    447            {
    448              osal_update_timers();
   \   00000E                ; Setup parameters for call to function osal_update_timers
   \   00000E   12....       LCALL   ??osal_update_timers?relay
    449            }
    450          }
   \                     ??Onboard_TimerCallBack_0:
   \   000011   02....       LJMP    ?Subroutine1 & 0xFFFF
    451          
    452          /*********************************************************************
    453           *                    EXTERNAL I/O FUNCTIONS
    454           *
    455           * User defined functions to control external devices. Add your code
    456           * to the following functions to control devices wired to DB outputs.
    457           *
    458           *********************************************************************/
    459          

   \                                 In  segment BANKED_CODE, align 1, keep-with-next
    460          void BigLight_On( void )
   \                     BigLight_On:
    461          {
   \   000000                ; Saved register size: 0
   \   000000                ; Auto size: 0
    462            // Put code here to turn on an external light
    463          }
   \   000000   02....       LJMP    ?BRET
    464          

   \                                 In  segment BANKED_CODE, align 1, keep-with-next
    465          void BigLight_Off( void )
   \                     BigLight_Off:
    466          {
   \   000000                ; Saved register size: 0
   \   000000                ; Auto size: 0
    467            // Put code here to turn off an external light
    468          }
   \   000000   02....       LJMP    ?BRET
    469          

   \                                 In  segment BANKED_CODE, align 1, keep-with-next
    470          void BuzzerControl( byte on )
   \                     BuzzerControl:
    471          {
   \   000000                ; Saved register size: 0
   \   000000                ; Auto size: 0
    472            // Put code here to turn a buzzer on/off
    473          }
   \   000000   02....       LJMP    ?BRET
    474          

   \                                 In  segment BANKED_CODE, align 1, keep-with-next
    475          void Dimmer( byte lvl )
   \                     Dimmer:
    476          {
   \   000000                ; Saved register size: 0
   \   000000                ; Auto size: 0
    477            // Put code here to control a dimmer
    478          }
   \   000000   02....       LJMP    ?BRET
    479          
    480          // No dip switches on this board

   \                                 In  segment BANKED_CODE, align 1, keep-with-next
    481          byte GetUserDipSw( void )
   \                     GetUserDipSw:
    482          {
   \   000000                ; Saved register size: 0
   \   000000                ; Auto size: 0
    483            return 0;
   \   000000   7900         MOV     R1,#0x0
   \   000002   02....       LJMP    ?BRET
    484          }

   \                                 In  segment XDATA_ID, align 1, keep-with-next
   \                     `?<Initializer for registeredKeysTaskID>`:
   \   000000   FF           DB 255

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

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

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

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

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

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

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

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

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

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

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

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

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

   \                                 In  segment BANK_RELAYS, align 1
   \                     ??GetUserDipSw?relay:
   \   000000   12....       LCALL   ?BDISPATCH
   \   000003   ......       DC24    GetUserDipSw
    485          
    486          /*********************************************************************
    487          *********************************************************************/

   Maximum stack usage in bytes:

     Function                ISTACK PSTACK XSTACK
     --------                ------ ------ ------
     BigLight_Off                0      0      0
     BigLight_On                 0      0      0
     BuzzerControl               0      0      0
     Dimmer                      0      0      0
     GetUserDipSw                0      0      0
     InitBoard                   0      0     12
       -> osal_int_disable       0      0     20
       -> HalLedSet              0      0     20
       -> HalLedSet              0      0     20
       -> Onboard_wait           0      0     20
       -> Onboard_wait           0      0     20
       -> HalLedSet              0      0     20
       -> Onboard_wait           0      0     20
       -> Onboard_wait           0      0     20
       -> HalTimerConfig         0      0     24
       -> MT_IndReset            0      0     20
       -> HalKeyConfig           0      0     20
     OnBoard_KeyCallback         2      0      0
       -> OnBoard_SendKeys       4      0      0
     OnBoard_SendKeys            1      0     10
       -> osal_msg_allocate      0      0     20
       -> osal_msg_send          0      0     20
     OnBoard_stack_used          2      0      0
     Onboard_TimerCallBack       2      0      0
       -> osal_update_timers     4      0      0
     Onboard_rand                0      0      9
       -> macMcuRandomByte       0      0     18
       -> macMcuRandomByte       0      0     18
     Onboard_wait                0      0     10
     RegisterForKeys             2      0      0
     _itoa                       1      0     19


   Segment part sizes:

     Function/Label                 Bytes
     --------------                 -----
     _A_IEN0                           1
     SLEEP                             1
     OnboardKeyIntEnable               1
     OnboardTimerIntEnable             1
     aExtendedAddress                  8
     registeredKeysTaskID              1
     InitBoard                       145
     ?Subroutine0                      5
     RegisterForKeys                  23
     ?Subroutine1                      7
     OnBoard_SendKeys                 66
     OnBoard_KeyCallback              40
     OnBoard_stack_used               78
     _itoa                           151
     Onboard_rand                     28
     Onboard_wait                     26
     Onboard_TimerCallBack            20
     BigLight_On                       3
     BigLight_Off                      3
     BuzzerControl                     3
     Dimmer                            3
     GetUserDipSw                      5
     ?<Initializer for registeredKeysTaskID>
                                       1
     ??InitBoard?relay                 6
     ??RegisterForKeys?relay           6
     ??OnBoard_SendKeys?relay          6
     ??OnBoard_KeyCallback?relay       6
     ??OnBoard_stack_used?relay        6
     ??_itoa?relay                     6
     ??Onboard_rand?relay              6
     ??Onboard_wait?relay              6
     ??Onboard_TimerCallBack?relay     6
     ??BigLight_On?relay               6
     ??BigLight_Off?relay              6
     ??BuzzerControl?relay             6
     ??Dimmer?relay                    6
     ??GetUserDipSw?relay              6

 
 606 bytes in segment BANKED_CODE
  84 bytes in segment BANK_RELAYS
   2 bytes in segment SFR_AN
   1 byte  in segment XDATA_I
   1 byte  in segment XDATA_ID
  10 bytes in segment XDATA_Z
 
 691 bytes of CODE  memory
   0 bytes of DATA  memory (+ 2 bytes shared)
  11 bytes of XDATA memory

Errors: none
Warnings: none
