mac_rx.lst

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

LST
1,148
字号
    418             */
    419            MAC_RADIO_CANCEL_ACK_TX_DONE_CALLBACK();
   \   000049                ; Setup parameters for call to function macMcuAndRFIM
   \   000049   79EF         MOV     R1,#-0x11
   \   00004B   90....       MOV     DPTR,#(macMcuAndRFIM & 0xffff)
   \   00004E   74..         MOV     A,#((macMcuAndRFIM >> 16) & 0xff)
   \   000050   12....       LCALL   ?BCALL               ; Banked call to: DPTR()
    420            macRxOutgoingAckFlag = 0;
   \   000053   E4           CLR     A
   \   000054   90....       MOV     DPTR,#macRxOutgoingAckFlag
   \   000057   F0           MOVX    @DPTR,A
    421          
    422            /*
    423             *  Make a module-local copy of macRxFilter.  This prevents the selected
    424             *  filter from changing in the middle of a receive.
    425             */
    426            rxFilter = macRxFilter;
   \   000058   90....       MOV     DPTR,#macRxFilter
   \   00005B   E0           MOVX    A,@DPTR
   \   00005C   90....       MOV     DPTR,#??rxFilter
   \   00005F   F0           MOVX    @DPTR,A
    427          
    428            /*-------------------------------------------------------------------------------
    429             *  Read initial frame information from FIFO.
    430             *
    431             *   This code is not triggered until the following are in the RX FIFO:
    432             *     frame length          - one byte containing length of MAC frame (excludes this field)
    433             *     frame control field   - two bytes defining frame type, addressing fields, control flags
    434             *     sequence number       - one byte unique sequence identifier
    435             *     additional two bytes  - these bytes are available in case the received frame is an ACK,
    436             *                             if so, the frame can be verified and responded to immediately,
    437             *                             if not an ACK, these bytes will be processed normally
    438             */
    439          
    440            /* read frame length, frame control field, and sequence number from FIFO */
    441            MAC_RADIO_READ_RX_FIFO(rxBuf, MAC_PHY_PHR_LEN + MAC_FCF_FIELD_LEN + MAC_SEQ_NUM_FIELD_LEN);
   \   000060                ; Setup parameters for call to function macMemReadRxFifo
   \   000060   7904         MOV     R1,#0x4
   \   000062   7A..         MOV     R2,#(??rxBuf & 0xff)
   \   000064   7B..         MOV     R3,#((??rxBuf >> 8) & 0xff)
   \   000066   90....       MOV     DPTR,#(macMemReadRxFifo & 0xffff)
   \   000069   74..         MOV     A,#((macMemReadRxFifo >> 16) & 0xff)
   \   00006B   12....       LCALL   ?BCALL               ; Banked call to: DPTR()
    442          
    443            /* bytes to read from FIFO equals frame length minus length of MHR fields just read from FIFO */
    444            rxUnreadLen = (rxBuf[0] & PHY_PACKET_SIZE_MASK) - MAC_FCF_FIELD_LEN - MAC_SEQ_NUM_FIELD_LEN;
   \   00006E   90....       MOV     DPTR,#??rxBuf
   \   000071   E0           MOVX    A,@DPTR
   \   000072   547F         ANL     A,#0x7f
   \   000074   24FD         ADD     A,#-0x3
   \   000076   90....       MOV     DPTR,#??rxUnreadLen
   \   000079   F0           MOVX    @DPTR,A
    445          
    446            /*
    447             *  Workaround for chip bug.  The receive buffer can sometimes be corrupted by hardware.
    448             *  This usually occurs under heavy traffic.  If a corrupted receive buffer is detected
    449             *  the entire receive buffer is flushed.
    450             *
    451             *  In the case that this workaround is not needed, an assert is used to make sure the
    452             *  receive length field is not corrupted.  This is important because a corrupted receive
    453             *  length field is utterly fatal and, if not caught here, extremely hard to track down.
    454             */
    455          #ifdef MAC_RADIO_RXBUFF_CHIP_BUG
    456            if ((rxUnreadLen > (MAC_A_MAX_PHY_PACKET_SIZE - MAC_FCF_FIELD_LEN - MAC_SEQ_NUM_FIELD_LEN)) ||
    457                (MAC_FRAME_TYPE(&rxBuf[1]) > MAC_FRAME_TYPE_MAX_VALID))
   \   00007A   C3           CLR     C
   \   00007B   947D         SUBB    A,#0x7d
   \   00007D   500B         JNC     ??rxStartIsr_6
   \   00007F   90....       MOV     DPTR,#(??rxBuf + 1)
   \   000082   E0           MOVX    A,@DPTR
   \   000083   5407         ANL     A,#0x7
   \   000085   C3           CLR     C
   \   000086   9404         SUBB    A,#0x4
   \   000088   4008         JC      ??rxStartIsr_7
    458            {
    459              MAC_RADIO_FLUSH_RX_FIFO();
   \                     ??rxStartIsr_6:
   \   00008A   75E1E6       MOV     0xe1,#-0x1a
   \   00008D   75E1E6       MOV     0xe1,#-0x1a
   \   000090   804E         SJMP    ??rxStartIsr_8
    460              rxDone();
    461              return;
    462            }
    463          #else
    464            /* radio supplied a corrupted receive buffer length */
    465            MAC_ASSERT(rxUnreadLen <= (MAC_A_MAX_PHY_PACKET_SIZE - MAC_FCF_FIELD_LEN - MAC_SEQ_NUM_FIELD_LEN));
    466          #endif
    467            
    468          
    469          
    470            /*-------------------------------------------------------------------------------
    471             *  Process ACKs.
    472             *
    473             *  If this frame is an ACK, process it immediately and exit from here.
    474             *  If this frame is not an ACK and transmit is listening for an ACK, let
    475             *  the transmit logic know an non-ACK was received so transmit can complete.
    476             *
    477             *  In promiscuous mode ACKs are treated like any other frame.
    478             */
    479            if ((MAC_FRAME_TYPE(&rxBuf[1]) == MAC_FRAME_TYPE_ACK) && (rxPromiscuousMode == PROMISCUOUS_MODE_OFF))
   \                     ??rxStartIsr_7:
   \   000092   E0           MOVX    A,@DPTR
   \   000093   5407         ANL     A,#0x7
   \   000095   6402         XRL     A,#0x2
   \   000097   704F         JNZ     ??rxStartIsr_9
   \   000099   90....       MOV     DPTR,#??rxPromiscuousMode
   \   00009C   E0           MOVX    A,@DPTR
   \   00009D   7049         JNZ     ??rxStartIsr_9
    480            {
    481              uint8 fcsBuf[MAC_FCF_FIELD_LEN];
    482              /*
    483               *  There are guaranteed to be two unread bytes in the FIFO.  By defintion, for ACK frames
    484               *  these two bytes will be the FCS.
    485               */
    486          
    487              /* read FCS from FIFO (threshold set so bytes are guaranteed to be there) */
    488              MAC_RADIO_READ_RX_FIFO(fcsBuf, MAC_FCS_FIELD_LEN);
   \   00009F                ; Setup parameters for call to function macMemReadRxFifo
   \   00009F   7902         MOV     R1,#0x2
   \   0000A1   85..82       MOV     DPL,?XSP + 0
   \   0000A4   85..83       MOV     DPH,?XSP + 1
   \   0000A7   AA82         MOV     R2,DPL
   \   0000A9   AB83         MOV     R3,DPH
   \   0000AB   90....       MOV     DPTR,#(macMemReadRxFifo & 0xffff)
   \   0000AE   74..         MOV     A,#((macMemReadRxFifo >> 16) & 0xff)
   \   0000B0   12....       LCALL   ?BCALL               ; Banked call to: DPTR()
    489              
    490              /* see if transmit is listening for an ACK */
    491              if (macTxActive == MAC_TX_ACTIVE_LISTEN_FOR_ACK)
   \   0000B3   90....       MOV     DPTR,#macTxActive
   \   0000B6   E0           MOVX    A,@DPTR
   \   0000B7   6485         XRL     A,#0x85
   \   0000B9   7025         JNZ     ??rxStartIsr_8
    492              {
    493                /*
    494                 *  An ACK was received so transmit logic needs to know.  If the FCS failed,
    495                 *  the transmit logic still needs to know.  In that case, treat the frame
    496                 *  as a non-ACK to complete the active transmit.
    497                 */
    498                if (PROPRIETARY_FCS_CRC_OK(fcsBuf))
   \   0000BB   7401         MOV     A,#0x1
   \   0000BD   12....       LCALL   ?XSTACK_DISP0_8
   \   0000C0   E0           MOVX    A,@DPTR
   \   0000C1   A2E7         MOV     C,0xE0 /* A   */.7
   \   0000C3   5013         JNC     ??rxStartIsr_10
    499                {
    500                  /* call transmit logic to indicate ACK was received */
    501                  macTxAckReceivedCallback(MAC_SEQ_NUMBER(&rxBuf[1]), MAC_FRAME_PENDING(&rxBuf[1]));
   \   0000C5                ; Setup parameters for call to function macTxAckReceivedCallback
   \   0000C5   90....       MOV     DPTR,#(??rxBuf + 1)
   \   0000C8   E0           MOVX    A,@DPTR
   \   0000C9   5410         ANL     A,#0x10
   \   0000CB   FA           MOV     R2,A
   \   0000CC   90....       MOV     DPTR,#(??rxBuf + 3)
   \   0000CF   E0           MOVX    A,@DPTR
   \   0000D0   F9           MOV     R1,A
   \   0000D1   90....       MOV     DPTR,#(macTxAckReceivedCallback & 0xffff)
   \   0000D4   74..         MOV     A,#((macTxAckReceivedCallback >> 16) & 0xff)
   \   0000D6   8005         SJMP    ??rxStartIsr_11
    502                }
    503                else
    504                {
    505                  macTxAckNotReceivedCallback();
   \                     ??rxStartIsr_10:
   \   0000D8                ; Setup parameters for call to function macTxAckNotReceivedCallback
   \   0000D8   90....       MOV     DPTR,#(macTxAckNotReceivedCallback & 0xffff)
   \   0000DB   74..         MOV     A,#((macTxAckNotReceivedCallback >> 16) & 0xff)
   \                     ??rxStartIsr_11:
   \   0000DD   12....       LCALL   ?BCALL               ; Banked call to: DPTR()
    506                }
    507              }
    508                
    509              /* receive is done, exit from here */
    510              rxDone();
   \                     ??rxStartIsr_8:
   \   0000E0                ; Setup parameters for call to function rxDone
   \   0000E0   90....       MOV     DPTR,#(??rxDone & 0xffff)
   \   0000E3   74..         MOV     A,#((??rxDone >> 16) & 0xff)
   \   0000E5   02....       LJMP    ??rxStartIsr_4 & 0xFFFF
    511              return;
    512            }
    513            else if (macTxActive == MAC_TX_ACTIVE_LISTEN_FOR_ACK)
   \                     ??rxStartIsr_9:
   \   0000E8   90....       MOV     DPTR,#macTxActive
   \   0000EB   E0           MOVX    A,@DPTR
   \   0000EC   6485         XRL     A,#0x85
   \   0000EE   7008         JNZ     ??rxStartIsr_12
    514            {
    515              macTxAckNotReceivedCallback();
   \   0000F0                ; Setup parameters for call to function macTxAckNotReceivedCallback
   \   0000F0   90....       MOV     DPTR,#(macTxAckNotReceivedCallback & 0xffff)
   \   0000F3   74..         MOV     A,#((macTxAckNotReceivedCallback >> 16) & 0xff)
   \   0000F5   12....       LCALL   ?BCALL               ; Banked call to: DPTR()
    516            }
    517          
    518            /*-------------------------------------------------------------------------------
    519             *  Apply filtering.
    520             *
    521             *  For efficiency, see if filtering is even 'on' before processing.  Also test
    522             *  to make sure promiscuous mode is disabled.  If promiscuous mode is enabled,
    523             *  do not apply filtering.
    524             */
    525            if ((rxFilter != RX_FILTER_OFF) && !rxPromiscuousMode)
   \                     ??rxStartIsr_12:
   \   0000F8   90....       MOV     DPTR,#??rxFilter
   \   0000FB   E0           MOVX    A,@DPTR
   \   0000FC   6024         JZ      ??rxStartIsr_13
   \   0000FE   90....       MOV     DPTR,#??rxPromiscuousMode
   \   000101   E0           MOVX    A,@DPTR
   \   000102   701E         JNZ     ??rxStartIsr_13
    526            {
    527              if (/* filter all frames */
    528                   (rxFilter == RX_FILTER_ALL) ||
    529          
    530                   /* filter non-beacon frames */
    531                   ((rxFilter == RX_FILTER_NON_BEACON_FRAMES) &&
    532                    (MAC_FRAME_TYPE(&rxBuf[1]) != MAC_FRAME_TYPE_BEACON)) ||
    533          
    534                   /* filter non-command frames */
    535                   ((rxFilter == RX_FILTER_NON_COMMAND_FRAMES) &&
    536                    ((MAC_FRAME_TYPE(&rxBuf[1]) != MAC_FRAME_TYPE_COMMAND))))
   \   000104   90....       MOV     DPTR,#??rxFilter
   \   000107   E0           MOVX    A,@DPTR
   \   000108   6401         XRL     A,#0x1
   \   00010A   7003         JNZ     $+5
   \   00010C   02....       LJMP    ??rxStartIsr_14 & 0xFFFF
   \   00010F   E0           MOVX    A,@DPTR
   \   0

⌨️ 快捷键说明

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