📄 mac_rx.lst
字号:
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
\ 000110 6402 XRL A,#0x2
\ 000112 6003 JZ $+5
\ 000114 02.... LJMP ??rxStartIsr_15 & 0xFFFF
\ 000117 90.... MOV DPTR,#(??rxBuf + 1)
\ 00011A E0 MOVX A,@DPTR
\ 00011B 5407 ANL A,#0x7
\ 00011D 6003 JZ $+5
\ 00011F 02.... LJMP ??rxStartIsr_14 & 0xFFFF
537 {
538 /* discard rest of frame */
539 rxDiscardFrame();
540 return;
541 }
542 }
543
544 /*-------------------------------------------------------------------------------
545 * Compute length of addressing fields. Compute payload length.
546 */
547
548 /* decode addressing modes */
549 dstAddrMode = MAC_DEST_ADDR_MODE(&rxBuf[1]);
\ ??rxStartIsr_13:
\ 000122 90.... MOV DPTR,#(??rxBuf + 2)
\ 000125 E0 MOVX A,@DPTR
\ 000126 FA MOV R2,A
\ 000127 13 RRC A
\ 000128 13 RRC A
\ 000129 543F ANL A,#0x3f
\ 00012B 5403 ANL A,#0x3
\ 00012D F5.. MOV ?V0 + 0,A
550 srcAddrMode = MAC_SRC_ADDR_MODE(&rxBuf[1]);
\ 00012F EA MOV A,R2
\ 000130 C4 SWAP A
\ 000131 13 RRC A
\ 000132 13 RRC A
\ 000133 5403 ANL A,#0x3
\ 000135 F5.. MOV ?V0 + 1,A
551
552 /*
553 * Workaround for chip bug. The receive buffer can sometimes be corrupted by hardware.
554 * This usually occurs under heavy traffic. If a corrupted receive buffer is detected
555 * the entire receive buffer is flushed.
556 */
557 #ifdef MAC_RADIO_RXBUFF_CHIP_BUG
558 if ((srcAddrMode == ADDR_MODE_RESERVERED) || (dstAddrMode == ADDR_MODE_RESERVERED))
\ 000137 7401 MOV A,#0x1
\ 000139 65.. XRL A,?V0 + 1
\ 00013B 7003 JNZ $+5
\ 00013D 02.... LJMP ??rxStartIsr_6 & 0xFFFF
\ 000140 7401 MOV A,#0x1
\ 000142 65.. XRL A,?V0 + 0
\ 000144 7003 JNZ $+5
\ 000146 02.... LJMP ??rxStartIsr_6 & 0xFFFF
559 {
560 MAC_RADIO_FLUSH_RX_FIFO();
561 rxDone();
562 return;
563 }
564 #endif
565
566 /*
567 * C
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -