mac_csp_tx.lst

来自「TI的基于ZIGBEE2006的协议栈」· LST 代码 · 共 1,102 行 · 第 1/5 页

LST
1,102
字号
    352            RFST = DECZ;
    353          }
    354          
    355          
    356          /**************************************************************************************************
    357           * @fn          macCspTxGoCsma
    358           *
    359           * @brief       Run previously loaded CSP program for CSMA transmit.  Handles either
    360           *              slotted or unslotted CSMA transmits.  When CSP program has finished,
    361           *              an interrupt occurs and macCspTxStopIsr() is called.  This ISR will in
    362           *              turn call macTxDoneCallback().
    363           *
    364           * @param       none
    365           *
    366           * @return      none
    367           **************************************************************************************************
    368           */

   \                                 In segment BANKED_CODE, align 1, keep-with-next
    369          void macCspTxGoCsma(void)
   \                     macCspTxGoCsma:
    370          {
   \   000000   C082         PUSH    DPL
   \   000002   C083         PUSH    DPH
   \   000004                ; Saved register size: 2
   \   000004                ; Auto size: 0
    371            /*
    372             *  Set CSPX with the countdown time of the CSMA delay.  Subtract one because there is
    373             *  a built-in one backoff delay in the CSP program to make sure receiver has been 'on'
    374             *  for at least one backoff.  Don't subtract though if CSPX is already zero!
    375             */
    376            CSPX = macTxCsmaBackoffDelay;
   \   000004   90....       MOV     DPTR,#macTxCsmaBackoffDelay
   \   000007   E0           MOVX    A,@DPTR
   \   000008   90DF12       MOV     DPTR,#-0x20ee
   \   00000B   F0           MOVX    @DPTR,A
    377            if (CSPX != 0)
   \   00000C   E0           MOVX    A,@DPTR
   \   00000D   6003         JZ      ??macCspTxGoCsma_0
    378            {
    379              CSPX--;
   \   00000F   E0           MOVX    A,@DPTR
   \   000010   14           DEC     A
   \   000011   F0           MOVX    @DPTR,A
    380            }
    381          
    382            /*
    383             *  Set WEVENT to trigger at the current value of the timer.  This allows
    384             *  unslotted CSMA to transmit just a little bit sooner.
    385             */
    386            CSP_WEVENT_SET_TRIGGER_NOW();
   \                     ??macCspTxGoCsma_0:
   \   000012   E5A6         MOV     A,0xa6
   \   000014   85A794       MOV     0x94,0xa7
   \   000017   E594         MOV     A,0x94
   \   000019   7003         JNZ     ??macCspTxGoCsma_1
   \   00001B   759401       MOV     0x94,#0x1
    387          
    388            /*
    389             *  Enable interrupt that fires when CSP program stops.
    390             *  Also enable interrupt that fires when INT instruction
    391             *  is executed.
    392             */
    393            MAC_MCU_CSP_STOP_ENABLE_INTERRUPT();
   \                     ??macCspTxGoCsma_1:
   \   00001E                ; Setup parameters for call to function macMcuOrRFIM
   \   00001E   7902         MOV     R1,#0x2
   \   000020   90....       MOV     DPTR,#(macMcuOrRFIM & 0xffff)
   \   000023   74..         MOV     A,#((macMcuOrRFIM >> 16) & 0xff)
   \   000025   12....       LCALL   ?BCALL               ; Banked call to: DPTR()
    394            MAC_MCU_CSP_INT_ENABLE_INTERRUPT();
   \   000028                ; Setup parameters for call to function macMcuOrRFIM
   \   000028   7901         MOV     R1,#0x1
   \   00002A   74..         MOV     A,#((macMcuOrRFIM >> 16) & 0xff)
   \   00002C   12....       LCALL   ?BCALL               ; Banked call to: DPTR()
    395            
    396            /*
    397             *  Turn on the receiver if it is not already on.  Receiver must be 'on' for at
    398             *  least one backoff before performing clear channel assessment (CCA).
    399             */
    400            macRxOn();
   \   00002F                ; Setup parameters for call to function macRxOn
   \   00002F   90....       MOV     DPTR,#(macRxOn & 0xffff)
   \   000032   74..         MOV     A,#((macRxOn >> 16) & 0xff)
   \   000034   12....       LCALL   ?BCALL               ; Banked call to: DPTR()
    401          
    402            /* start the CSP program */
    403            CSP_START_PROGRAM();
   \   000037   75E1FE       MOV     0xe1,#-0x2
    404          }
   \   00003A   80..         SJMP    ??Subroutine0_1
    405          
    406          
    407          /**************************************************************************************************
    408           * @fn          macCspTxPrepSlotted
    409           *
    410           * @brief       Prepare CSP for "Slotted" (non-CSMA) transmit.
    411           *              Load CSP program and set CSP parameters.
    412           *
    413           * @param       none
    414           *
    415           * @return      none
    416           **************************************************************************************************
    417           */

   \                                 In segment BANKED_CODE, align 1, keep-with-next
    418          void macCspTxPrepSlotted(void)
   \                     macCspTxPrepSlotted:
    419          {
   \   000000   C082         PUSH    DPL
   \   000002   C083         PUSH    DPH
   \   000004                ; Saved register size: 2
   \   000004                ; Auto size: 0
    420            cspPrepForTxProgram();
   \   000004                ; Setup parameters for call to function cspPrepForTxProgram
   \   000004   90....       MOV     DPTR,#(??cspPrepForTxProgram & 0xffff)
   \   000007   74..         MOV     A,#((??cspPrepForTxProgram >> 16) & 0xff)
   \   000009   12....       LCALL   ?BCALL               ; Banked call to: DPTR()
    421          
    422            /*----------------------------------------------------------------------
    423             *  Load CSP program :  Slotted transmit (no CSMA)
    424             */
    425            
    426            /* wait for X number of backoffs */
    427            RFST = WAITX;
   \   00000C   75E1BB       MOV     0xe1,#-0x45
    428          
    429            /* just transmit, no CSMA required */
    430            RFST = STXON;
   \   00000F   80..         SJMP    ??Subroutine0_0
    431          
    432            /*
    433             *  If the SFD pin is high at this point, there was an RX-TX collision.
    434             *  In other words, TXON was strobed while receiving.  The CSP variable
    435             *  CSPY is decremented to indicate this happened.  The rest of the transmit
    436             *  continues normally.
    437             */
    438            RFST = SKIP(2+__SNOP_SKIP__, C_SFD_IS_INACTIVE);
    439            RFST = WHILE(C_SFD_IS_ACTIVE);
    440            RFST = DECY;
    441            RFST = __SNOP__;
    442            
    443            /*
    444             *  Watch the SFD pin to determine when the transmit has finished going out.
    445             *  The INT instruction causes an interrupt to fire.  The ISR for this interrupt
    446             *  handles the record the timestamp (which was just captured when SFD went high).
    447             *  Decrement CSPZ at the last step to indicate transmit was successful.
    448             */
    449            RFST = WHILE(C_SFD_IS_INACTIVE);
    450            RFST = INT;
    451            RFST = WHILE(C_SFD_IS_ACTIVE);
    452            RFST = DECZ;
    453          }
    454          
    455          
    456          /**************************************************************************************************
    457           * @fn          macCspTxGoSlotted
    458           *
    459           * @brief       Run previously loaded CSP program for non-CSMA slotted transmit.   When CSP
    460           *              program has finished, an interrupt occurs and macCspTxStopIsr() is called.
    461           *              This ISR will in turn call macTxDoneCallback().
    462           *
    463           * @param       none
    464           *
    465           * @return      none
    466           **************************************************************************************************
    467           */

   \                                 In segment BANKED_CODE, align 1, keep-with-next
    468          void macCspTxGoSlotted(void)
   \                     macCspTxGoSlotted:
    469          {
   \   000000   C082         PUSH    DPL
   \   000002   C083         PUSH    DPH
   \   000004                ; Saved register size: 2
   \   000004                ; Auto size: 0
    470            halIntState_t  s;
    471            uint8 lowByteOfBackoffCount;
    472            uint8 backoffCountdown;
    473            
    474            /*
    475             *  Enable interrupt that fires when CSP program stops.
    476             *  Also enable interrupt that fires when INT instruction
    477             *  is executed.
    478             */
    479            MAC_MCU_CSP_STOP_ENABLE_INTERRUPT();
   \   000004                ; Setup parameters for call to function macMcuOrRFIM
   \   000004   7902         MOV     R1,#0x2
   \   000006   90....       MOV     DPTR,#(macMcuOrRFIM & 0xffff)
   \   000009   74..         MOV     A,#((macMcuOrRFIM >> 16) & 0xff)
   \   00000B   12....       LCALL   ?BCALL               ; Banked call to: DPTR()
    480            MAC_MCU_CSP_INT_ENABLE_INTERRUPT();
   \   00000E                ; Setup parameters for call to function macMcuOrRFIM
   \   00000E   7901         MOV     R1,#0x1
   \   000010   74..         MOV     A,#((macMcuOrRFIM >> 16) & 0xff)
   \   000012   12....       LCALL   ?BCALL               ; Banked call to: DPTR()
    481          
    482            /* critical section needed for timer accesses */
    483            HAL_ENTER_CRITICAL_SECTION(s);
   \   000015   A2AF         MOV     C,0xa8.7
   \   000017   E4           CLR     A
   \   000018   92E0         MOV     0xE0 /* A   */.0,C
   \   00001A   FB           MOV     R3,A
   \   00001B   C2AF         CLR     0xa8.7
    484          
    485            /* store lowest byte of backoff count (same as lowest byte of overflow count) */
    486            lowByteOfBackoffCount = T2OF0;
   \   00001D   E5A1         MOV     A,0xa1
   \   00001F   FC           MOV     R4,A
    487          
    488            /*
    489             *  Compute the number of backoffs until time to strobe transmit.  The strobe should
    490             *  occur one backoff before the SFD pin is expected to go high.  So, the forumla for the
    491             *  countdown value is to determine when the lower bits would rollover and become zero,
    492             *  and then subtract one.
    493             */
    494            backoffCountdown = SLOTTED_TX_MAX_BACKOFF_COUNTDOWN - (lowByteOfBackoffCount & SLOTTED_TX_BACKOFF_COUNT_ALIGN_BIT_MASK) - 1;
   \   000020   740F         MOV     A,#0xf
   \   000022   5C           ANL     A,R4
   \   000023   FA           MOV     R2,A
   \   000024   740F         MOV     A,#0xf

⌨️ 快捷键说明

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