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

📄 mac_tx.s51

📁 cc2430应用实例
💻 S51
📖 第 1 页 / 共 5 页
字号:
        FUNCALL macTxFrame, halAssertHandler
        LOCFRAME XSTACK, 9, STACK
        ARGFRAME XSTACK, 9, STACK
        FUNCALL macTxFrame, ??txCsmaPrep
        LOCFRAME XSTACK, 9, STACK
        ARGFRAME XSTACK, 9, STACK
        FUNCALL macTxFrame, halAssertHandler
        LOCFRAME XSTACK, 9, STACK
        ARGFRAME XSTACK, 9, STACK
        FUNCALL macTxFrame, macMemWriteTxFifo
        LOCFRAME XSTACK, 9, STACK
        ARGFRAME XSTACK, 9, STACK
        FUNCALL macTxFrame, ??txGo
        LOCFRAME XSTACK, 9, STACK
        ARGFRAME XSTACK, 9, STACK
        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
        MOV	A,R1
        MOV	R6,A
//  156   MAC_ASSERT(!macTxActive);            /* transmit on top of transmit */
        MOV	DPTR,#macTxActive
        MOVX	A,@DPTR
        JZ	??macTxFrame_0
        ; Setup parameters for call to function halAssertHandler
        MOV	DPTR,#(halAssertHandler & 0xffff)
        MOV	A,#((halAssertHandler >> 16) & 0xff)
        LCALL	?BCALL               ; Banked call to: DPTR()
//  157 
//  158   /* mark transmit as active */
//  159   macTxActive = MAC_TX_ACTIVE_INITIALIZE;
??macTxFrame_0:
        MOV	A,#0x1
        MOV	DPTR,#macTxActive
        MOVX	@DPTR,A
//  160 
//  161   /*
//  162    *  The MAC will not enter sleep mode if there is an active transmit.  However, if macSleep() is
//  163    *  ever called from interrupt context, it possible to enter sleep state after a transmit is
//  164    *  intiated but before macTxActive is set.  To recover from this, the transmit must be aborted
//  165    *  and proper notificiation given to high-level.
//  166    */
//  167   if (macSleepState != MAC_SLEEP_STATE_AWAKE)
        MOV	DPTR,#macSleepState
        MOVX	A,@DPTR
        JZ	??macTxFrame_1
//  168   {
//  169     /* notify high-level that transmit had to be aborted */
//  170     txComplete(MAC_TX_ABORTED);
        ; Setup parameters for call to function txComplete
        MOV	R1,#0x1d
        MOV	DPTR,#(??txComplete & 0xffff)
        MOV	A,#((??txComplete >> 16) & 0xff)
??macTxFrame_2:
        LCALL	?BCALL               ; Banked call to: DPTR()
//  171 
//  172     /* exit from transmit logic */
//  173     return;
        LJMP	??macTxFrame_3 & 0xFFFF
//  174   }
//  175   
//  176   /* save transmit type */
//  177   macTxType = txType;
??macTxFrame_1:
        MOV	A,R6
        MOV	DPTR,#macTxType
        MOVX	@DPTR,A
//  178 
//  179   /*-------------------------------------------------------------------------------
//  180    *  Prepare for transmit.
//  181    */
//  182   if (macTxType == MAC_TX_TYPE_SLOTTED)
        XRL	A,#0x2
        JNZ	??macTxFrame_4
//  183   {
//  184     MAC_RADIO_TX_PREP_SLOTTED();
        ; Setup parameters for call to function macCspTxPrepSlotted
        MOV	DPTR,#(macCspTxPrepSlotted & 0xffff)
        MOV	A,#((macCspTxPrepSlotted >> 16) & 0xff)
        SJMP	??macTxFrame_5
//  185   }
//  186   else
//  187   {
//  188     MAC_ASSERT((macTxType == MAC_TX_TYPE_SLOTTED_CSMA) || (macTxType == MAC_TX_TYPE_UNSLOTTED_CSMA));
??macTxFrame_4:
        MOVX	A,@DPTR
        JZ	??macTxFrame_6
        XRL	A,#0x1
        JZ	??macTxFrame_6
        ; Setup parameters for call to function halAssertHandler
        MOV	DPTR,#(halAssertHandler & 0xffff)
        MOV	A,#((halAssertHandler >> 16) & 0xff)
        LCALL	?BCALL               ; Banked call to: DPTR()
//  189 
//  190     nb = 0;
??macTxFrame_6:
        CLR	A
        MOV	DPTR,#??nb
        MOVX	@DPTR,A
//  191     macTxBe = (pMacDataTx->internal.txOptions & MAC_TXOPTION_ALT_BE) ? macPib.altBe : macPib.minBe;
        MOV	DPTR,#pMacDataTx
        MOVX	A,@DPTR
        ADD	A,#0xe
        LCALL	?Subroutine1 & 0xFFFF
??CrossCallReturnLabel_2:
        MOV	C,0xE0 /* A   */.6
        JNC	??macTxFrame_7
        MOV	DPTR,#(macPib + 58)
        SJMP	??macTxFrame_8
??macTxFrame_7:
        MOV	DPTR,#(macPib + 28)
??macTxFrame_8:
        MOVX	A,@DPTR
        MOV	R2,A
        MOV	A,R2
        MOV	DPTR,#macTxBe
        MOVX	@DPTR,A
//  192 
//  193     if ((macTxType == MAC_TX_TYPE_SLOTTED_CSMA) && (macPib.battLifeExt))
        MOV	DPTR,#macTxType
        MOVX	A,@DPTR
        JNZ	??macTxFrame_9
        MOV	DPTR,#(macPib + 3)
        MOVX	A,@DPTR
        JZ	??macTxFrame_9
//  194     {
//  195       macTxBe = MIN(2, macTxBe);
        MOV	DPTR,#macTxBe
        MOVX	A,@DPTR
        CLR	C
        SUBB	A,#0x3
        JC	??macTxFrame_10
        MOV	R2,#0x2
??macTxFrame_10:
        MOV	A,R2
        MOVX	@DPTR,A
//  196     }
//  197 
//  198     txCsmaPrep();
??macTxFrame_9:
        ; Setup parameters for call to function txCsmaPrep
        MOV	DPTR,#(??txCsmaPrep & 0xffff)
        MOV	A,#((??txCsmaPrep >> 16) & 0xff)
??macTxFrame_5:
        LCALL	?BCALL               ; Banked call to: DPTR()
//  199   }
//  200 
//  201   /*-------------------------------------------------------------------------------
//  202    *  Load transmit FIFO unless this is a retransmit.  No need to write
//  203    *  the FIFO again in that case.
//  204    */
//  205   if (!txRetransmitFlag)
        MOV	DPTR,#??txRetransmitFlag
        MOVX	A,@DPTR
        JNZ	??macTxFrame_11
//  206   {
//  207     uint8 * p;
//  208     uint8   lenMhrMsdu;
//  209 
//  210     MAC_ASSERT(pMacDataTx != NULL); /* must have data to transmit */
        MOV	DPTR,#pMacDataTx
        MOVX	A,@DPTR
        JNZ	??macTxFrame_12
        INC	DPTR
        MOVX	A,@DPTR
??macTxFrame_12:
        JNZ	??macTxFrame_13
        ; Setup parameters for call to function halAssertHandler
        MOV	DPTR,#(halAssertHandler & 0xffff)
        MOV	A,#((halAssertHandler >> 16) & 0xff)
        LCALL	?BCALL               ; Banked call to: DPTR()
//  211 
//  212     /* save needed parameters */
//  213     txAckReq = MAC_ACK_REQUEST(pMacDataTx->msdu.p);
??macTxFrame_13:
        MOV	DPTR,#pMacDataTx
        MOVX	A,@DPTR
        ADD	A,#0x2
        LCALL	?Subroutine1 & 0xFFFF
??CrossCallReturnLabel_3:
        MOV	R2,A
        INC	DPTR
        MOVX	A,@DPTR
        MOV	DPH,A
        MOV	DPL,R2
        MOVX	A,@DPTR
        ANL	A,#0x20
        MOV	DPTR,#??txAckReq
        MOVX	@DPTR,A
//  214     txSeqn   = MAC_SEQ_NUMBER(pMacDataTx->msdu.p);
        MOV	DPL,R0
        MOV	DPH,R1
        INC	DPTR
        MOVX	A,@DPTR
        MOV	DPH,A
        MOV	DPL,R2
        INC	DPTR
        INC	DPTR
        MOVX	A,@DPTR
        MOV	DPTR,#??txSeqn
        MOVX	@DPTR,A
//  215 
//  216     /* set length of frame (note: use of term msdu is a misnomer, here it's actually mhr + msdu) */
//  217     lenMhrMsdu = pMacDataTx->msdu.len;
        LCALL	?Subroutine0 & 0xFFFF
??CrossCallReturnLabel_0:
        MOVX	A,@DPTR
        MOV	R2,A
//  218 
//  219     /* calling code guarantees an unused prepended byte  */
//  220     p = pMacDataTx->msdu.p - PREPENDED_BYTE_LEN;
        MOV	DPL,R0
        MOV	DPH,R1
        MOVX	A,@DPTR
        ADD	A,#-0x1
        MOV	R0,A
        INC	DPTR
        MOVX	A,@DPTR
        ADDC	A,#-0x1
        MOV	R1,A
        MOV	DPL,R0
        MOV	DPH,R1
//  221 
//  222     /* first byte of buffer is length of MPDU */
//  223     *p = lenMhrMsdu + MFR_LEN;
        MOV	A,#0x2
        ADD	A,R2
        MOVX	@DPTR,A
//  224 
//  225     /*
//  226      *  Flush the TX FIFO.  This is necessary in case the previous transmit was never
//  227      *  actually sent (e.g. CSMA failed without strobing TXON).  If bytes are written to
//  228      *  the FIFO but not transmitted, they remain in the FIFO to be transmitted whenever
//  229      *  a strobe of TXON does happen.
//  230      */
//  231     MAC_RADIO_FLUSH_TX_FIFO();
        MOV	0xe1,#-0x19
//  232 
//  233     /* write bytes to FIFO, prepended byte is included, MFR is not (it's generated by hardware) */
//  234     MAC_RADIO_WRITE_TX_FIFO(p, PREPENDED_BYTE_LEN + lenMhrMsdu);
        ; Setup parameters for call to function macMemWriteTxFifo
        MOV	A,#0x1
        ADD	A,R2
        MOV	R1,A
        MOV	R2,DPL
        MOV	R3,DPH
        MOV	DPTR,#(macMemWriteTxFifo & 0xffff)
        MOV	A,#((macMemWriteTxFifo >> 16) & 0xff)
        LCALL	?BCALL               ; Banked call to: DPTR()
//  235   }
//  236 
//  237   /*-------------------------------------------------------------------------------
//  238    *  If not receiving, start the transmit.  If receive is active
//  239    *  queue up the transmit.
//  240    *
//  241    *  Critical sections around the state change prevents any sort of race condition
//  242    *  with  macTxStartQueuedFrame().  This guarantees function txGo() will only be
//  243    *  called once.
//  244    */
//  245   {
//  246     halIntState_t  s;
//  247 
//  248     HAL_ENTER_CRITICAL_SECTION(s);
??macTxFrame_11:
        MOV	C,0xa8.7
        CLR	A
        MOV	0xE0 /* A   */.0,C
        CLR	0xa8.7
//  249     if (!macRxActive && !macRxOutgoingAckFlag)
        MOV	DPTR,#macRxActive
        MOVX	A,@DPTR
        JNZ	??macTxFrame_14
        MOV	DPTR,#macRxOutgoingAckFlag
        MOVX	A,@DPTR
        JNZ	??macTxFrame_14
//  250     {
//  251       macTxActive = MAC_TX_ACTIVE_GO;
        MOV	A,#-0x7d
        MOV	DPTR,#macTxActive
        LCALL	?Subroutine2 & 0xFFFF
//  252       HAL_EXIT_CRITICAL_SECTION(s);
//  253       txGo();
??CrossCallReturnLabel_4:
        LJMP	??macTxFrame_2 & 0xFFFF
//  254     }
//  255     else
//  256     {
//  257       macTxActive = MAC_TX_ACTIVE_QUEUED;
??macTxFrame_14:
        MOV	A,#0x2
        MOV	DPTR,#macTxActive
        MOVX	@DPTR,A
//  258       HAL_EXIT_CRITICAL_SECTION(s);
        MOV	0xa8.7,C
??macTxFrame_3:
        LJMP	?Subroutine4 & 0xFFFF
        CFI EndBlock cfiBlock2
//  259     }
//  260   }
//  261 }

        RSEG BANKED_CODE:CODE:NOROOT(0)
?Subroutine1:
        CFI Block cfiCond3 Using cfiCommon0
        CFI NoFunction
        CFI Conditional ??CrossCallReturnLabel_3
        CFI R6 load(1, XDATA, add(CFA_XSP16, literal(-9)))
        CFI VB load(1, XDATA, add(CFA_XSP16, literal(-8)))
        CFI V0 load(1, XDATA, add(CFA_XSP16, literal(-7)))
        CFI R7 load(1, XDATA, add(CFA_XSP16, literal(-6)))
        CFI ?RET_LOW load(1, XDATA, add(CFA_XSP16, literal(-5)))
        CFI ?RET_HIGH load(1, XDATA, add(CFA_XSP16, literal(-4)))
        CFI ?BRET_EXT load(1, XDATA, add(CFA_XSP16, literal(-3)))
        CFI DPL0 load(1, XDATA, add(CFA_XSP16, literal(-2)))
        CFI DPH0 load(1, XDATA, add(CFA_XSP16, literal(-1)))
        CFI CFA_SP SP+0
        CFI CFA_XSP16 add(XSP16, 9)
        CFI Block cfiCond4 Using cfiCommon0
        CFI (cfiCond4) NoFunction
        CFI (cfiCond4) Conditional ??CrossCallReturnLabel_2
        CFI (cfiCond4) R6 load(1, XDATA, add(CFA_XSP16, literal(-9)))
        CFI (cfiCond4) VB load(1, XDATA, add(CFA_XSP16, literal(-8)))
        CFI (cfiCond4) V0 load(1, XDATA, add(CFA_XSP16, literal(-7)))
        CFI (cfiCond4) R7 load(1, XDATA, add(CFA_XSP16, literal(-6)))
        CFI (cfiCond4) ?RET_LOW load(1, XDATA, add(CFA_XSP16, literal(-5)))
        CFI (cfiCond4) ?RET_HIGH load(1, XDATA, add(CFA_XSP16, literal(-4)))
        CFI (cfiCond4) ?BRET_EXT load(1, XDATA, add(CFA_XSP16, literal(-3)))
        CFI (cfiCond4) DPL0 load(1, XDATA, add(CFA_XSP16, literal(-2)))

⌨️ 快捷键说明

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