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

📄 mac_backoff_timer.lst

📁 CC2430上开关控制灯和温度传感器采集两个例子
💻 LST
📖 第 1 页 / 共 5 页
字号:
     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           */

   \                                 In segment XDATA_Z, align 1, keep-with-next
   \   000000                REQUIRE __INIT_XDATA_Z
    110          static uint32 backoffTimerRollover;
   \                     ??backoffTimerRollover:
   \   000000                DS 4

   \                                 In segment XDATA_Z, align 1, keep-with-next
   \   000000                REQUIRE __INIT_XDATA_Z
    111          static uint32 backoffTimerTrigger;
   \                     ??backoffTimerTrigger:
   \   000000                DS 4

   \                                 In segment XDATA_Z, align 1, keep-with-next
   \   000000                REQUIRE __INIT_XDATA_Z
    112          static uint8 compareState;
   \                     ??compareState:
   \   000000                DS 1
    113          
    114          
    115          /**************************************************************************************************
    116           * @fn          macBackoffTimerInit
    117           *
    118           * @brief       Intializes backoff timer.
    119           *
    120           * @param       none
    121           *
    122           * @return      none
    123           **************************************************************************************************
    124           */

   \                                 In segment BANKED_CODE, align 1, keep-with-next
    125          void macBackoffTimerInit(void)
   \                     macBackoffTimerInit:
    126          {
   \   000000   74F4         MOV     A,#-0xc
   \   000002   12....       LCALL   ?BANKED_ENTER_XDATA
   \   000005                ; Saved register size: 12
   \   000005                ; Auto size: 0
    127            compareState = COMPARE_STATE_ROLLOVER;
   \   000005   7401         MOV     A,#0x1
   \   000007   90....       MOV     DPTR,#??compareState
   \   00000A   F0           MOVX    @DPTR,A
    128            MAC_RADIO_BACKOFF_SET_COUNT(0);
   \   00000B                ; Setup parameters for call to function macMcuOverflowSetCount
   \   00000B   90....       MOV     DPTR,#__Constant_0
   \   00000E   78..         MOV     R0,#?V0 + 0
   \   000010   12....       LCALL   ?L_MOV_X
   \   000013   AA..         MOV     R2,?V0 + 0
   \   000015   AB..         MOV     R3,?V0 + 1
   \   000017   AC..         MOV     R4,?V0 + 2
   \   000019   AD..         MOV     R5,?V0 + 3
   \   00001B   90....       MOV     DPTR,#(macMcuOverflowSetCount & 0xffff)
   \   00001E   74..         MOV     A,#((macMcuOverflowSetCount >> 16) & 0xff)
   \   000020   12....       LCALL   ?BCALL               ; Banked call to: DPTR()
    129            macBackoffTimerSetRollover(MAC_BACKOFF_TIMER_DEFAULT_ROLLOVER);
   \   000023                ; Setup parameters for call to function macBackoffTimerSetRollover
   \   000023   90....       MOV     DPTR,#__Constant_c0000
   \   000026   78..         MOV     R0,#?V0 + 0
   \   000028   12....       LCALL   ?L_MOV_X
   \   00002B   AA..         MOV     R2,?V0 + 0
   \   00002D   AB..         MOV     R3,?V0 + 1
   \   00002F   AC..         MOV     R4,?V0 + 2
   \   000031   AD..         MOV     R5,?V0 + 3
   \   000033   90....       MOV     DPTR,#(macBackoffTimerSetRollover & 0xffff)
   \   000036   74..         MOV     A,#((macBackoffTimerSetRollover >> 16) & 0xff)
   \   000038   12....       LCALL   ?BCALL               ; Banked call to: DPTR()
    130            MAC_RADIO_BACKOFF_COMPARE_CLEAR_INTERRUPT();
   \   00003B   75C3C3       MOV     0xc3,#-0x3d
    131            MAC_RADIO_BACKOFF_COMPARE_ENABLE_INTERRUPT();
   \   00003E                ; Setup parameters for call to function macMcuOrT2PEROF2
   \   00003E   7920         MOV     R1,#0x20
   \   000040   90....       MOV     DPTR,#(macMcuOrT2PEROF2 & 0xffff)
   \   000043   74..         MOV     A,#((macMcuOrT2PEROF2 >> 16) & 0xff)
   \   000045   12....       LCALL   ?BCALL               ; Banked call to: DPTR()
    132          }
   \   000048   02....       LJMP    ?Subroutine1 & 0xFFFF

   \                                 In segment BANKED_CODE, align 1, keep-with-next
   \                     ?Subroutine1:
   \   000000   7F04         MOV     R7,#0x4
   \   000002   02....       LJMP    ?BANKED_LEAVE_XDATA
    133          
    134          
    135          /**************************************************************************************************
    136           * @fn          macBackoffTimerReset
    137           *
    138           * @brief       Resets backoff timer.
    139           *
    140           * @param       none
    141           *
    142           * @return      none
    143           **************************************************************************************************
    144           */

   \                                 In segment BANKED_CODE, align 1, keep-with-next
    145          void macBackoffTimerReset(void)
   \                     macBackoffTimerReset:
    146          {
   \   000000   C082         PUSH    DPL
   \   000002   C083         PUSH    DPH
   \   000004                ; Saved register size: 2
   \   000004                ; Auto size: 0
    147            MAC_RADIO_BACKOFF_COMPARE_DISABLE_INTERRUPT();
   \   000004                ; Setup parameters for call to function macMcuAndT2PEROF2
   \   000004   79DF         MOV     R1,#-0x21
   \   000006   90....       MOV     DPTR,#(macMcuAndT2PEROF2 & 0xffff)
   \   000009   74..         MOV     A,#((macMcuAndT2PEROF2 >> 16) & 0xff)
   \   00000B   12....       LCALL   ?BCALL               ; Banked call to: DPTR()
    148            macBackoffTimerInit();
   \   00000E                ; Setup parameters for call to function macBackoffTimerInit
   \   00000E   90....       MOV     DPTR,#(macBackoffTimerInit & 0xffff)
   \   000011   74..         MOV     A,#((macBackoffTimerInit >> 16) & 0xff)
   \   000013   12....       LCALL   ?BCALL               ; Banked call to: DPTR()
    149          }
   \   000016   D083         POP     DPH
   \   000018   D082         POP     DPL
   \   00001A   02....       LJMP    ?BRET
    150          
    151          
    152          /**************************************************************************************************
    153           * @fn          macBackoffTimerSetRollover
    154           *
    155           * @brief       Set rollover count of backoff timer.
    156           *
    157           * @param       rolloverBackoff - backoff count where count is reset to zero
    158           *
    159           * @return      none
    160           **************************************************************************************************
    161           */

   \                                 In segment BANKED_CODE, align 1, keep-with-next
    162          void macBackoffTimerSetRollover(uint32 rolloverBackoff)
   \                     macBackoffTimerSetRollover:
    163          {
   \   000000   74F0         MOV     A,#-0x10
   \   000002   12....       LCALL   ?BANKED_ENTER_XDATA
   \   000005                ; Saved register size: 16
   \   000005                ; Auto size: 0
   \   000005   8A..         MOV     ?V0 + 0,R2
   \   000007   8B..         MOV     ?V0 + 1,R3
   \   000009   8C..         MOV     ?V0 + 2,R4
   \   00000B   8D..         MOV     ?V0 + 3,R5
    164            halIntState_t  s;
    165          
    166            MAC_ASSERT(rolloverBackoff > MAC_RADIO_BACKOFF_COUNT());  /* rollover value must be greater than count */
   \   00000D                ; Setup parameters for call to function macMcuOverflowCount
   \   00000D   90....       MOV     DPTR,#(macMcuOverflowCount & 0xffff)
   \   000010   74..         MOV     A,#((macMcuOverflowCount >> 16) & 0xff)
   \   000012   12....       LCALL   ?BCALL               ; Banked call to: DPTR()
   \   000015   8A..         MOV     ?V0 + 4,R2
   \   000017   8B..         MOV     ?V0 + 5,R3
   \   000019   8C..         MOV     ?V0 + 6,R4
   \   00001B   8D..         MOV     ?V0 + 7,R5
   \   00001D   78..         MOV     R0,#?V0 + 0
   \   00001F   79..         MOV     R1,#?V0 + 4
   \   000021   12....       LCALL   ?UL_GT
   \   000024   4008         JC      ??macBackoffTimerSetRollover_0
   \   000026                ; Setup parameters for call to function halAssertHandler
   \   000026   90....       MOV     DPTR,#(halAssertHandler & 0xffff)
   \   000029   74..         MOV     A,#((halAssertHandler >> 16) & 0xff)
   \   00002B   12....       LCALL   ?BCALL               ; Banked call to: DPTR()
    167          
    168            HAL_ENTER_CRITICAL_SECTION(s);
   \                     ??macBackoffTimerSetRollover_0:
   \   00002E   A2AF         MOV     C,0xa8.7
   \   000030   E4           CLR     A
   \   000031   92E0         MOV     0xE0 /* A   */.0,C
   \   000033   FE           MOV     R6,A
   \   000034   C2AF         CLR     0xa8.7
    169            backoffTimerRollover = rolloverBackoff;
   \   000036   90....       MOV     DPTR,#??backoffTimerRollover
   \   000039   78..         MOV     R0,#?V0 + 0
   \   00003B   12....       LCALL   ?L_MOV_TO_X
    170            MAC_RADIO_BACKOFF_SET_COMPARE(rolloverBackoff);
   \   00003E                ; Setup parameters for call to function macMcuOverflowSetCompare
   \   00003E   02....       LJMP    ?Subroutine2 & 0xFFFF
    171            HAL_EXIT_CRITICAL_SECTION(s);
    172          }

   \                                 In segment BANKED_CODE, align 1, keep-with-next
   \                     ?Subroutine2:
   \   000000   AA..         MOV     R2,?V0 + 0
   \   000002   AB..         MOV     R3,?V0 + 1
   \   000004   AC..         MOV     R4,?V0 + 2
   \   000006   AD..         MOV     R5,?V0 + 3
   \   000008   90....       MOV     DPTR,#(macMcuOverflowSetCompare & 0xffff)
   \   00000B   74..         MOV     A,#((macMcuOverflowSetCompare >> 16) & 0xff)
   \                     ??Subroutine2_0:
   \   00000D   12....       LCALL   ?BCALL               ; Banked call to: DPTR()
   \   000010   EE           MOV     A,R6
   \   000011   A2E0         MOV     C,0xE0 /* A   */.0
   \   000013   92AF         MOV     0xa8.7,C
   \                     ??Subroutine2_1:
   \   000015   7F08         MOV     R7,#0x8
   \   000017   02....       LJMP    ?BANKED_LEAVE_XDATA
    173          
    174          
    175          /**************************************************************************************************
    176           * @fn          macBackoffTimerSetCount

⌨️ 快捷键说明

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