///////////////////////////////////////////////////////////////////////////////
//                                                                            /
// IAR 8051 C/C++ Compiler V7.30B/W32                   12/Sep/2010  21:57:29 /
// Copyright 2004-2007 IAR Systems. All rights reserved.                      /
//                                                                            /
//    Core               =  plain                                             /
//    Code model         =  banked                                            /
//    Data model         =  large                                             /
//    Calling convention =  xdata reentrant                                   /
//    Constant location  =  data                                              /
//    Dptr setup         =  1,16                                              /
//    Source file        =  C:\Texas Instruments 33\ZStack-1.4.3-1.2.1\Compon /
//                          ents\mac\low_level\srf03\single_chip\mac_csp_tx.c /
//    Command line       =  -f "C:\Texas Instruments                          /
//                          33\ZStack-1.4.3-1.2.1\Projects\zstack\Project\Loc /
//                          ation\CC2430DB\..\..\..\Tools\CC2430DB\f8wRouter. /
//                          cfg" (-DCPU32MHZ -DFORCE_MAC_NEAR                 /
//                          -DROOT=__near_func -DMAC_CFG_APP_PENDING_QUEUE=TR /
//                          UE -DRTR_NWK -DBLINK_LEDS "-DCONST=const __code"  /
//                          -DGENERIC=__generic) -f "C:\Texas Instruments     /
//                          33\ZStack-1.4.3-1.2.1\Projects\zstack\Project\Loc /
//                          ation\CC2430DB\..\..\..\Tools\CC2430DB\f8wConfig. /
//                          cfg" (-DSECURE=1 -DDEFAULT_CHANLIST=0x04000000    /
//                          -DZDAPP_CONFIG_PAN_ID=0x00FF                      /
//                          -DNWK_START_DELAY=100 -DEXTENDED_JOINING_RANDOM_M /
//                          ASK=0x007F -DBEACON_REQUEST_DELAY=100             /
//                          -DBEACON_REQ_DELAY_MASK=0x00FF                    /
//                          -DROUTE_EXPIRY_TIME=30 -DAPSC_ACK_WAIT_DURATION_P /
//                          OLLED=3000 -DNWK_INDIRECT_MSG_TIMEOUT=7           /
//                          -DMAX_RREQ_ENTRIES=10 -DAPSC_MAX_FRAME_RETRIES=3  /
//                          -DNWK_MAX_DATA_RETRIES=2                          /
//                          -DMAX_POLL_FAILURE_RETRIES=2 -DMAX_BCAST=9        /
//                          -DAPS_MAX_GROUPS=16 -DMAX_RTG_ENTRIES=20          /
//                          -DNWK_MAX_BINDING_ENTRIES=10                      /
//                          -DMAX_BINDING_CLUSTER_IDS=5                       /
//                          "-DDEFAULT_KEY={0x02, 0x03, 0x05, 0x07, 0x09,     /
//                          0x0B, 0x0D, 0x0F, 0x00, 0x02, 0x04, 0x06, 0x08,   /
//                          0x0A, 0x0C, 0x0D}" -DRFD_RCVC_ALWAYS_ON=FALSE     /
//                          -DPOLL_RATE=1000 -DQUEUED_POLL_RATE=100           /
//                          -DRESPONSE_POLL_RATE=100) -DREJOIN_POLL_RATE=440  /
//                          "C:\Texas Instruments 33\ZStack-1.4.3-1.2.1\Compo /
//                          nents\mac\low_level\srf03\single_chip\mac_csp_tx. /
//                          c" -D CC2430EB -D LOCATION_REFNODE -D             /
//                          xNV_RESTORE -D ZTOOL_P1 -D MT_TASK -D             /
//                          POWER_SAVING -D HAL_UART_BIG_TX_BUF=1 -D          /
//                          SPI_MGR_DEFAULT_MAX_TX_BUFF=1024 -D               /
//                          SPI_MGR_DEFAULT_OVERFLOW=1 -lC "C:\Texas          /
//                          Instruments 33\ZStack-1.4.3-1.2.1\Projects\zstack /
//                          \Project\Location\CC2430DB\RefNode\List\" -lA     /
//                          "C:\Texas Instruments 33\ZStack-1.4.3-1.2.1\Proje /
//                          cts\zstack\Project\Location\CC2430DB\RefNode\List /
//                          \" --diag_suppress Pe001,Pa010 --diag_remark      /
//                          pe550 -o "C:\Texas Instruments                    /
//                          33\ZStack-1.4.3-1.2.1\Projects\zstack\Project\Loc /
//                          ation\CC2430DB\RefNode\Obj\" -e                   /
//                          --require_prototypes -z9 --no_code_motion         /
//                          --debug --core=plain --dptr=16,1                  /
//                          --data_model=large --code_model=banked            /
//                          --calling_convention=xdata_reentrant              /
//                          --place_constants=data --nr_virtual_regs 8 -I     /
//                          "C:\Texas Instruments 33\ZStack-1.4.3-1.2.1\Proje /
//                          cts\zstack\Project\Location\CC2430DB\" -I         /
//                          "C:\Texas Instruments 33\ZStack-1.4.3-1.2.1\Proje /
//                          cts\zstack\Project\Location\CC2430DB\..\SOURCE\"  /
//                          -I "C:\Texas Instruments                          /
//                          33\ZStack-1.4.3-1.2.1\Projects\zstack\Project\Loc /
//                          ation\CC2430DB\..\..\..\ZMAIN\TI2430DB\" -I       /
//                          "C:\Texas Instruments 33\ZStack-1.4.3-1.2.1\Proje /
//                          cts\zstack\Project\Location\CC2430DB\..\..\..\..\ /
//                          ..\COMPONENTS\MT\" -I "C:\Texas Instruments       /
//                          33\ZStack-1.4.3-1.2.1\Projects\zstack\Project\Loc /
//                          ation\CC2430DB\..\..\..\..\..\COMPONENTS\HAL\INCL /
//                          UDE\" -I "C:\Texas Instruments                    /
//                          33\ZStack-1.4.3-1.2.1\Projects\zstack\Project\Loc /
//                          ation\CC2430DB\..\..\..\..\..\COMPONENTS\HAL\TARG /
//                          ET\CC2430BB\" -I "C:\Texas Instruments            /
//                          33\ZStack-1.4.3-1.2.1\Projects\zstack\Project\Loc /
//                          ation\CC2430DB\..\..\..\..\..\COMPONENTS\OSAL\MCU /
//                          \CCSOC\" -I "C:\Texas Instruments                 /
//                          33\ZStack-1.4.3-1.2.1\Projects\zstack\Project\Loc /
//                          ation\CC2430DB\..\..\..\..\..\COMPONENTS\OSAL\INC /
//                          LUDE\" -I "C:\Texas Instruments                   /
//                          33\ZStack-1.4.3-1.2.1\Projects\zstack\Project\Loc /
//                          ation\CC2430DB\..\..\..\..\..\COMPONENTS\STACK\AF /
//                          \" -I "C:\Texas Instruments                       /
//                          33\ZStack-1.4.3-1.2.1\Projects\zstack\Project\Loc /
//                          ation\CC2430DB\..\..\..\..\..\COMPONENTS\STACK\NW /
//                          K\" -I "C:\Texas Instruments                      /
//                          33\ZStack-1.4.3-1.2.1\Projects\zstack\Project\Loc /
//                          ation\CC2430DB\..\..\..\..\..\COMPONENTS\STACK\SE /
//                          C\" -I "C:\Texas Instruments                      /
//                          33\ZStack-1.4.3-1.2.1\Projects\zstack\Project\Loc /
//                          ation\CC2430DB\..\..\..\..\..\COMPONENTS\STACK\SY /
//                          S\" -I "C:\Texas Instruments                      /
//                          33\ZStack-1.4.3-1.2.1\Projects\zstack\Project\Loc /
//                          ation\CC2430DB\..\..\..\..\..\COMPONENTS\STACK\ZD /
//                          O\" -I "C:\Texas Instruments                      /
//                          33\ZStack-1.4.3-1.2.1\Projects\zstack\Project\Loc /
//                          ation\CC2430DB\..\..\..\..\..\COMPONENTS\ZMAC\F8W /
//                          \" -I "C:\Texas Instruments                       /
//                          33\ZStack-1.4.3-1.2.1\Projects\zstack\Project\Loc /
//                          ation\CC2430DB\..\..\..\..\..\COMPONENTS\ZMAC\"   /
//                          -I "C:\Texas Instruments                          /
//                          33\ZStack-1.4.3-1.2.1\Projects\zstack\Project\Loc /
//                          ation\CC2430DB\..\..\..\..\..\COMPONENTS\SERVICES /
//                          \SADDR\" -I "C:\Texas Instruments                 /
//                          33\ZStack-1.4.3-1.2.1\Projects\zstack\Project\Loc /
//                          ation\CC2430DB\..\..\..\..\..\COMPONENTS\SERVICES /
//                          \SDATA\" -I "C:\Texas Instruments                 /
//                          33\ZStack-1.4.3-1.2.1\Projects\zstack\Project\Loc /
//                          ation\CC2430DB\..\..\..\..\..\COMPONENTS\MAC\INCL /
//                          UDE\" -I "C:\Texas Instruments                    /
//                          33\ZStack-1.4.3-1.2.1\Projects\zstack\Project\Loc /
//                          ation\CC2430DB\..\..\..\..\..\COMPONENTS\MAC\HIGH /
//                          _LEVEL\" -I "C:\Texas Instruments                 /
//                          33\ZStack-1.4.3-1.2.1\Projects\zstack\Project\Loc /
//                          ation\CC2430DB\..\..\..\..\..\COMPONENTS\MAC\LOW_ /
//                          LEVEL\SRF03\" -I "C:\Texas Instruments            /
//                          33\ZStack-1.4.3-1.2.1\Projects\zstack\Project\Loc /
//                          ation\CC2430DB\..\..\..\..\..\COMPONENTS\MAC\LOW_ /
//                          LEVEL\SRF03\SINGLE_CHIP\" -I "C:\Program          /
//                          Files\IAR Systems\Embedded Workbench 4.0          /
//                          Evaluation version\8051\INC\" -I "C:\Program      /
//                          Files\IAR Systems\Embedded Workbench 4.0          /
//                          Evaluation version\8051\INC\CLIB\"                /
//    List file          =  C:\Texas Instruments 33\ZStack-1.4.3-1.2.1\Projec /
//                          ts\zstack\Project\Location\CC2430DB\RefNode\List\ /
//                          mac_csp_tx.s51                                    /
//                                                                            /
//                                                                            /
///////////////////////////////////////////////////////////////////////////////

        NAME mac_csp_tx

        RTMODEL "__calling_convention", "xdata_reentrant"
        RTMODEL "__code_model", "banked"
        RTMODEL "__core", "plain"
        RTMODEL "__data_model", "large"
        RTMODEL "__dptr_size", "16"
        RTMODEL "__extended_stack", "disabled"
        RTMODEL "__location_for_constants", "data"
        RTMODEL "__number_of_dptrs", "1"
        RTMODEL "__rt_version", "1"

        RSEG DOVERLAY:DATA:NOROOT(0)
        RSEG IOVERLAY:IDATA:NOROOT(0)
        RSEG ISTACK:IDATA:NOROOT(0)
        RSEG PSTACK:XDATA:NOROOT(0)
        RSEG XSTACK:XDATA:NOROOT(0)

        EXTERN ??cspPrepForTxProgram?relay
        EXTERN ??macCspTxIntIsr?relay
        EXTERN ?BANKED_ENTER_XDATA
        EXTERN ?BANKED_LEAVE_XDATA
        EXTERN ?BDISPATCH
        EXTERN ?BRET
        EXTERN ?S_DIV_MOD
        EXTERN ?V0

        FUNCTION ??cspPrepForTxProgram?relay,0203H
        PUBLIC ??macCspForceTxDoneIfPending?relay
        FUNCTION ??macCspForceTxDoneIfPending?relay,0203H
        PUBLIC ??macCspTxCancelAckTimeoutCallback?relay
        FUNCTION ??macCspTxCancelAckTimeoutCallback?relay,0203H
        PUBLIC ??macCspTxGoCsma?relay
        FUNCTION ??macCspTxGoCsma?relay,0203H
        PUBLIC ??macCspTxGoSlotted?relay
        FUNCTION ??macCspTxGoSlotted?relay,0203H
        PUBLIC ??macCspTxIntIsr?relay
        FUNCTION ??macCspTxIntIsr?relay,0203H
        PUBLIC ??macCspTxPrepCsmaSlotted?relay
        FUNCTION ??macCspTxPrepCsmaSlotted?relay,0203H
        PUBLIC ??macCspTxPrepCsmaUnslotted?relay
        FUNCTION ??macCspTxPrepCsmaUnslotted?relay,0203H
        PUBLIC ??macCspTxPrepSlotted?relay
        FUNCTION ??macCspTxPrepSlotted?relay,0203H
        PUBLIC ??macCspTxRequestAckTimeoutCallback?relay
        FUNCTION ??macCspTxRequestAckTimeoutCallback?relay,0203H
        PUBLIC ??macCspTxReset?relay
        FUNCTION ??macCspTxReset?relay,0203H
        PUBLIC ??macCspTxStopIsr?relay
        FUNCTION ??macCspTxStopIsr?relay,0203H
        PUBWEAK RFIF
        PUBWEAK RFIM
        PUBWEAK RFST
        PUBWEAK S1CON
        PUBWEAK T2CMP
        PUBWEAK T2OF0
        PUBWEAK T2THD
        PUBWEAK T2TLD
        PUBWEAK _A_IEN0
        FUNCTION cspPrepForTxProgram,021203H
        ARGFRAME XSTACK, 0, STACK
        ARGFRAME IOVERLAY, 0, STATIC
        ARGFRAME DOVERLAY, 0, STATIC
        LOCFRAME ISTACK, 2, STACK
        PUBLIC macCspForceTxDoneIfPending
        FUNCTION macCspForceTxDoneIfPending,021203H
        ARGFRAME XSTACK, 0, STACK
        LOCFRAME ISTACK, 2, STACK
        PUBLIC macCspTxCancelAckTimeoutCallback
        FUNCTION macCspTxCancelAckTimeoutCallback,0203H
        ARGFRAME XSTACK, 0, STACK
        PUBLIC macCspTxGoCsma
        FUNCTION macCspTxGoCsma,021203H
        ARGFRAME XSTACK, 0, STACK
        LOCFRAME ISTACK, 2, STACK
        PUBLIC macCspTxGoSlotted
        FUNCTION macCspTxGoSlotted,021203H
        ARGFRAME XSTACK, 0, STACK
        LOCFRAME XSTACK, 9, STACK
        PUBLIC macCspTxIntIsr
        FUNCTION macCspTxIntIsr,021203H
        ARGFRAME XSTACK, 0, STACK
        ARGFRAME IOVERLAY, 0, STATIC
        ARGFRAME DOVERLAY, 0, STATIC
        LOCFRAME ISTACK, 2, STACK
        PUBLIC macCspTxPrepCsmaSlotted
        FUNCTION macCspTxPrepCsmaSlotted,021203H
        ARGFRAME XSTACK, 0, STACK
        LOCFRAME ISTACK, 2, STACK
        PUBLIC macCspTxPrepCsmaUnslotted
        FUNCTION macCspTxPrepCsmaUnslotted,021203H
        ARGFRAME XSTACK, 0, STACK
        LOCFRAME ISTACK, 2, STACK
        PUBLIC macCspTxPrepSlotted
        FUNCTION macCspTxPrepSlotted,021203H
        ARGFRAME XSTACK, 0, STACK
        LOCFRAME ISTACK, 2, STACK
        PUBLIC macCspTxRequestAckTimeoutCallback
        FUNCTION macCspTxRequestAckTimeoutCallback,021203H
        ARGFRAME XSTACK, 0, STACK
        LOCFRAME XSTACK, 12, STACK
        PUBLIC macCspTxReset
        FUNCTION macCspTxReset,0203H
        ARGFRAME XSTACK, 0, STACK
        PUBLIC macCspTxStopIsr
        FUNCTION macCspTxStopIsr,021203H
        ARGFRAME XSTACK, 0, STACK
        LOCFRAME ISTACK, 2, STACK
        
        CFI Names cfiNames0
        CFI StackFrame CFA_SP SP DATA
        CFI StackFrame CFA_PSP16 PSP16 XDATA
        CFI StackFrame CFA_XSP16 XSP16 XDATA
        CFI StaticOverlayFrame CFA_IOVERLAY IOVERLAY
        CFI StaticOverlayFrame CFA_DOVERLAY DOVERLAY
        CFI Resource `PSW.CY`:1, `B.BR0`:1, `B.BR1`:1, `B.BR2`:1, `B.BR3`:1
        CFI Resource `B.BR4`:1, `B.BR5`:1, `B.BR6`:1, `B.BR7`:1, `VB.BR8`:1
        CFI Resource `VB.BR9`:1, `VB.BR10`:1, `VB.BR11`:1, `VB.BR12`:1
        CFI Resource `VB.BR13`:1, `VB.BR14`:1, `VB.BR15`:1, VB:8, B:8, A:8
        CFI Resource PSW:8, DPL0:8, DPH0:8, R0:8, R1:8, R2:8, R3:8, R4:8, R5:8
        CFI Resource R6:8, R7:8, V0:8, V1:8, V2:8, V3:8, V4:8, V5:8, V6:8, V7:8
        CFI Resource SP:8, PSPH:8, PSPL:8, PSP16:16, XSPH:8, XSPL:8, XSP16:16
        CFI VirtualResource ?RET:24
        CFI Resource ?BRET_EXT:8
        CFI VirtualResource ?RET_HIGH:8, ?RET_LOW:8
        CFI ResourceParts PSP16 PSPH, PSPL
        CFI ResourceParts XSP16 XSPH, XSPL
        CFI ResourceParts ?RET ?BRET_EXT, ?RET_HIGH, ?RET_LOW
        CFI EndNames cfiNames0
        
        CFI Common cfiCommon0 Using cfiNames0
        CFI CodeAlign 1
        CFI DataAlign -1
        CFI ReturnAddress ?RET CODE
        CFI CFA_DOVERLAY Used
        CFI CFA_IOVERLAY Used
        CFI CFA_SP SP+-3
        CFI CFA_PSP16 PSP16+0
        CFI CFA_XSP16 XSP16+0
        CFI `PSW.CY` SameValue
        CFI `B.BR0` SameValue
        CFI `B.BR1` SameValue
        CFI `B.BR2` SameValue
        CFI `B.BR3` SameValue
        CFI `B.BR4` SameValue
        CFI `B.BR5` SameValue
        CFI `B.BR6` SameValue
        CFI `B.BR7` SameValue
        CFI `VB.BR8` SameValue
        CFI `VB.BR9` SameValue
        CFI `VB.BR10` SameValue
        CFI `VB.BR11` SameValue
        CFI `VB.BR12` SameValue
        CFI `VB.BR13` SameValue
        CFI `VB.BR14` SameValue
        CFI `VB.BR15` SameValue
        CFI VB SameValue
        CFI B Undefined
        CFI A Undefined
        CFI PSW SameValue
        CFI DPL0 SameValue
        CFI DPH0 SameValue
        CFI R0 Undefined
        CFI R1 Undefined
        CFI R2 Undefined
        CFI R3 Undefined
        CFI R4 Undefined
        CFI R5 Undefined
        CFI R6 SameValue
        CFI R7 SameValue
        CFI V0 SameValue
        CFI V1 SameValue
        CFI V2 SameValue
        CFI V3 SameValue
        CFI V4 SameValue
        CFI V5 SameValue
        CFI V6 SameValue
        CFI V7 SameValue
        CFI PSPH Undefined
        CFI PSPL Undefined
        CFI XSPH Undefined
        CFI XSPL Undefined
        CFI ?RET Concat
        CFI ?BRET_EXT Frame(CFA_SP, 3)
        CFI ?RET_HIGH Frame(CFA_SP, 2)
        CFI ?RET_LOW Frame(CFA_SP, 1)
        CFI EndCommon cfiCommon0
        
        
        CFI Common cfiCommon1 Using cfiNames0
        CFI CodeAlign 1
        CFI DataAlign -1
        CFI ReturnAddress ?RET CODE
        CFI CFA_DOVERLAY Used
        CFI CFA_IOVERLAY Used
        CFI CFA_SP SP+-2
        CFI CFA_PSP16 PSP16+0
        CFI CFA_XSP16 XSP16+0
        CFI `PSW.CY` SameValue
        CFI `B.BR0` SameValue
        CFI `B.BR1` SameValue
        CFI `B.BR2` SameValue
        CFI `B.BR3` SameValue
        CFI `B.BR4` SameValue
        CFI `B.BR5` SameValue
        CFI `B.BR6` SameValue
        CFI `B.BR7` SameValue
        CFI `VB.BR8` SameValue
        CFI `VB.BR9` SameValue
        CFI `VB.BR10` SameValue
        CFI `VB.BR11` SameValue
        CFI `VB.BR12` SameValue
        CFI `VB.BR13` SameValue
        CFI `VB.BR14` SameValue
        CFI `VB.BR15` SameValue
        CFI VB SameValue
        CFI B SameValue
        CFI A SameValue
        CFI PSW SameValue
        CFI DPL0 SameValue
        CFI DPH0 SameValue
        CFI R0 SameValue
        CFI R1 SameValue
        CFI R2 SameValue
        CFI R3 SameValue
        CFI R4 SameValue
        CFI R5 SameValue
        CFI R6 SameValue
        CFI R7 SameValue
        CFI V0 SameValue
        CFI V1 SameValue
        CFI V2 SameValue
        CFI V3 SameValue
        CFI V4 SameValue
        CFI V5 SameValue
        CFI V6 SameValue
        CFI V7 SameValue
        CFI PSPH Undefined
        CFI PSPL Undefined
        CFI XSPH Undefined
        CFI XSPL Undefined
        CFI ?RET Concat
        CFI ?BRET_EXT SameValue
        CFI ?RET_HIGH Frame(CFA_SP, 2)
        CFI ?RET_LOW Frame(CFA_SP, 1)
        CFI EndCommon cfiCommon1
        
halAssertHandler    SYMBOL "halAssertHandler"
macRxOn             SYMBOL "macRxOn"
macRxHardDisable    SYMBOL "macRxHardDisable"
macTxDoneCallback   SYMBOL "macTxDoneCallback"
macTxTimestampCallback SYMBOL "macTxTimestampCallback"
macTxChannelBusyCallback SYMBOL "macTxChannelBusyCallback"
macTxAckNotReceivedCallback SYMBOL "macTxAckNotReceivedCallback"
??halAssertHandler?relay SYMBOL "?relay", halAssertHandler
??macRxHardDisable?relay SYMBOL "?relay", macRxHardDisable
??macRxOn?relay     SYMBOL "?relay", macRxOn
??macTxAckNotReceivedCallback?relay SYMBOL "?relay", macTxAckNotReceivedCallback
??macTxChannelBusyCallback?relay SYMBOL "?relay", macTxChannelBusyCallback
??macTxDoneCallback?relay SYMBOL "?relay", macTxDoneCallback
??macTxTimestampCallback?relay SYMBOL "?relay", macTxTimestampCallback
macCspForceTxDoneIfPending SYMBOL "macCspForceTxDoneIfPending"
??macCspForceTxDoneIfPending?relay SYMBOL "?relay", macCspForceTxDoneIfPending
macCspTxCancelAckTimeoutCallback SYMBOL "macCspTxCancelAckTimeoutCallback"
??macCspTxCancelAckTimeoutCallback?relay SYMBOL "?relay", macCspTxCancelAckTimeoutCallback
macCspTxGoCsma      SYMBOL "macCspTxGoCsma"
??macCspTxGoCsma?relay SYMBOL "?relay", macCspTxGoCsma
macCspTxGoSlotted   SYMBOL "macCspTxGoSlotted"
??macCspTxGoSlotted?relay SYMBOL "?relay", macCspTxGoSlotted
macCspTxIntIsr      SYMBOL "macCspTxIntIsr"
??macCspTxIntIsr?relay SYMBOL "?relay", macCspTxIntIsr
macCspTxPrepCsmaSlotted SYMBOL "macCspTxPrepCsmaSlotted"
??macCspTxPrepCsmaSlotted?relay SYMBOL "?relay", macCspTxPrepCsmaSlotted
macCspTxPrepCsmaUnslotted SYMBOL "macCspTxPrepCsmaUnslotted"
??macCspTxPrepCsmaUnslotted?relay SYMBOL "?relay", macCspTxPrepCsmaUnslotted
macCspTxPrepSlotted SYMBOL "macCspTxPrepSlotted"
??macCspTxPrepSlotted?relay SYMBOL "?relay", macCspTxPrepSlotted
macCspTxRequestAckTimeoutCallback SYMBOL "macCspTxRequestAckTimeoutCallback"
??macCspTxRequestAckTimeoutCallback?relay SYMBOL "?relay", macCspTxRequestAckTimeoutCallback
macCspTxReset       SYMBOL "macCspTxReset"
??macCspTxReset?relay SYMBOL "?relay", macCspTxReset
macCspTxStopIsr     SYMBOL "macCspTxStopIsr"
??macCspTxStopIsr?relay SYMBOL "?relay", macCspTxStopIsr

        EXTERN halAssertHandler
        FUNCTION halAssertHandler,0202H
        ARGFRAME ISTACK, 2, STACK
        ARGFRAME PSTACK, 0, STACK
        ARGFRAME XSTACK, 12, STACK
        ARGFRAME IOVERLAY, 0, STATIC
        ARGFRAME DOVERLAY, 0, STATIC
        EXTERN macRxOn
        FUNCTION macRxOn,0202H
        ARGFRAME ISTACK, 2, STACK
        ARGFRAME PSTACK, 0, STACK
        ARGFRAME XSTACK, 0, STACK
        ARGFRAME IOVERLAY, 0, STATIC
        ARGFRAME DOVERLAY, 0, STATIC
        EXTERN macRxHardDisable
        FUNCTION macRxHardDisable,0202H
        ARGFRAME ISTACK, 0, STACK
        ARGFRAME PSTACK, 0, STACK
        ARGFRAME XSTACK, 9, STACK
        ARGFRAME IOVERLAY, 0, STATIC
        ARGFRAME DOVERLAY, 0, STATIC
        EXTERN macTxDoneCallback
        FUNCTION macTxDoneCallback,0202H
        ARGFRAME ISTACK, 2, STACK
        ARGFRAME PSTACK, 0, STACK
        ARGFRAME XSTACK, 0, STACK
        ARGFRAME IOVERLAY, 0, STATIC
        ARGFRAME DOVERLAY, 0, STATIC
        EXTERN macTxTimestampCallback
        FUNCTION macTxTimestampCallback,0202H
        ARGFRAME ISTACK, 2, STACK
        ARGFRAME PSTACK, 0, STACK
        ARGFRAME XSTACK, 0, STACK
        ARGFRAME IOVERLAY, 0, STATIC
        ARGFRAME DOVERLAY, 0, STATIC
        EXTERN macTxChannelBusyCallback
        FUNCTION macTxChannelBusyCallback,0202H
        ARGFRAME ISTACK, 2, STACK
        ARGFRAME PSTACK, 0, STACK
        ARGFRAME XSTACK, 0, STACK
        ARGFRAME IOVERLAY, 0, STATIC
        ARGFRAME DOVERLAY, 0, STATIC
        EXTERN macTxAckNotReceivedCallback
        FUNCTION macTxAckNotReceivedCallback,0202H
        ARGFRAME ISTACK, 2, STACK
        ARGFRAME PSTACK, 0, STACK
        ARGFRAME XSTACK, 0, STACK
        ARGFRAME IOVERLAY, 0, STATIC
        ARGFRAME DOVERLAY, 0, STATIC
        EXTERN ??halAssertHandler?relay
        FUNCTION ??halAssertHandler?relay,00H
        EXTERN ??macRxHardDisable?relay
        FUNCTION ??macRxHardDisable?relay,00H
        EXTERN ??macRxOn?relay
        FUNCTION ??macRxOn?relay,00H
        EXTERN ??macTxAckNotReceivedCallback?relay
        FUNCTION ??macTxAckNotReceivedCallback?relay,00H
        EXTERN ??macTxChannelBusyCallback?relay
        FUNCTION ??macTxChannelBusyCallback?relay,00H
        EXTERN ??macTxDoneCallback?relay
        FUNCTION ??macTxDoneCallback?relay,00H
        EXTERN ??macTxTimestampCallback?relay
        FUNCTION ??macTxTimestampCallback?relay,00H
        EXTERN macPib
        EXTERN macRxOnFlag
        EXTERN macTxCsmaBackoffDelay

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

        ASEGN SFR_AN:DATA:NOROOT,091H
// unsigned char volatile __sfr RFIM
RFIM:
        DS 1

        ASEGN SFR_AN:DATA:NOROOT,094H
// unsigned char volatile __sfr T2CMP
T2CMP:
        DS 1

        ASEGN SFR_AN:DATA:NOROOT,09bH
// unsigned char volatile __sfr S1CON
S1CON:
        DS 1

        ASEGN SFR_AN:DATA:NOROOT,0a1H
// unsigned char volatile __sfr T2OF0
T2OF0:
        DS 1

        ASEGN SFR_AN:DATA:NOROOT,0a6H
// unsigned char volatile __sfr T2TLD
T2TLD:
        DS 1

        ASEGN SFR_AN:DATA:NOROOT,0a7H
// unsigned char volatile __sfr T2THD
T2THD:
        DS 1

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

        ASEGN SFR_AN:DATA:NOROOT,0e1H
// unsigned char volatile __sfr RFST
RFST:
        DS 1

        ASEGN SFR_AN:DATA:NOROOT,0e9H
// unsigned char volatile __sfr RFIF
RFIF:
        DS 1
//   48 
//   49 /* high-level */
//   50 #include "mac_spec.h"
//   51 #include "mac_pib.h"
//   52 
//   53 /* exported low-level */
//   54 #include "mac_low_level.h"
//   55 
//   56 /* low-level specific */
//   57 #include "mac_csp_tx.h"
//   58 #include "mac_tx.h"
//   59 #include "mac_rx.h"
//   60 #include "mac_rx_onoff.h"
//   61 
//   62 /* target specific */
//   63 #include "mac_radio_defs.h"
//   64 
//   65 /* debug */
//   66 #include "mac_assert.h"
//   67 
//   68 
//   69 /* ------------------------------------------------------------------------------------------------
//   70  *                                   CSP Defines / Macros
//   71  * ------------------------------------------------------------------------------------------------
//   72  */
//   73 /* immediate strobe commands */
//   74 #define ISSTART     0xFE
//   75 #define ISSTOP      0xFF
//   76 
//   77 /* strobe processor instructions */
//   78 #define SKIP(s,c)   (0x00 | (((s) & 0x07) << 4) | ((c) & 0x0F))   /* skip 's' instructions if 'c' is true  */
//   79 #define WHILE(c)    SKIP(0,c)              /* pend while 'c' is true (derived instruction)        */
//   80 #define WAITW(w)    (0x80 | ((w) & 0x1F))  /* wait for 'w' number of MAC timer overflows          */
//   81 #define WEVENT      (0xB8)                 /* wait for MAC timer compare                          */
//   82 #define WAITX       (0xBB)                 /* wait for CPSX number of MAC timer overflows         */
//   83 #define LABEL       (0xBA)                 /* set next instruction as start of loop               */
//   84 #define RPT(c)      (0xA0 | ((c) & 0x0F))  /* if condition is true jump to last label             */
//   85 #define INT         (0xB9)                 /* assert IRQ_CSP_INT interrupt                        */
//   86 #define INCY        (0xBD)                 /* increment CSPY                                      */
//   87 #define INCMAXY(m)  (0xB0 | ((m) & 0x07))  /* increment CSPY but not above maximum value of 'm'   */
//   88 #define DECY        (0xBE)                 /* decrement CSPY                                      */
//   89 #define DECZ        (0xBF)                 /* decrement CSPZ                                      */
//   90 #define RANDXY      (0xBC)                 /* load the lower CSPY bits of CSPX with random value  */
//   91 
//   92 /* strobe processor command instructions */
//   93 #define SSTOP       (0xDF)    /* stop program execution                                      */
//   94 #define SNOP        (0xC0)    /* no operation                                                */
//   95 #define STXCALN     (0xC1)    /* enable and calibrate frequency synthesizer for TX           */
//   96 #define SRXON       (0xC2)    /* turn on receiver                                            */
//   97 #define STXON       (0xC3)    /* transmit after calibration                                  */
//   98 #define STXONCCA    (0xC4)    /* transmit after calibration if CCA indicates clear channel   */
//   99 #define SRFOFF      (0xC5)    /* turn off RX/TX                                              */
//  100 #define SFLUSHRX    (0xC6)    /* flush receive FIFO                                          */
//  101 #define SFLUSHTX    (0xC7)    /* flush transmit FIFO                                         */
//  102 #define SACK        (0xC8)    /* send ACK frame                                              */
//  103 #define SACKPEND    (0xC9)    /* send ACK frame with pending bit set                         */
//  104 
//  105 /* conditions for use with instructions SKIP and RPT */
//  106 #define C_CCA_IS_VALID        0x00
//  107 #define C_SFD_IS_ACTIVE       0x01
//  108 #define C_CPU_CTRL_IS_ON      0x02
//  109 #define C_END_INSTR_MEM       0x03
//  110 #define C_CSPX_IS_ZERO        0x04
//  111 #define C_CSPY_IS_ZERO        0x05
//  112 #define C_CSPZ_IS_ZERO        0x06
//  113 
//  114 /* negated conditions for use with instructions SKIP and RPT */
//  115 #define C_NEGATE(c)   ((c) | 0x08)
//  116 #define C_CCA_IS_INVALID      C_NEGATE(C_CCA_IS_VALID)
//  117 #define C_SFD_IS_INACTIVE     C_NEGATE(C_SFD_IS_ACTIVE)
//  118 #define C_CPU_CTRL_IS_OFF     C_NEGATE(C_CPU_CTRL_IS_ON)
//  119 #define C_NOT_END_INSTR_MEM   C_NEGATE(C_END_INSTR_MEM)
//  120 #define C_CSPX_IS_NON_ZERO    C_NEGATE(C_CSPX_IS_ZERO)
//  121 #define C_CSPY_IS_NON_ZERO    C_NEGATE(C_CSPY_IS_ZERO)
//  122 #define C_CSPZ_IS_NON_ZERO    C_NEGATE(C_CSPZ_IS_ZERO)
//  123 
//  124 
//  125 /* ------------------------------------------------------------------------------------------------
//  126  *                                         Defines
//  127  * ------------------------------------------------------------------------------------------------
//  128  */
//  129 
//  130 /* CSPZ return values from CSP program */
//  131 #define CSPZ_CODE_TX_DONE           0
//  132 #define CSPZ_CODE_CHANNEL_BUSY      1
//  133 #define CSPZ_CODE_TX_ACK_TIME_OUT   2
//  134 
//  135 
//  136 /* ------------------------------------------------------------------------------------------------
//  137  *                                          Macros
//  138  * ------------------------------------------------------------------------------------------------
//  139  */
//  140 #define CSP_STOP_AND_CLEAR_PROGRAM()          st( RFST = ISSTOP;  )
//  141 #define CSP_START_PROGRAM()                   st( RFST = ISSTART; )
//  142 
//  143 /*
//  144  *  These macros improve readability of using T2CMP in conjunction with WEVENT.
//  145  *
//  146  *  The timer2 compare, T2CMP, only compares one byte of the 16-bit timer register.
//  147  *  It is configurable and has been set to compare against the upper byte of the timer value.
//  148  *  The CSP instruction WEVENT waits for the timer value to be greater than or equal
//  149  *  the value of T2CMP.
//  150  *
//  151  *  Reading the timer value is done by reading the low byte first.  This latches the
//  152  *  high byte.  A trick with the ternary operator is used by a macro below to force a
//  153  *  read of the low byte when returning the value of the high byte.
//  154  *
//  155  *  CSP_WEVENT_SET_TRIGGER_NOW()      - sets the WEVENT trigger point at the current timer count
//  156  *  CSP_WEVENT_SET_TRIGGER_SYMBOLS(x) - sets the WEVENT trigger point in symbols
//  157  *  CSP_WEVENT_READ_COUNT_SYMBOLS()   - reads the current timer count in symbols
//  158  */
//  159 #define T2THD_TICKS_PER_SYMBOL                (MAC_RADIO_TIMER_TICKS_PER_SYMBOL() >> 8)
//  160 
//  161 #define CSP_WEVENT_SET_TRIGGER_NOW()          st( uint8 temp=T2TLD;  T2CMP = T2THD; )
//  162 #define CSP_WEVENT_SET_TRIGGER_SYMBOLS(x)     st( MAC_ASSERT(x <= MAC_A_UNIT_BACKOFF_PERIOD); \ 
//  163                                                   T2CMP = (x) * T2THD_TICKS_PER_SYMBOL; )
//  164 #define CSP_WEVENT_READ_COUNT_SYMBOLS()       (((T2TLD) ? T2THD : T2THD) / T2THD_TICKS_PER_SYMBOL)
//  165 
//  166 /*
//  167  *  Number of bits used for aligning a slotted transmit to the backoff count (plus
//  168  *  derived values).  There are restrictions on this value.  Compile time integrity
//  169  *  checks will catch an illegal setting of this value.  A full explanation accompanies
//  170  *  this compile time check (see bottom of this file).
//  171  */
//  172 #define SLOTTED_TX_MAX_BACKOFF_COUNTDOWN_NUM_BITS     4
//  173 #define SLOTTED_TX_MAX_BACKOFF_COUNTDOWN              (1 << SLOTTED_TX_MAX_BACKOFF_COUNTDOWN_NUM_BITS)
//  174 #define SLOTTED_TX_BACKOFF_COUNT_ALIGN_BIT_MASK       (SLOTTED_TX_MAX_BACKOFF_COUNTDOWN - 1)
//  175 
//  176 
//  177 
//  178 /* ------------------------------------------------------------------------------------------------
//  179  *                                     Local Programs
//  180  * ------------------------------------------------------------------------------------------------
//  181  */
//  182 static void cspPrepForTxProgram(void);
//  183 
//  184 
//  185 /**************************************************************************************************
//  186  * @fn          macCspTxReset
//  187  *
//  188  * @brief       Reset the CSP.  Immediately halts any running program.
//  189  *
//  190  * @param       none
//  191  *
//  192  * @return      none
//  193  **************************************************************************************************
//  194  */

        RSEG BANKED_CODE:CODE:NOROOT(0)
//  195 void macCspTxReset(void)
macCspTxReset:
        CFI Block cfiBlock0 Using cfiCommon0
        CFI Function macCspTxReset
//  196 {
        ; Saved register size: 0
        ; Auto size: 0
//  197   MAC_MCU_CSP_STOP_DISABLE_INTERRUPT();
        ANL     0x91,#0xfd
//  198   MAC_MCU_CSP_INT_DISABLE_INTERRUPT();
        ANL     0x91,#0xfe
        CFI EndBlock cfiBlock0
//  199   CSP_STOP_AND_CLEAR_PROGRAM();
        REQUIRE ?Subroutine2
        REQUIRE RFIM
        REQUIRE RFST
        ; // Fall through to label ?Subroutine2
//  200 }

        RSEG BANKED_CODE:CODE:NOROOT(0)
?Subroutine2:
        CFI Block cfiBlock1 Using cfiCommon0
        CFI NoFunction
        MOV     0xe1,#-0x1
        LJMP    ?BRET
        CFI EndBlock cfiBlock1
//  201 
//  202 
//  203 /*=================================================================================================
//  204  * @fn          cspPrepForTxProgram
//  205  *
//  206  * @brief       Prepare and initialize for transmit CSP program.
//  207  *              Call *before* loading the CSP program!
//  208  *
//  209  * @param       none
//  210  *
//  211  * @return      none
//  212  *=================================================================================================
//  213  */

        RSEG BANKED_CODE:CODE:NOROOT(0)
//  214 static void cspPrepForTxProgram(void)
cspPrepForTxProgram:
        CFI Block cfiBlock2 Using cfiCommon0
        CFI Function cspPrepForTxProgram
//  215 {
        FUNCALL cspPrepForTxProgram, halAssertHandler
        LOCFRAME ISTACK, 2, STACK
        LOCFRAME PSTACK, 0, STACK
        LOCFRAME XSTACK, 0, STACK
        LOCFRAME IOVERLAY, 0, STATIC
        LOCFRAME DOVERLAY, 0, STATIC
        ARGFRAME ISTACK, 2, STACK
        ARGFRAME PSTACK, 0, STACK
        ARGFRAME XSTACK, 0, STACK
        ARGFRAME IOVERLAY, 0, STATIC
        ARGFRAME DOVERLAY, 0, STATIC
        PUSH    DPL
        CFI DPL0 Frame(CFA_SP, 4)
        CFI CFA_SP SP+-4
        PUSH    DPH
        CFI DPH0 Frame(CFA_SP, 5)
        CFI CFA_SP SP+-5
        ; Saved register size: 2
        ; Auto size: 0
//  216   MAC_ASSERT(!(RFIM & IM_CSP_STOP)); /* already an active CSP program */
        MOV     A,0x91
        MOV     C,0xE0 /* A   */.1
        JNC     ??cspPrepForTxProgram_0
        ; Setup parameters for call to function halAssertHandler
        LCALL   ??halAssertHandler?relay
//  217 
//  218   /* set up parameters for CSP transmit program */
//  219   CSPZ = CSPZ_CODE_CHANNEL_BUSY;
??cspPrepForTxProgram_0:
        MOV     A,#0x1
        MOV     DPTR,#-0x20ec
        MOVX    @DPTR,A
//  220 
//  221   /* clear the currently loaded CSP, this generates a stop interrupt which must be cleared */
//  222   CSP_STOP_AND_CLEAR_PROGRAM();
        MOV     0xe1,#-0x1
//  223   MAC_MCU_CSP_STOP_CLEAR_INTERRUPT();
        MOV     C,0xa8.7
        CLR     A
        MOV     0xE0 /* A   */.0,C
        CLR     0xa8.7
        MOV     0xe9,#-0x3
        MOV     0x9b,#0x0
        MOV     0xe9,#-0x1
        MOV     C,0xE0 /* A   */.0
        MOV     0xa8.7,C
//  224   MAC_MCU_CSP_INT_CLEAR_INTERRUPT();
        MOV     C,0xa8.7
        CLR     A
        MOV     0xE0 /* A   */.0,C
        CLR     0xa8.7
        MOV     0xe9,#-0x2
        MOV     0x9b,#0x0
        MOV     0xe9,#-0x1
        MOV     C,0xE0 /* A   */.0
        MOV     0xa8.7,C
//  225 }
        SJMP    ??Subroutine1_1
        CFI EndBlock cfiBlock2
        REQUIRE RFIM
        REQUIRE S1CON
        REQUIRE _A_IEN0
        REQUIRE RFST
        REQUIRE RFIF
//  226 
//  227 
//  228 /**************************************************************************************************
//  229  * @fn          macCspTxPrepCsmaUnslotted
//  230  *
//  231  * @brief       Prepare CSP for "Unslotted CSMA" transmit.  Load CSP program and set CSP parameters.
//  232  *
//  233  * @param       none
//  234  *
//  235  * @return      none
//  236  **************************************************************************************************
//  237  */

        RSEG BANKED_CODE:CODE:NOROOT(0)
//  238 void macCspTxPrepCsmaUnslotted(void)
macCspTxPrepCsmaUnslotted:
        CFI Block cfiBlock3 Using cfiCommon0
        CFI Function macCspTxPrepCsmaUnslotted
//  239 {
        FUNCALL macCspTxPrepCsmaUnslotted, cspPrepForTxProgram
        LOCFRAME ISTACK, 2, STACK
        LOCFRAME PSTACK, 0, STACK
        LOCFRAME XSTACK, 0, STACK
        LOCFRAME IOVERLAY, 0, STATIC
        LOCFRAME DOVERLAY, 0, STATIC
        ARGFRAME ISTACK, 2, STACK
        ARGFRAME PSTACK, 0, STACK
        ARGFRAME XSTACK, 0, STACK
        ARGFRAME IOVERLAY, 0, STATIC
        ARGFRAME DOVERLAY, 0, STATIC
        PUSH    DPL
        CFI DPL0 Frame(CFA_SP, 4)
        CFI CFA_SP SP+-4
        PUSH    DPH
        CFI DPH0 Frame(CFA_SP, 5)
        CFI CFA_SP SP+-5
        ; Saved register size: 2
        ; Auto size: 0
//  240   cspPrepForTxProgram();
        ; Setup parameters for call to function cspPrepForTxProgram
        LCALL   ?Subroutine0 & 0xFFFF
//  241 
//  242   /*----------------------------------------------------------------------
//  243    *  Load CSP program :  Unslotted CSMA transmit 
//  244    */
//  245 
//  246   /*
//  247    *  Wait for X number of backoffs, then wait for intra-backoff count
//  248    *  to reach value set for WEVENT.
//  249    */
//  250   RFST = WAITX;
//  251   RFST = WEVENT;
??CrossCallReturnLabel_0:
        MOV     0xe1,#-0x48
//  252 
//  253   /* wait for one backoff to guarantee receiver has been on at least that long */
//  254   RFST = WAITW(1);
        MOV     0xe1,#-0x7f
//  255   RFST = WEVENT;
        MOV     0xe1,#-0x48
//  256   
//  257   /* sample CCA, if it fails exit from here, CSPZ indicates result */
//  258   RFST = SKIP(1, C_CCA_IS_VALID);
        SJMP    ?Subroutine1
        CFI EndBlock cfiBlock3
        REQUIRE RFST
//  259   RFST = SSTOP;
//  260   
//  261   /* CSMA has passed so transmit */
//  262   RFST = STXON;
//  263 
//  264   /*
//  265    *  If the SFD pin is high at this point, there was an RX-TX collision.
//  266    *  In other words, TXON was strobed while receiving.  The CSP variable
//  267    *  CSPY is decremented to indicate this happened.  The rest of the transmit
//  268    *  continues normally.
//  269    */
//  270   RFST = WHILE(C_SFD_IS_ACTIVE);
//  271   RFST = WHILE(C_SFD_IS_INACTIVE);
//  272 
//  273   /*
//  274    *  The INT instruction causes an interrupt to fire.  The ISR for this interrupt
//  275    *  handles the record the timestamp (which was just captured when SFD went high).
//  276    *  Decrement CSPZ at the last step to indicate transmit was successful.
//  277    */
//  278   RFST = INT;
//  279 
//  280   /*
//  281    *  Wait for SFD to go inactive which is the end of transmit.  Decrement CSPZ to indicate
//  282    *  the transmit was successful.
//  283    */
//  284   RFST = WHILE(C_SFD_IS_ACTIVE);
//  285   RFST = DECZ;
//  286 }
//  287 
//  288 
//  289 /**************************************************************************************************
//  290  * @fn          macCspTxPrepCsmaSlotted
//  291  *
//  292  * @brief       Prepare CSP for "Slotted CSMA" transmit.  Load CSP program and set CSP parameters.
//  293  *
//  294  * @param       none
//  295  *
//  296  * @return      none
//  297  **************************************************************************************************
//  298  */

        RSEG BANKED_CODE:CODE:NOROOT(0)
//  299 void macCspTxPrepCsmaSlotted(void)
macCspTxPrepCsmaSlotted:
        CFI Block cfiBlock4 Using cfiCommon0
        CFI Function macCspTxPrepCsmaSlotted
//  300 {
        FUNCALL macCspTxPrepCsmaSlotted, cspPrepForTxProgram
        LOCFRAME ISTACK, 2, STACK
        LOCFRAME PSTACK, 0, STACK
        LOCFRAME XSTACK, 0, STACK
        LOCFRAME IOVERLAY, 0, STATIC
        LOCFRAME DOVERLAY, 0, STATIC
        ARGFRAME ISTACK, 2, STACK
        ARGFRAME PSTACK, 0, STACK
        ARGFRAME XSTACK, 0, STACK
        ARGFRAME IOVERLAY, 0, STATIC
        ARGFRAME DOVERLAY, 0, STATIC
        PUSH    DPL
        CFI DPL0 Frame(CFA_SP, 4)
        CFI CFA_SP SP+-4
        PUSH    DPH
        CFI DPH0 Frame(CFA_SP, 5)
        CFI CFA_SP SP+-5
        ; Saved register size: 2
        ; Auto size: 0
//  301   cspPrepForTxProgram();
        ; Setup parameters for call to function cspPrepForTxProgram
        LCALL   ?Subroutine0 & 0xFFFF
//  302 
//  303   /*----------------------------------------------------------------------
//  304    *  Load CSP program :  Slotted CSMA transmit 
//  305    */
//  306   
//  307   /* wait for X number of backoffs */
//  308   RFST = WAITX;
//  309 
//  310   /* wait for one backoff to guarantee receiver has been on at least that long */
//  311   RFST = WAITW(1);
??CrossCallReturnLabel_1:
        MOV     0xe1,#-0x7f
//  312 
//  313   /* sample CCA, if it fails exit from here, CSPZ indicates result */
//  314   RFST = SKIP(1, C_CCA_IS_VALID);
        MOV     0xe1,#0x10
//  315   RFST = SSTOP;
        MOV     0xe1,#-0x21
//  316   
//  317   /* per CSMA in specification, wait one backoff */
//  318   RFST = WAITW(1);
        MOV     0xe1,#-0x7f
//  319   
//  320   /* sample CCA again, if it fails exit from here, CSPZ indicates result */
//  321   RFST = SKIP(1, C_CCA_IS_VALID);
        SJMP    ?Subroutine1
        CFI EndBlock cfiBlock4
        REQUIRE RFST
//  322   RFST = SSTOP;
//  323   
//  324   /* CSMA has passed so transmit */
//  325   RFST = STXON;
//  326 
//  327   /*
//  328    *  If the SFD pin is high at this point, there was an RX-TX collision.
//  329    *  In other words, TXON was strobed while receiving.  The CSP variable
//  330    *  CSPY is decremented to indicate this happened.  The rest of the transmit
//  331    *  continues normally.
//  332    */
//  333   RFST = WHILE(C_SFD_IS_ACTIVE);
//  334   RFST = WHILE(C_SFD_IS_INACTIVE);
//  335 
//  336   /*
//  337    *  The INT instruction causes an interrupt to fire.  The ISR for this interrupt
//  338    *  handles the record the timestamp (which was just captured when SFD went high).
//  339    *  Decrement CSPZ at the last step to indicate transmit was successful.
//  340    */
//  341   RFST = INT;
//  342 
//  343   /*
//  344    *  Wait for SFD to go inactive which is the end of transmit.  Decrement CSPZ to indicate
//  345    *  the transmit was successful.
//  346    */
//  347   RFST = WHILE(C_SFD_IS_ACTIVE);
//  348   RFST = DECZ;
//  349 }

        RSEG BANKED_CODE:CODE:NOROOT(0)
?Subroutine0:
        CFI Block cfiCond5 Using cfiCommon0
        CFI NoFunction
        CFI Conditional ??CrossCallReturnLabel_0
        CFI DPL0 Frame(CFA_SP, 4)
        CFI DPH0 Frame(CFA_SP, 5)
        CFI CFA_SP SP+-5
        CFI Block cfiCond6 Using cfiCommon0
        CFI (cfiCond6) NoFunction
        CFI (cfiCond6) Conditional ??CrossCallReturnLabel_1
        CFI (cfiCond6) DPL0 Frame(CFA_SP, 4)
        CFI (cfiCond6) DPH0 Frame(CFA_SP, 5)
        CFI (cfiCond6) CFA_SP SP+-5
        CFI Block cfiCond7 Using cfiCommon0
        CFI (cfiCond7) NoFunction
        CFI (cfiCond7) Conditional ??CrossCallReturnLabel_2
        CFI (cfiCond7) DPL0 Frame(CFA_SP, 4)
        CFI (cfiCond7) DPH0 Frame(CFA_SP, 5)
        CFI (cfiCond7) CFA_SP SP+-5
        CFI Block cfiPicker8 Using cfiCommon1
        CFI (cfiPicker8) NoFunction
        CFI (cfiPicker8) Picker
        LCALL   ??cspPrepForTxProgram?relay
        MOV     0xe1,#-0x45
        RET
        CFI EndBlock cfiCond5
        CFI EndBlock cfiCond6
        CFI EndBlock cfiCond7
        CFI EndBlock cfiPicker8
//  350 
//  351 
//  352 /**************************************************************************************************
//  353  * @fn          macCspTxGoCsma
//  354  *
//  355  * @brief       Run previously loaded CSP program for CSMA transmit.  Handles either
//  356  *              slotted or unslotted CSMA transmits.  When CSP program has finished,
//  357  *              an interrupt occurs and macCspTxStopIsr() is called.  This ISR will in
//  358  *              turn call macTxDoneCallback().
//  359  *
//  360  * @param       none
//  361  *
//  362  * @return      none
//  363  **************************************************************************************************
//  364  */

        RSEG BANKED_CODE:CODE:NOROOT(0)
//  365 void macCspTxGoCsma(void)
macCspTxGoCsma:
        CFI Block cfiBlock9 Using cfiCommon0
        CFI Function macCspTxGoCsma
//  366 {
        FUNCALL macCspTxGoCsma, macRxOn
        LOCFRAME ISTACK, 2, STACK
        LOCFRAME PSTACK, 0, STACK
        LOCFRAME XSTACK, 0, STACK
        LOCFRAME IOVERLAY, 0, STATIC
        LOCFRAME DOVERLAY, 0, STATIC
        ARGFRAME ISTACK, 2, STACK
        ARGFRAME PSTACK, 0, STACK
        ARGFRAME XSTACK, 0, STACK
        ARGFRAME IOVERLAY, 0, STATIC
        ARGFRAME DOVERLAY, 0, STATIC
        PUSH    DPL
        CFI DPL0 Frame(CFA_SP, 4)
        CFI CFA_SP SP+-4
        PUSH    DPH
        CFI DPH0 Frame(CFA_SP, 5)
        CFI CFA_SP SP+-5
        ; Saved register size: 2
        ; Auto size: 0
//  367   /*
//  368    *  Set CSPX with the countdown time of the CSMA delay.  Subtract one because there is
//  369    *  a built-in one backoff delay in the CSP program to make sure receiver has been 'on'
//  370    *  for at least one backoff.  Don't subtract though if CSPX is already zero!
//  371    */
//  372   CSPX = macTxCsmaBackoffDelay;
        MOV     DPTR,#macTxCsmaBackoffDelay
        MOVX    A,@DPTR
        MOV     DPTR,#-0x20ee
        MOVX    @DPTR,A
//  373   if (CSPX != 0)
        MOVX    A,@DPTR
        JZ      ??macCspTxGoCsma_0
//  374   {
//  375     CSPX--;
        MOVX    A,@DPTR
        DEC     A
        MOVX    @DPTR,A
//  376   }
//  377 
//  378   /*
//  379    *  Set WEVENT to trigger at the current value of the timer.  This allows
//  380    *  unslotted CSMA to transmit just a little bit sooner.
//  381    */
//  382   CSP_WEVENT_SET_TRIGGER_NOW();
??macCspTxGoCsma_0:
        MOV     A,0xa6
        MOV     0x94,0xa7
//  383 
//  384   /*
//  385    *  Enable interrupt that fires when CSP program stops.
//  386    *  Also enable interrupt that fires when INT instruction
//  387    *  is executed.
//  388    */
//  389   MAC_MCU_CSP_STOP_ENABLE_INTERRUPT();
        ORL     0x91,#0x2
//  390   MAC_MCU_CSP_INT_ENABLE_INTERRUPT();
        ORL     0x91,#0x1
//  391   
//  392   /*
//  393    *  Turn on the receiver if it is not already on.  Receiver must be 'on' for at
//  394    *  least one backoff before performing clear channel assessment (CCA).
//  395    */
//  396   macRxOn();
        ; Setup parameters for call to function macRxOn
        LCALL   ??macRxOn?relay
//  397 
//  398   /* start the CSP program */
//  399   CSP_START_PROGRAM();
        MOV     0xe1,#-0x2
//  400 }
        SJMP    ??Subroutine1_1
        CFI EndBlock cfiBlock9
        REQUIRE RFIM
        REQUIRE T2CMP
        REQUIRE T2TLD
        REQUIRE T2THD
        REQUIRE RFST

        RSEG BANKED_CODE:CODE:NOROOT(0)
?Subroutine1:
        CFI Block cfiBlock10 Using cfiCommon0
        CFI NoFunction
        CFI CFA_SP SP+-5
        CFI DPL0 Frame(CFA_SP, 4)
        CFI DPH0 Frame(CFA_SP, 5)
        MOV     0xe1,#0x10
        MOV     0xe1,#-0x21
??Subroutine1_0:
        MOV     0xe1,#-0x3d
        MOV     0xe1,#0x1
        MOV     0xe1,#0x9
        MOV     0xe1,#-0x47
        MOV     0xe1,#0x1
        MOV     0xe1,#-0x41
??Subroutine1_1:
        POP     DPH
        CFI CFA_SP SP+-4
        CFI DPH0 SameValue
        POP     DPL
        CFI CFA_SP SP+-3
        CFI DPL0 SameValue
        LJMP    ?BRET
        CFI EndBlock cfiBlock10
//  401 
//  402 
//  403 /**************************************************************************************************
//  404  * @fn          macCspTxPrepSlotted
//  405  *
//  406  * @brief       Prepare CSP for "Slotted" (non-CSMA) transmit.
//  407  *              Load CSP program and set CSP parameters.
//  408  *
//  409  * @param       none
//  410  *
//  411  * @return      none
//  412  **************************************************************************************************
//  413  */

        RSEG BANKED_CODE:CODE:NOROOT(0)
//  414 void macCspTxPrepSlotted(void)
macCspTxPrepSlotted:
        CFI Block cfiBlock11 Using cfiCommon0
        CFI Function macCspTxPrepSlotted
//  415 {
        FUNCALL macCspTxPrepSlotted, cspPrepForTxProgram
        LOCFRAME ISTACK, 2, STACK
        LOCFRAME PSTACK, 0, STACK
        LOCFRAME XSTACK, 0, STACK
        LOCFRAME IOVERLAY, 0, STATIC
        LOCFRAME DOVERLAY, 0, STATIC
        ARGFRAME ISTACK, 2, STACK
        ARGFRAME PSTACK, 0, STACK
        ARGFRAME XSTACK, 0, STACK
        ARGFRAME IOVERLAY, 0, STATIC
        ARGFRAME DOVERLAY, 0, STATIC
        PUSH    DPL
        CFI DPL0 Frame(CFA_SP, 4)
        CFI CFA_SP SP+-4
        PUSH    DPH
        CFI DPH0 Frame(CFA_SP, 5)
        CFI CFA_SP SP+-5
        ; Saved register size: 2
        ; Auto size: 0
//  416   cspPrepForTxProgram();
        ; Setup parameters for call to function cspPrepForTxProgram
        LCALL   ?Subroutine0 & 0xFFFF
//  417 
//  418   /*----------------------------------------------------------------------
//  419    *  Load CSP program :  Slotted transmit (no CSMA)
//  420    */
//  421   
//  422   /* wait for X number of backoffs */
//  423   RFST = WAITX;
//  424 
//  425   /* just transmit, no CSMA required */
//  426   RFST = STXON;
??CrossCallReturnLabel_2:
        SJMP    ??Subroutine1_0
        CFI EndBlock cfiBlock11
        REQUIRE RFST
//  427 
//  428   /*
//  429    *  If the SFD pin is high at this point, there was an RX-TX collision.
//  430    *  In other words, TXON was strobed while receiving.  The CSP variable
//  431    *  CSPY is decremented to indicate this happened.  The rest of the transmit
//  432    *  continues normally.
//  433    */
//  434   RFST = WHILE(C_SFD_IS_ACTIVE);
//  435   RFST = WHILE(C_SFD_IS_INACTIVE);
//  436   
//  437   /*
//  438    *  The INT instruction causes an interrupt to fire.  The ISR for this interrupt
//  439    *  handles the record the timestamp (which was just captured when SFD went high).
//  440    *  Decrement CSPZ at the last step to indicate transmit was successful.
//  441    */
//  442   RFST = INT;
//  443 
//  444   /*
//  445    *  Wait for SFD to go inactive which is the end of transmit.  Decrement CSPZ to indicate
//  446    *  the transmit was successful.
//  447    */
//  448   RFST = WHILE(C_SFD_IS_ACTIVE);
//  449   RFST = DECZ;
//  450 }
//  451 
//  452 
//  453 /**************************************************************************************************
//  454  * @fn          macCspTxGoSlotted
//  455  *
//  456  * @brief       Run previously loaded CSP program for non-CSMA slotted transmit.   When CSP
//  457  *              program has finished, an interrupt occurs and macCspTxStopIsr() is called.
//  458  *              This ISR will in turn call macTxDoneCallback().
//  459  *
//  460  * @param       none
//  461  *
//  462  * @return      none
//  463  **************************************************************************************************
//  464  */

        RSEG BANKED_CODE:CODE:NOROOT(0)
//  465 void macCspTxGoSlotted(void)
macCspTxGoSlotted:
        CFI Block cfiBlock12 Using cfiCommon0
        CFI Function macCspTxGoSlotted
//  466 {
        FUNCALL macCspTxGoSlotted, macRxHardDisable
        LOCFRAME ISTACK, 0, STACK
        LOCFRAME PSTACK, 0, STACK
        LOCFRAME XSTACK, 9, STACK
        LOCFRAME IOVERLAY, 0, STATIC
        LOCFRAME DOVERLAY, 0, STATIC
        ARGFRAME ISTACK, 0, STACK
        ARGFRAME PSTACK, 0, STACK
        ARGFRAME XSTACK, 9, STACK
        ARGFRAME IOVERLAY, 0, STATIC
        ARGFRAME DOVERLAY, 0, STATIC
        MOV     A,#-0x9
        LCALL   ?BANKED_ENTER_XDATA
        CFI DPH0 load(1, XDATA, add(CFA_XSP16, literal(-1)))
        CFI DPL0 load(1, XDATA, add(CFA_XSP16, literal(-2)))
        CFI ?BRET_EXT load(1, XDATA, add(CFA_XSP16, literal(-3)))
        CFI ?RET_HIGH load(1, XDATA, add(CFA_XSP16, literal(-4)))
        CFI ?RET_LOW load(1, XDATA, add(CFA_XSP16, literal(-5)))
        CFI R7 load(1, XDATA, add(CFA_XSP16, literal(-6)))
        CFI V0 load(1, XDATA, add(CFA_XSP16, literal(-7)))
        CFI VB load(1, XDATA, add(CFA_XSP16, literal(-8)))
        CFI R6 load(1, XDATA, add(CFA_XSP16, literal(-9)))
        CFI CFA_SP SP+0
        CFI CFA_XSP16 add(XSP16, 9)
        ; Saved register size: 9
        ; Auto size: 0
//  467   halIntState_t  s;
//  468   uint8 lowByteOfBackoffCount;
//  469   uint8 backoffCountdown;
//  470   
//  471   /*
//  472    *  Enable interrupt that fires when CSP program stops.
//  473    *  Also enable interrupt that fires when INT instruction
//  474    *  is executed.
//  475    */
//  476   MAC_MCU_CSP_STOP_ENABLE_INTERRUPT();
        ORL     0x91,#0x2
//  477   MAC_MCU_CSP_INT_ENABLE_INTERRUPT();
        ORL     0x91,#0x1
//  478 
//  479   /* critical section needed for timer accesses */
//  480   HAL_ENTER_CRITICAL_SECTION(s);
        MOV     C,0xa8.7
        CLR     A
        MOV     0xE0 /* A   */.0,C
        MOV     R6,A
        CLR     0xa8.7
//  481 
//  482   /* store lowest byte of backoff count (same as lowest byte of overflow count) */
//  483   lowByteOfBackoffCount = T2OF0;
        MOV     A,0xa1
        MOV     R7,A
//  484 
//  485   /*
//  486    *  Compute the number of backoffs until time to strobe transmit.  The strobe should
//  487    *  occur one backoff before the SFD pin is expected to go high.  So, the forumla for the
//  488    *  countdown value is to determine when the lower bits would rollover and become zero,
//  489    *  and then subtract one.
//  490    */
//  491   backoffCountdown = SLOTTED_TX_MAX_BACKOFF_COUNTDOWN - (lowByteOfBackoffCount & SLOTTED_TX_BACKOFF_COUNT_ALIGN_BIT_MASK) - 1;
        MOV     A,#0xf
        ANL     A,R7
        MOV     R2,A
        MOV     A,#0xf
        CLR     C
        SUBB    A,R2
        MOV     ?V0 + 0,A
//  492   
//  493   /*
//  494    *  Store backoff countdown value into CSPX.
//  495    *
//  496    *  Note: it is OK if this value is zero.  The WAITX instruction at the top of the
//  497    *  CSP program will immediately continue if CSPX is zero when executed.  However,
//  498    *  if the countdown is zero, it means the transmit function was not called early
//  499    *  enough for a properly timed slotted transmit.  The transmit will be late.
//  500    */
//  501   CSPX = backoffCountdown;
        MOV     DPTR,#-0x20ee
        MOVX    @DPTR,A
//  502 
//  503   /* Disable Rx and flush RXFIFO due to chip bug #1546 */
//  504   macRxHardDisable();
        ; Setup parameters for call to function macRxHardDisable
        LCALL   ??macRxHardDisable?relay
//  505 
//  506   /*
//  507    *  The receiver will be turned on during CSP execution, guaranteed.
//  508    *  Since it is not possible to update C variables within the CSP,
//  509    *  the new "on" state of the receiver must be set a little early
//  510    *  here before the CSP is started.
//  511    */
//  512   MAC_RX_WAS_FORCED_ON();
        MOV     A,#0x1
        MOV     DPTR,#macRxOnFlag
        MOVX    @DPTR,A
//  513 
//  514   /* start the CSP program */
//  515   CSP_START_PROGRAM();
        MOV     0xe1,#-0x2
//  516   
//  517   /*
//  518    *  If the previous stored low byte of the backoff count is no longer equal to
//  519    *  the current value, a rollover has occurred.  This means the backoff countdown
//  520    *  stored in CSPX may not be correct.
//  521    *
//  522    *  In this case, the value of CSPX is reloaded to reflect the correct backoff
//  523    *  countdown value (this is one less than what was just used as a rollover has
//  524    *  occurred).  Since it is certain a rollover *just* occurred, there is no danger
//  525    *  of another rollover occurring.  This means the value written to CSPX is guaranteed
//  526    *  to be accurate.
//  527    *
//  528    *  Also, the logic below ensures that the value written to CSPX is at least one.
//  529    *  This is needed for correct operation of the WAITX instruction.  As with an
//  530    *  initial backoff countdown value of zero, if this case does occur, it means the
//  531    *  transmit function was not called early enough for a properly timed slotted transmit.
//  532    *  The transmit will be late.
//  533    *
//  534    *  Finally, worth noting, writes to CSPX may not work if the CSP is executing the WAITX
//  535    *  instruction and a timer rollover occurs.  In this case, however, there is no possibility
//  536    *  of that happening.  If CSPX is updated here, a rollover has just occurred so a
//  537    *  collision is not possible (still within a critical section here too).
//  538    */
//  539   if ((lowByteOfBackoffCount != T2OF0) && (backoffCountdown > 1))
        MOV     A,0xa1
        XRL     A,R7
        JZ      ??macCspTxGoSlotted_0
        MOV     A,?V0 + 0
        CLR     C
        SUBB    A,#0x2
        JC      ??macCspTxGoSlotted_0
//  540   {
//  541     CSPX = backoffCountdown - 1;
        MOV     A,#-0x1
        ADD     A,?V0 + 0
        MOV     DPTR,#-0x20ee
        MOVX    @DPTR,A
//  542   }
//  543   
//  544   HAL_EXIT_CRITICAL_SECTION(s);
??macCspTxGoSlotted_0:
        MOV     A,R6
        MOV     C,0xE0 /* A   */.0
        MOV     0xa8.7,C
//  545 }
        MOV     R7,#0x1
        LJMP    ?BANKED_LEAVE_XDATA
        CFI EndBlock cfiBlock12
        REQUIRE RFIM
        REQUIRE T2OF0
        REQUIRE _A_IEN0
        REQUIRE RFST
//  546 
//  547 
//  548 /**************************************************************************************************
//  549  * @fn          macCspForceTxDoneIfPending
//  550  *
//  551  * @brief       The function clears out any pending TX done logic.  Used by receive logic
//  552  *              to make sure its ISR does not prevent transmit from completing in a reasonable
//  553  *              amount of time.
//  554  *
//  555  * @param       none
//  556  *
//  557  * @return      none
//  558  **************************************************************************************************
//  559  */

        RSEG BANKED_CODE:CODE:NOROOT(0)
//  560 void macCspForceTxDoneIfPending(void)
macCspForceTxDoneIfPending:
        CFI Block cfiBlock13 Using cfiCommon0
        CFI Function macCspForceTxDoneIfPending
//  561 {
        FUNCALL macCspForceTxDoneIfPending, macCspTxIntIsr
        LOCFRAME ISTACK, 2, STACK
        LOCFRAME PSTACK, 0, STACK
        LOCFRAME XSTACK, 0, STACK
        LOCFRAME IOVERLAY, 0, STATIC
        LOCFRAME DOVERLAY, 0, STATIC
        ARGFRAME ISTACK, 2, STACK
        ARGFRAME PSTACK, 0, STACK
        ARGFRAME XSTACK, 0, STACK
        ARGFRAME IOVERLAY, 0, STATIC
        ARGFRAME DOVERLAY, 0, STATIC
        FUNCALL macCspForceTxDoneIfPending, macTxDoneCallback
        LOCFRAME ISTACK, 2, STACK
        LOCFRAME PSTACK, 0, STACK
        LOCFRAME XSTACK, 0, STACK
        LOCFRAME IOVERLAY, 0, STATIC
        LOCFRAME DOVERLAY, 0, STATIC
        ARGFRAME ISTACK, 2, STACK
        ARGFRAME PSTACK, 0, STACK
        ARGFRAME XSTACK, 0, STACK
        ARGFRAME IOVERLAY, 0, STATIC
        ARGFRAME DOVERLAY, 0, STATIC
        PUSH    DPL
        CFI DPL0 Frame(CFA_SP, 4)
        CFI CFA_SP SP+-4
        PUSH    DPH
        CFI DPH0 Frame(CFA_SP, 5)
        CFI CFA_SP SP+-5
        ; Saved register size: 2
        ; Auto size: 0
//  562   if ((CSPZ == CSPZ_CODE_TX_DONE) &&  MAC_MCU_CSP_STOP_INTERRUPT_IS_ENABLED())
        MOV     DPTR,#-0x20ec
        MOVX    A,@DPTR
        JNZ     ??macCspForceTxDoneIfPending_0
        MOV     A,0x91
        MOV     C,0xE0 /* A   */.1
        JNC     ??macCspForceTxDoneIfPending_0
//  563   {
//  564     MAC_MCU_CSP_STOP_DISABLE_INTERRUPT();
        ANL     0x91,#0xfd
//  565     if (MAC_MCU_CSP_INT_INTERRUPT_IS_ENABLED())
        MOV     A,0x91
        MOV     C,0xE0 /* A   */.0
        JNC     ??macCspForceTxDoneIfPending_1
//  566     {
//  567       macCspTxIntIsr();
        ; Setup parameters for call to function macCspTxIntIsr
        LCALL   ??macCspTxIntIsr?relay
//  568     }
//  569     macTxDoneCallback();
??macCspForceTxDoneIfPending_1:
        ; Setup parameters for call to function macTxDoneCallback
        LCALL   ??macTxDoneCallback?relay
//  570   }
//  571 }
??macCspForceTxDoneIfPending_0:
        SJMP    ??Subroutine1_1
        CFI EndBlock cfiBlock13
        REQUIRE RFIM
//  572 
//  573 
//  574 /**************************************************************************************************
//  575  * @fn          macCspTxRequestAckTimeoutCallback
//  576  *
//  577  * @brief       Requests a callback after the ACK timeout period has expired.  At that point,
//  578  *              the function macTxAckTimeoutCallback() is called via an interrupt.
//  579  *
//  580  * @param       none
//  581  *
//  582  * @return      none
//  583  **************************************************************************************************
//  584  */

        RSEG BANKED_CODE:CODE:NOROOT(0)
//  585 void macCspTxRequestAckTimeoutCallback(void)
macCspTxRequestAckTimeoutCallback:
        CFI Block cfiBlock14 Using cfiCommon0
        CFI Function macCspTxRequestAckTimeoutCallback
//  586 {
        FUNCALL macCspTxRequestAckTimeoutCallback, halAssertHandler
        LOCFRAME ISTACK, 0, STACK
        LOCFRAME PSTACK, 0, STACK
        LOCFRAME XSTACK, 12, STACK
        LOCFRAME IOVERLAY, 0, STATIC
        LOCFRAME DOVERLAY, 0, STATIC
        ARGFRAME ISTACK, 0, STACK
        ARGFRAME PSTACK, 0, STACK
        ARGFRAME XSTACK, 12, STACK
        ARGFRAME IOVERLAY, 0, STATIC
        ARGFRAME DOVERLAY, 0, STATIC
        FUNCALL macCspTxRequestAckTimeoutCallback, halAssertHandler
        LOCFRAME ISTACK, 0, STACK
        LOCFRAME PSTACK, 0, STACK
        LOCFRAME XSTACK, 12, STACK
        LOCFRAME IOVERLAY, 0, STATIC
        LOCFRAME DOVERLAY, 0, STATIC
        ARGFRAME ISTACK, 0, STACK
        ARGFRAME PSTACK, 0, STACK
        ARGFRAME XSTACK, 12, STACK
        ARGFRAME IOVERLAY, 0, STATIC
        ARGFRAME DOVERLAY, 0, STATIC
        FUNCALL macCspTxRequestAckTimeoutCallback, halAssertHandler
        LOCFRAME ISTACK, 0, STACK
        LOCFRAME PSTACK, 0, STACK
        LOCFRAME XSTACK, 12, STACK
        LOCFRAME IOVERLAY, 0, STATIC
        LOCFRAME DOVERLAY, 0, STATIC
        ARGFRAME ISTACK, 0, STACK
        ARGFRAME PSTACK, 0, STACK
        ARGFRAME XSTACK, 12, STACK
        ARGFRAME IOVERLAY, 0, STATIC
        ARGFRAME DOVERLAY, 0, STATIC
        MOV     A,#-0xc
        LCALL   ?BANKED_ENTER_XDATA
        CFI DPH0 load(1, XDATA, add(CFA_XSP16, literal(-1)))
        CFI DPL0 load(1, XDATA, add(CFA_XSP16, literal(-2)))
        CFI ?BRET_EXT load(1, XDATA, add(CFA_XSP16, literal(-3)))
        CFI ?RET_HIGH load(1, XDATA, add(CFA_XSP16, literal(-4)))
        CFI ?RET_LOW load(1, XDATA, add(CFA_XSP16, literal(-5)))
        CFI R7 load(1, XDATA, add(CFA_XSP16, literal(-6)))
        CFI V3 load(1, XDATA, add(CFA_XSP16, literal(-7)))
        CFI V2 load(1, XDATA, add(CFA_XSP16, literal(-8)))
        CFI V1 load(1, XDATA, add(CFA_XSP16, literal(-9)))
        CFI V0 load(1, XDATA, add(CFA_XSP16, literal(-10)))
        CFI VB load(1, XDATA, add(CFA_XSP16, literal(-11)))
        CFI R6 load(1, XDATA, add(CFA_XSP16, literal(-12)))
        CFI CFA_SP SP+0
        CFI CFA_XSP16 add(XSP16, 12)
        ; Saved register size: 12
        ; Auto size: 0
//  587   uint8 startSymbol;
//  588   uint8 symbols;
//  589   uint8 rollovers;
//  590 
//  591   MAC_ASSERT(!(RFIM & IM_CSP_STOP)); /* already an active CSP program */
        MOV     A,0x91
        MOV     C,0xE0 /* A   */.1
        JNC     ??macCspTxRequestAckTimeoutCallback_0
        ; Setup parameters for call to function halAssertHandler
        LCALL   ??halAssertHandler?relay
//  592 
//  593   /* record current symbol count */
//  594   startSymbol = CSP_WEVENT_READ_COUNT_SYMBOLS();
??macCspTxRequestAckTimeoutCallback_0:
        MOV     A,0xa6
        MOV     R2,0xa7
        MOV     DPL,R2
        MOV     R0,DPL
        MOV     R1,#0x0
        MOV     R2,#0x2
        MOV     R3,#0x0
        LCALL   ?S_DIV_MOD
        MOV     A,R0
        MOV     ?V0 + 0,A
//  595 
//  596   /* set symbol timeout from PIB */
//  597   symbols = macPib.ackWaitDuration;
        MOV     DPTR,#macPib
        MOVX    A,@DPTR
        MOV     R6,A
//  598 
//  599   /* make sure delay value is not too small for logic to handle */
//  600   MAC_ASSERT(symbols > MAC_A_UNIT_BACKOFF_PERIOD);  /* symbols timeout period must be great than a backoff */
        CLR     C
        SUBB    A,#0x15
        JNC     ??macCspTxRequestAckTimeoutCallback_1
        ; Setup parameters for call to function halAssertHandler
        LCALL   ??halAssertHandler?relay
//  601 
//  602   /* subtract out symbols left in current backoff period */
//  603   symbols = symbols - (MAC_A_UNIT_BACKOFF_PERIOD - startSymbol);
??macCspTxRequestAckTimeoutCallback_1:
        MOV     A,#-0x14
        ADD     A,?V0 + 0
        ADD     A,R6
        MOV     R6,A
//  604 
//  605   /* calculate rollovers needed for remaining symbols */
//  606   rollovers = symbols / MAC_A_UNIT_BACKOFF_PERIOD;
        MOV     B,#0x14
        DIV     AB
        MOV     R7,A
//  607 
//  608   /* calculate symbols that still need counted after last rollover */
//  609   symbols = symbols - (rollovers * MAC_A_UNIT_BACKOFF_PERIOD);
        MOV     B,#0x14
        MUL     AB
        XCH     A,R6
        SUBB    A,R6
        MOV     R6,A
//  610 
//  611   /* add one to rollovers to account for symbols remaining in the current backoff period */
//  612   rollovers++;
        INC     R7
//  613 
//  614   /* set up parameters for CSP program */
//  615   CSPZ = CSPZ_CODE_TX_ACK_TIME_OUT;
        MOV     A,#0x2
        MOV     DPTR,#-0x20ec
        MOVX    @DPTR,A
//  616   CSPX = rollovers;
        MOV     A,R7
        MOV     DPTR,#-0x20ee
        MOVX    @DPTR,A
//  617   CSP_WEVENT_SET_TRIGGER_SYMBOLS(symbols);
        MOV     A,R6
        CLR     C
        SUBB    A,#0x15
        JC      ??macCspTxRequestAckTimeoutCallback_2
        ; Setup parameters for call to function halAssertHandler
        LCALL   ??halAssertHandler?relay
??macCspTxRequestAckTimeoutCallback_2:
        MOV     A,R6
        CLR     C
        RLC     A
        MOV     0x94,A
//  618 
//  619   /* clear the currently loaded CSP, this generates a stop interrupt which must be cleared */
//  620   CSP_STOP_AND_CLEAR_PROGRAM();
        MOV     0xe1,#-0x1
//  621   MAC_MCU_CSP_STOP_CLEAR_INTERRUPT();
        MOV     C,0xa8.7
        CLR     A
        MOV     0xE0 /* A   */.0,C
        CLR     0xa8.7
        MOV     0xe9,#-0x3
        MOV     0x9b,#0x0
        MOV     0xe9,#-0x1
        MOV     C,0xE0 /* A   */.0
        MOV     0xa8.7,C
//  622   
//  623   /*--------------------------
//  624    * load CSP program
//  625    */
//  626   RFST = WAITX;
        MOV     0xe1,#-0x45
//  627   RFST = WEVENT;
        MOV     0xe1,#-0x48
//  628   /*--------------------------
//  629    */
//  630   
//  631   /* run CSP program */
//  632   MAC_MCU_CSP_STOP_ENABLE_INTERRUPT();
        ORL     0x91,#0x2
//  633   CSP_START_PROGRAM();
        MOV     0xe1,#-0x2
//  634 
//  635   /*
//  636    *  For bullet proof operation, must account for the boundary condition
//  637    *  where a rollover occurs after count was read but before CSP program
//  638    *  was started.
//  639    *
//  640    *  If current symbol count is less that the symbol count recorded at the
//  641    *  start of this function, a rollover has occurred.
//  642    */
//  643   if (CSP_WEVENT_READ_COUNT_SYMBOLS() < startSymbol)
        MOV     A,0xa6
        MOV     R2,0xa7
        MOV     DPL,R2
        MOV     R0,DPL
        MOV     R1,#0x0
        MOV     R2,#0x2
        MOV     R3,#0x0
        LCALL   ?S_DIV_MOD
        CLR     C
        MOV     A,R0
        SUBB    A,?V0 + 0
        MOV     A,R1
        SUBB    A,#0x0
        MOV     C,0xD0 /* PSW */.2
        XRL     A,PSW
        RLC     A
        JNC     ??macCspTxRequestAckTimeoutCallback_3
//  644   {
//  645     /* a rollover has occurred, make sure it was accounted for */
//  646     if (CSPX == rollovers)
        MOV     DPTR,#-0x20ee
        MOVX    A,@DPTR
        XRL     A,R7
        JNZ     ??macCspTxRequestAckTimeoutCallback_3
//  647     {
//  648       /*
//  649        *  Rollover event missed, manually decrement CSPX to adjust.
//  650        *
//  651        *  Note : there is a very small chance that CSPX does not
//  652        *  get decremented.  This would occur if CSPX were written
//  653        *  at exactly the same time a timer overflow is occurring (which
//  654        *  causes the CSP instruction WAITX to decrement CSPX).  This
//  655        *  would be extremely rare, but if it does happen, the only
//  656        *  consequence is that the ACK timeout period is extended
//  657        *  by one backoff.
//  658        */
//  659       CSPX--;
        MOVX    A,@DPTR
        DEC     A
        MOVX    @DPTR,A
//  660     }
//  661   }
//  662 }
??macCspTxRequestAckTimeoutCallback_3:
        MOV     R7,#0x4
        LJMP    ?BANKED_LEAVE_XDATA
        CFI EndBlock cfiBlock14
        REQUIRE RFIM
        REQUIRE T2CMP
        REQUIRE S1CON
        REQUIRE T2TLD
        REQUIRE T2THD
        REQUIRE _A_IEN0
        REQUIRE RFST
        REQUIRE RFIF
//  663 
//  664 
//  665 /**************************************************************************************************
//  666  * @fn          macCspTxCancelAckTimeoutCallback
//  667  *
//  668  * @brief       Cancels previous request for ACK timeout callback.
//  669  *
//  670  * @param       none
//  671  *
//  672  * @return      none
//  673  **************************************************************************************************
//  674  */

        RSEG BANKED_CODE:CODE:NOROOT(0)
//  675 void macCspTxCancelAckTimeoutCallback(void)
macCspTxCancelAckTimeoutCallback:
        CFI Block cfiBlock15 Using cfiCommon0
        CFI Function macCspTxCancelAckTimeoutCallback
//  676 {
        ; Saved register size: 0
        ; Auto size: 0
//  677   MAC_MCU_CSP_STOP_DISABLE_INTERRUPT();
        ANL     0x91,#0xfd
//  678   CSP_STOP_AND_CLEAR_PROGRAM();
        LJMP    ?Subroutine2 & 0xFFFF
        CFI EndBlock cfiBlock15
        REQUIRE RFIM
        REQUIRE RFST
//  679 }
//  680 
//  681 
//  682 /**************************************************************************************************
//  683  * @fn          macCspTxIntIsr
//  684  *
//  685  * @brief       Interrupt service routine for handling INT type interrupts from CSP.
//  686  *              This interrupt happens when the CSP instruction INT is executed.  It occurs
//  687  *              once the SFD signal goes high indicating that transmit has successfully
//  688  *              started.  The timer value has been captured at this point and timestamp
//  689  *              can be stored.
//  690  *
//  691  * @param       none
//  692  *
//  693  * @return      none
//  694  **************************************************************************************************
//  695  */

        RSEG BANKED_CODE:CODE:NOROOT(0)
//  696 void macCspTxIntIsr(void)
macCspTxIntIsr:
        CFI Block cfiBlock16 Using cfiCommon0
        CFI Function macCspTxIntIsr
//  697 {
        FUNCALL macCspTxIntIsr, macTxTimestampCallback
        LOCFRAME ISTACK, 2, STACK
        LOCFRAME PSTACK, 0, STACK
        LOCFRAME XSTACK, 0, STACK
        LOCFRAME IOVERLAY, 0, STATIC
        LOCFRAME DOVERLAY, 0, STATIC
        ARGFRAME ISTACK, 2, STACK
        ARGFRAME PSTACK, 0, STACK
        ARGFRAME XSTACK, 0, STACK
        ARGFRAME IOVERLAY, 0, STATIC
        ARGFRAME DOVERLAY, 0, STATIC
        PUSH    DPL
        CFI DPL0 Frame(CFA_SP, 4)
        CFI CFA_SP SP+-4
        PUSH    DPH
        CFI DPH0 Frame(CFA_SP, 5)
        CFI CFA_SP SP+-5
        ; Saved register size: 2
        ; Auto size: 0
//  698   MAC_MCU_CSP_INT_DISABLE_INTERRUPT();
        ANL     0x91,#0xfe
//  699 
//  700   /* execute callback function that records transmit timestamp */
//  701   macTxTimestampCallback();
        ; Setup parameters for call to function macTxTimestampCallback
        LCALL   ??macTxTimestampCallback?relay
//  702 }
        LJMP    ??Subroutine1_1 & 0xFFFF
        CFI EndBlock cfiBlock16
        REQUIRE RFIM
//  703 
//  704 
//  705 /**************************************************************************************************
//  706  * @fn          macCspTxStopIsr
//  707  *
//  708  * @brief       Interrupt service routine for handling STOP type interrupts from CSP.
//  709  *              This interrupt occurs when the CSP program stops by 1) reaching the end of the
//  710  *              program, 2) executing SSTOP within the program, 3) executing immediate
//  711  *              instruction ISSTOP.
//  712  *
//  713  *              The value of CSPZ indicates if interrupt is being used for ACK timeout or
//  714  *              is the end of a transmit.
//  715  *
//  716  * @param       none
//  717  *
//  718  * @return      none
//  719  **************************************************************************************************
//  720  */

        RSEG BANKED_CODE:CODE:NOROOT(0)
//  721 void macCspTxStopIsr(void)
macCspTxStopIsr:
        CFI Block cfiBlock17 Using cfiCommon0
        CFI Function macCspTxStopIsr
//  722 {
        FUNCALL macCspTxStopIsr, macTxDoneCallback
        LOCFRAME ISTACK, 2, STACK
        LOCFRAME PSTACK, 0, STACK
        LOCFRAME XSTACK, 0, STACK
        LOCFRAME IOVERLAY, 0, STATIC
        LOCFRAME DOVERLAY, 0, STATIC
        ARGFRAME ISTACK, 2, STACK
        ARGFRAME PSTACK, 0, STACK
        ARGFRAME XSTACK, 0, STACK
        ARGFRAME IOVERLAY, 0, STATIC
        ARGFRAME DOVERLAY, 0, STATIC
        FUNCALL macCspTxStopIsr, macTxChannelBusyCallback
        LOCFRAME ISTACK, 2, STACK
        LOCFRAME PSTACK, 0, STACK
        LOCFRAME XSTACK, 0, STACK
        LOCFRAME IOVERLAY, 0, STATIC
        LOCFRAME DOVERLAY, 0, STATIC
        ARGFRAME ISTACK, 2, STACK
        ARGFRAME PSTACK, 0, STACK
        ARGFRAME XSTACK, 0, STACK
        ARGFRAME IOVERLAY, 0, STATIC
        ARGFRAME DOVERLAY, 0, STATIC
        FUNCALL macCspTxStopIsr, halAssertHandler
        LOCFRAME ISTACK, 2, STACK
        LOCFRAME PSTACK, 0, STACK
        LOCFRAME XSTACK, 0, STACK
        LOCFRAME IOVERLAY, 0, STATIC
        LOCFRAME DOVERLAY, 0, STATIC
        ARGFRAME ISTACK, 2, STACK
        ARGFRAME PSTACK, 0, STACK
        ARGFRAME XSTACK, 0, STACK
        ARGFRAME IOVERLAY, 0, STATIC
        ARGFRAME DOVERLAY, 0, STATIC
        FUNCALL macCspTxStopIsr, macTxAckNotReceivedCallback
        LOCFRAME ISTACK, 2, STACK
        LOCFRAME PSTACK, 0, STACK
        LOCFRAME XSTACK, 0, STACK
        LOCFRAME IOVERLAY, 0, STATIC
        LOCFRAME DOVERLAY, 0, STATIC
        ARGFRAME ISTACK, 2, STACK
        ARGFRAME PSTACK, 0, STACK
        ARGFRAME XSTACK, 0, STACK
        ARGFRAME IOVERLAY, 0, STATIC
        ARGFRAME DOVERLAY, 0, STATIC
        PUSH    DPL
        CFI DPL0 Frame(CFA_SP, 4)
        CFI CFA_SP SP+-4
        PUSH    DPH
        CFI DPH0 Frame(CFA_SP, 5)
        CFI CFA_SP SP+-5
        ; Saved register size: 2
        ; Auto size: 0
//  723   MAC_MCU_CSP_STOP_DISABLE_INTERRUPT();
        ANL     0x91,#0xfd
//  724 
//  725   if (CSPZ == CSPZ_CODE_TX_DONE)
        MOV     DPTR,#-0x20ec
        MOVX    A,@DPTR
        JNZ     ??macCspTxStopIsr_0
//  726   {
//  727     macTxDoneCallback();
        ; Setup parameters for call to function macTxDoneCallback
        LCALL   ??macTxDoneCallback?relay
        SJMP    ??macCspTxStopIsr_1
//  728   }
//  729   else if (CSPZ == CSPZ_CODE_CHANNEL_BUSY)
??macCspTxStopIsr_0:
        MOVX    A,@DPTR
        XRL     A,#0x1
        JNZ     ??macCspTxStopIsr_2
//  730   {
//  731     macTxChannelBusyCallback();
        ; Setup parameters for call to function macTxChannelBusyCallback
        LCALL   ??macTxChannelBusyCallback?relay
        SJMP    ??macCspTxStopIsr_1
//  732   }
//  733   else
//  734   {
//  735     MAC_ASSERT(CSPZ == CSPZ_CODE_TX_ACK_TIME_OUT); /* unexpected CSPZ value */
??macCspTxStopIsr_2:
        MOVX    A,@DPTR
        XRL     A,#0x2
        JZ      ??macCspTxStopIsr_3
        ; Setup parameters for call to function halAssertHandler
        LCALL   ??halAssertHandler?relay
//  736     macTxAckNotReceivedCallback();
??macCspTxStopIsr_3:
        ; Setup parameters for call to function macTxAckNotReceivedCallback
        LCALL   ??macTxAckNotReceivedCallback?relay
//  737   }
//  738 }
??macCspTxStopIsr_1:
        LJMP    ??Subroutine1_1 & 0xFFFF
        CFI EndBlock cfiBlock17
        REQUIRE RFIM

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

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

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

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

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

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

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

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

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

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

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

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

        END
//  739 
//  740 
//  741 
//  742 /**************************************************************************************************
//  743  *                                  Compile Time Integrity Checks
//  744  **************************************************************************************************
//  745  */
//  746 
//  747 #if ((CSPZ_CODE_TX_DONE != 0) || (CSPZ_CODE_CHANNEL_BUSY != 1))
//  748 #error "ERROR!  The CSPZ return values are very specific and tied into the actual CSP program."
//  749 #endif
//  750 
//  751 #if (MAC_TX_TYPE_SLOTTED_CSMA != 0)
//  752 #error "WARNING!  This define value changed.  It was selected for optimum performance."
//  753 #endif
//  754 
//  755 #if (T2THD_TICKS_PER_SYMBOL == 0)
//  756 #error "ERROR!  Timer compare will not work on high byte.  Clock speed is probably too slow."
//  757 #endif
//  758 
//  759 #define BACKOFFS_PER_BASE_SUPERFRAME  (MAC_A_BASE_SLOT_DURATION * MAC_A_NUM_SUPERFRAME_SLOTS)
//  760 #if (((BACKOFFS_PER_BASE_SUPERFRAME - 1) & SLOTTED_TX_BACKOFF_COUNT_ALIGN_BIT_MASK) != SLOTTED_TX_BACKOFF_COUNT_ALIGN_BIT_MASK)
//  761 #error "ERROR!  The specified bit mask for backoff alignment of slotted transmit does not rollover 'cleanly'."
//  762 /*
//  763  *  In other words, the backoff count for the number of superframe rolls over before the
//  764  *  specified number of bits rollover.  For example, if backoff count for a superframe
//  765  *  rolls over at 48, the binary number immediately before a rollover is 00101111.
//  766  *  In this case four bits would work as an alignment mask.  Five would not work though as
//  767  *  the lower five bits would go from 01111 to 00000 (instead of the value 10000 which
//  768  *  would be expected) because it a new superframe is starting.
//  769  */
//  770 #endif
//  771 #if (SLOTTED_TX_MAX_BACKOFF_COUNTDOWN_NUM_BITS < 2)
//  772 #error "ERROR!  Not enough backoff countdown bits to be practical."
//  773 #endif
//  774 
//  775 
//  776 /**************************************************************************************************
//  777 */
// 
// 543 bytes in segment BANKED_CODE
//  72 bytes in segment BANK_RELAYS
//   9 bytes in segment SFR_AN
// 
// 615 bytes of CODE memory
//   0 bytes of DATA memory (+ 9 bytes shared)
//
//Errors: none
//Warnings: none
