⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mac_backoff_timer.s51

📁 用IAR开发的ZIGBEE网络路由例子
💻 S51
📖 第 1 页 / 共 5 页
字号:
        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
        
        EXTERN macMcuOverflowSetCount
        FUNCTION macMcuOverflowSetCount,0202H
        ARGFRAME XSTACK, 20, STACK
        EXTERN macMcuOrT2PEROF2
        FUNCTION macMcuOrT2PEROF2,0202H
        ARGFRAME XSTACK, 12, STACK
        EXTERN macMcuAndT2PEROF2
        FUNCTION macMcuAndT2PEROF2,0202H
        ARGFRAME ISTACK, 2, STACK
        EXTERN macMcuOverflowCount
        FUNCTION macMcuOverflowCount,0202H
        ARGFRAME XSTACK, 20, STACK
        EXTERN halAssertHandler
        FUNCTION halAssertHandler,0202H
        ARGFRAME XSTACK, 20, STACK
        EXTERN macMcuOverflowSetCompare
        FUNCTION macMcuOverflowSetCompare,0202H
        ARGFRAME XSTACK, 16, STACK
        EXTERN macMcuOverflowCapture
        FUNCTION macMcuOverflowCapture,0202H
        ARGFRAME XSTACK, 16, STACK
        EXTERN macCspForceTxDoneIfPending
        FUNCTION macCspForceTxDoneIfPending,0202H
        ARGFRAME XSTACK, 20, STACK
        EXTERN macBackoffTimerRolloverCallback
        FUNCTION macBackoffTimerRolloverCallback,0202H
        ARGFRAME XSTACK, 12, STACK
        EXTERN macBackoffTimerTriggerCallback
        FUNCTION macBackoffTimerTriggerCallback,0202H
        ARGFRAME XSTACK, 12, STACK
        EXTERN macTxActive

// C:\Texas Instruments\ZStack-1.4.2\Components\mac\low_level\srf03\mac_backoff_timer.c
//    1 /**************************************************************************************************
//    2     Filename:
//    3     Revised:        $Date: 2007-03-26 16:18:09 -0700 (Mon, 26 Mar 2007) $
//    4     Revision:       $Revision: 13860 $
//    5 
//    6     Description:
//    7 
//    8     Describe the purpose and contents of the file.
//    9 
//   10     Copyright (c) 2006 by Texas Instruments, Inc.
//   11     All Rights Reserved.  Permission to use, reproduce, copy, prepare
//   12     derivative works, modify, distribute, perform, display or sell this
//   13     software and/or its documentation for any purpose is prohibited
//   14     without the express written consent of Texas Instruments, Inc.
//   15 **************************************************************************************************/
//   16 
//   17 
//   18 
//   19 /* ------------------------------------------------------------------------------------------------
//   20  *                                           Includes
//   21  * ------------------------------------------------------------------------------------------------
//   22  */
//   23 
//   24 /* hal */
//   25 #include "hal_types.h"
//   26 #include "hal_mcu.h"

        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,0c3H
// unsigned char volatile __sfr T2CNF
T2CNF:
        DS 1
//   27 
//   28 /* high-level specific */
//   29 #include "mac_spec.h"
//   30 
//   31 /* exported low-level */
//   32 #include "mac_low_level.h"
//   33 
//   34 /* low-level specific */
//   35 #include "mac_backoff_timer.h"
//   36 #include "mac_tx.h"
//   37 
//   38 /* target specific */
//   39 #include "mac_radio_defs.h"
//   40 
//   41 /* debug */
//   42 #include "mac_assert.h"
//   43 
//   44 
//   45 /* ------------------------------------------------------------------------------------------------
//   46  *                                            Defines
//   47  * ------------------------------------------------------------------------------------------------
//   48  */
//   49 #define COMPARE_STATE_ROLLOVER_BV                 BV(0)
//   50 #define COMPARE_STATE_TRIGGER_BV                  BV(1)
//   51 #define COMPARE_STATE_ARM_BV                      BV(2)
//   52 
//   53 #define COMPARE_STATE_TRIGGER                     COMPARE_STATE_TRIGGER_BV
//   54 #define COMPARE_STATE_ROLLOVER                    COMPARE_STATE_ROLLOVER_BV
//   55 #define COMPARE_STATE_ROLLOVER_AND_TRIGGER        (COMPARE_STATE_ROLLOVER_BV | COMPARE_STATE_TRIGGER_BV)
//   56 #define COMPARE_STATE_ROLLOVER_AND_ARM_TRIGGER    (COMPARE_STATE_ROLLOVER_BV | COMPARE_STATE_ARM_BV)
//   57 
//   58 
//   59 /*
//   60  *  The datasheet mentions a small delay on both receive and transmit side of approximately
//   61  *  two microseconds.  The precise characterization is given below.
//   62  *  (This data is not given in rev 1.03 datasheet)
//   63  */
//   64 #define RX_TX_PROP_DELAY_AVG_USEC         ((MAC_RADIO_RX_TX_PROP_DELAY_MIN_USEC + MAC_RADIO_RX_TX_PROP_DELAY_MAX_USEC) / 2)
//   65 #define RX_TX_PROP_DELAY_AVG_TIMER_TICKS  ((uint16)(MAC_RADIO_TIMER_TICKS_PER_USEC() * RX_TX_PROP_DELAY_AVG_USEC + 0.5))
//   66 
//   67 /*
//   68  *  For slotted receives, the SFD signal is expected to occur on a specifc symbol boundary.
//   69  *  This does *not* correspond to the backoff boundary.  The SFD signal occurs at an
//   70  *  offset from the backoff boundary.  This is done for efficiency of related algorithms.
//   71  *
//   72  *  Once transmit is strobed there is a fixed delay until the SFD signal occurs.  The frame
//   73  *  does not start over-the-air transmit until after an internal radio delay of 12 symbols.
//   74  *  Once transmitting over-the-air, the preamble is sent (8 symbols) followed by the
//   75  *  SFD field (2 symbols). After the SFD field completes, the SFD signal occurs.  This
//   76  *  adds up to a total of 22 symbols from strobe to SFD signal.
//   77  *
//   78  *  Since 22 symbols spans more than a backoff (20 symbols) the modulus operation is used
//   79  *  to find the symbol offset which is 2 symbols.
//   80  *
//   81  *  This math is derived formally via the pre-processor.
//   82  */
//   83 #define SYMBOLS_FROM_STROBE_TO_PREAMBLE   12 /* from datasheet */
//   84 #define SYMBOLS_FROM_PREAMBLE_TO_SFD      (MAC_SPEC_PREAMBLE_FIELD_LENGTH + MAC_SPEC_SFD_FIELD_LENGTH)
//   85 #define SYMBOLS_FROM_STROBE_TO_SFD        (SYMBOLS_FROM_STROBE_TO_PREAMBLE + SYMBOLS_FROM_PREAMBLE_TO_SFD)
//   86 #define SYMBOLS_EXPECTED_AT_SFD           (SYMBOLS_FROM_STROBE_TO_SFD % MAC_A_UNIT_BACKOFF_PERIOD)
//   87 
//   88 /* after all that formal math, make sure the result is as expected */
//   89 #if (SYMBOLS_EXPECTED_AT_SFD != 2)
//   90 #error "ERROR! Internal problem with pre-processor math of slotted alignment."
//   91 #endif
//   92 
//   93 
//   94 /*
//   95  *  The expected SFD signal occurs at the symbol offset *plus* a small internal propagation delay
//   96  *  internal to the radio.  This delay is given as the sum of a receive side delay and a transmit
//   97  *  side delay.  When this delay is subtracted from the internal timer, the internal time base
//   98  *  actually becomes the actual receive time *minus* the transmit delay.  This works out though.
//   99  *  The transmit logic does *not* take into account this delay.  Since the timer is skewed by the
//  100  *  transmit delay already, the transmits go out precisely on time.
//  101  */
//  102 #define TIMER_TICKS_EXPECTED_AT_SFD   ((SYMBOLS_EXPECTED_AT_SFD * MAC_RADIO_TIMER_TICKS_PER_SYMBOL()) \ 
//  103                                           + RX_TX_PROP_DELAY_AVG_TIMER_TICKS)
//  104 
//  105 
//  106 /* ------------------------------------------------------------------------------------------------
//  107  *                                         Local Variables
//  108  * ------------------------------------------------------------------------------------------------
//  109  */

        RSEG XDATA_Z:XDATA:NOROOT(0)
        REQUIRE __INIT_XDATA_Z
//  110 static uint32 backoffTimerRollover;
??backoffTimerRollover:
        DS 4

        RSEG XDATA_Z:XDATA:NOROOT(0)
        REQUIRE __INIT_XDATA_Z
//  111 static uint32 backoffTimerTrigger;
??backoffTimerTrigger:
        DS 4

        RSEG XDATA_Z:XDATA:NOROOT(0)
        REQUIRE __INIT_XDATA_Z
//  112 static uint8 compareState;
??compareState:
        DS 1
//  113 
//  114 
//  115 /**************************************************************************************************
//  116  * @fn          macBackoffTimerInit
//  117  *
//  118  * @brief       Intializes backoff timer.
//  119  *
//  120  * @param       none
//  121  *
//  122  * @return      none
//  123  **************************************************************************************************
//  124  */

        RSEG BANKED_CODE:CODE:NOROOT(0)
//  125 void macBackoffTimerInit(void)
macBackoffTimerInit:
        CFI Block cfiBlock0 Using cfiCommon0
        CFI Function macBackoffTimerInit
//  126 {
        FUNCALL macBackoffTimerInit, macMcuOverflowSetCount
        LOCFRAME XSTACK, 12, STACK
        ARGFRAME XSTACK, 12, STACK
        FUNCALL macBackoffTimerInit, macBackoffTimerSetRollover
        LOCFRAME XSTACK, 12, STACK
        ARGFRAME XSTACK, 12, STACK
        FUNCALL macBackoffTimerInit, macMcuOrT2PEROF2
        LOCFRAME XSTACK, 12, STACK
        ARGFRAME XSTACK, 12, STACK
        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
//  127   compareState = COMPARE_STATE_ROLLOVER;
        MOV	A,#0x1
        MOV	DPTR,#??compareState
        MOVX	@DPTR,A
//  128   MAC_RADIO_BACKOFF_SET_COUNT(0);
        ; Setup parameters for call to function macMcuOverflowSetCount
        MOV	DPTR,#__Constant_0
        MOV	R0,#?V0 + 0
        LCALL	?L_MOV_X
        MOV	R2,?V0 + 0
        MOV	R3,?V0 + 1
        MOV	R4,?V0 + 2
        MOV	R5,?V0 + 3
        MOV	DPTR,#(macMcuOverflowSetCount & 0xffff)
        MOV	A,#((macMcuOverflowSetCount >> 16) & 0xff)
        LCALL	?BCALL               ; Banked call to: DPTR()
//  129   macBackoffTimerSetRollover(MAC_BACKOFF_TIMER_DEFAULT_ROLLOVER);
        ; Setup parameters for call to function macBackoffTimerSetRollover
        MOV	DPTR,#__Constant_c0000
        MOV	R0,#?V0 + 0
        LCALL	?L_MOV_X
        MOV	R2,?V0 + 0
        MOV	R3,?V0 + 1
        MOV	R4,?V0 + 2
        MOV	R5,?V0 + 3
        MOV	DPTR,#(macBackoffTimerSetRollover & 0xffff)
        MOV	A,#((macBackoffTimerSetRollover >> 16) & 0xff)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -