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

📄 streamisr.c

📁 This network protcol stack,it is very strong and powerful!
💻 C
字号:
/************************************************************************************
* Implements Rx and Tx streaming interrupts
*
* Author(s):
*   Thomas O. Jensen, Jesper Thomsen
*
* (c) Copyright 2004, Freescale, Inc.  All rights reserved.
*
* Freescale Confidential Proprietary
* Digianswer Confidential
*
* No part of this document must be reproduced in any form - including copied,
* transcribed, printed or by any electronic means - without specific written
* permission from Freescale.
*
* Last Inspected:
* Last Tested:
************************************************************************************/

#include "Phy.h"
#include "MacPhy.h"

/************************************************************************************
*************************************************************************************
* Private macros
*************************************************************************************
************************************************************************************/

/************************************************************************************
*************************************************************************************
* Private prototypes
*************************************************************************************
************************************************************************************/
bool_t PhyCheckAddrMode(uint8_t);
void DummyFastIsr(void);

/************************************************************************************
*************************************************************************************
* Private type definitions
*************************************************************************************
************************************************************************************/

/************************************************************************************
*************************************************************************************
* Public memory declarations
*************************************************************************************
************************************************************************************/

/************************************************************************************
*************************************************************************************
* Private memory declarations
*************************************************************************************
************************************************************************************/

/************************************************************************************
*************************************************************************************
* Public functions
*************************************************************************************
************************************************************************************/
#ifndef USE_INTERRUPT_TXEOF
extern void PollForTx(void);
#endif


/************************************************************************************
* First streaming interrupt
* When a streaming Rx interrupt occurs, copy length into data buffer and get timestamp
*
* Interface assumptions:
*
* Return value:
*   NONE
*
* Revision history:
*
*    Date    Author    Comments
*   ------   ------    --------
*   280104   JT        Created IrqStreamingRxFirst
*
************************************************************************************/
#ifdef I_AM_A_SNIFFER
  extern uint8_t SnifferPacketCounter;
#endif I_AM_A_SNIFFER
  
void IrqStreamingRxFirst(void)
{
  // Assert if not in rx state
  DigiAssert(PHY_ASSERT, mPhyTxRxState==cBusy_Rx);
  SETTIMINGPIN_3

#ifdef I_AM_A_SNIFFER
//  GREEN_LED_ON;
  // Read timestamp for reception
  ABEL_READ_INT(ABEL_TIMESTAMP_MSB_REG, (gpPhyRxData->headerLength) ); 
  ABEL_READ_INT(ABEL_TIMESTAMP_LSB_REG, (gpPhyRxData->timeStampAbelLSB1) ); 
  gpPhyRxData->timeStampMCU = TPM1C1VH; // Both bytes (H/L) needs to be read before the buffer gets unlatched.  
  gpPhyRxData->timeStampMCU = TPM1C1VL & 0x0f; // Use this element in the structure to store timestamp (only 4 bit)
  gpPhyRxData->headerLength = SnifferPacketCounter++; // Overwrite the first timestamp with counter. The first timestamp is not valid anyway
#endif I_AM_A_SNIFFER

  // Read Link Quality / Length from Abel
  ABEL_READ_INT_SWAP(ABEL_ENERGYLVL_REG, (gpPhyRxData->frameLength) );  // Reads both Length and LQ to buffer
  if((gpPhyRxData->frameLength < gMacMinHeaderLengthAck_c)){
    // Check for illegal length. 
    // We choose 5 as minimum as for valid MAC packets,but one may argue for 2 as limited by HW. 
    // Choosing 2 would require additional check in async part for packets less than 5. 

    mpfPendingSetup = SetupPendingNop;
    SetupPendingProtected();          // Kill current Rx
    DoFastRxEofCrcInvalid();    // Restart everything like if the Crc was invalid
    CLRTIMINGPIN_3
    return;
  }

    // Read timestamp for reception
  ABEL_READ_BURST_L_INT(ABEL_TIMESTAMP_MSB_REG, (zbClock16_t*)&gRxTimeStamp24); // adjustment for drift and latching time (2symb) cancelled out by propagation delay (~24 us) in rx/tx chain.
  gRxTimeStamp=(zbClock16_t) gRxTimeStamp24;

    // Init "async abort flag" and "bad packet indicator flag"
  gStopAsyncRx = FALSE;

  gIsrAsyncTailFunction = IrqAsyncRxFilterEntry;
  gIsrFastAction = IrqStreamingRx;
  CLRTIMINGPIN_3
}

/************************************************************************************
* Normal streaming Rx interrupt
* When a streaming Rx interrupt occurs, copy data word into data buffer
*
* Interface assumptions:
*
* Return value:
*   NONE
*
* Revision history:
*
*    Date    Author    Comments
*   ------   ------    --------
*   010903   TOJ       Created
*   080903   JT        Added IrqStreamingRx
*   280104   JT        Moved first isr to seperate function 
*
************************************************************************************/
void IrqStreamingRx(void)
{
  SETTIMINGPIN_3
    // Read data from Abel (this also clears RxStream irq)
  ABEL_READ_INT_SWAP(RX_DATA, *gpPhyPacketHead);
  gpPhyPacketHead+=2;
  gPhyMacDataRxIndex+=2;
  CLRTIMINGPIN_3
}

/************************************************************************************
* When a streaming Tx interrupt occurs, copy data word from data buffer to Abel
*
* Interface assumptions:
*
* Return value:
*   NONE
*
* Revision history:
*
*    Date    Author    Comments
*   ------   ------    --------
*   090903   JT        Created
*
************************************************************************************/
void IrqStreamingTx(void)
{
  uint16_t tmpData;

    // Assert if not in tx state
  DigiAssert(PHY_ASSERT,(mPhyTxRxState==cBusy_Tx));
  DigiAssert(PHY_ASSERT, gPhyMacDataTxIndex!=0);

    // Copy data from data buffer to Abel
  tmpData = gpPhyTxPacket[gPhyMacDataTxIndex] | (gpPhyTxPacket[gPhyMacDataTxIndex+1] << 8);
  ABEL_WRITE_INT(TX_DATA, tmpData);
  
  gPhyMacDataTxIndex+=2;
  gTxRemainingLength-=2;

  if (gTxRemainingLength <= 0) {
#ifndef USE_INTERRUPT_TXEOF
    gIsrFastAction = DummyFastIsr;
    gIsrAsyncTailFunction = PollForTx;
#else
    gIsrFastAction = DoFastTxEof;
#endif
  }
}

/************************************************************************************
*************************************************************************************
* Private functions
*************************************************************************************
************************************************************************************/

/************************************************************************************
*************************************************************************************
* Module debug stuff
*************************************************************************************
************************************************************************************/




/************************************************************************************
*************************************************************************************
* Level 1 block comment
*************************************************************************************
************************************************************************************/

//-----------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------
// Level 2 block comment
//-----------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------

/* Level 3 block comment */




// Delimiters

/***********************************************************************************/

//-----------------------------------------------------------------------------------

⌨️ 快捷键说明

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