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

📄 eof.c

📁 This network protcol stack,it is very strong and powerful!
💻 C
📖 第 1 页 / 共 2 页
字号:
/************************************************************************************
* End of frames are handled here. Called from TxDone and RxDone interrupts in Abel.
*
* 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 "DigiType.h"
#include "Phy.h"
#include "PhyMacMsg.h"
#include "MacPhy.h"

/************************************************************************************
*************************************************************************************
* Private macros
*************************************************************************************
************************************************************************************/
#if !(defined(USE_INTERRUPT_RXEOF) && defined(USE_INTERRUPT_TXEOF) )
#define POLL_UNTIL_IDLE {while(IsAbelActive());}
#endif 

#ifdef USE_INTERRUPT_TXEOF
#define DELAY_5US 
#else
#define DELAY_5US { {uint8_t i=10; do {} while(--i);}  }
#endif

/************************************************************************************
*************************************************************************************
* Private prototypes
*************************************************************************************
************************************************************************************/
bool_t PhyCheckAddrMode(uint8_t addrMode);
void (*gIsrSuperFastAction)(void);
/************************************************************************************
*************************************************************************************
* Private type definitions
*************************************************************************************
************************************************************************************/

/************************************************************************************
*************************************************************************************
* Public memory declarations
*************************************************************************************
************************************************************************************/
extern bool_t gPanIdConflict;


#ifdef I_AM_A_SNIFFER
extern rxPacket_t gRxDataBuffer;
rxPacket_t gRxDataBuffer2;
rxPacket_t * gpRxDataToBeSentOnHostInterface  = NULL;  
uint8_t SnifferPacketCounter = 0;
#endif I_AM_A_SNIFFER

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

/************************************************************************************
*************************************************************************************
* Public functions
*************************************************************************************
************************************************************************************/

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

/************************************************************************************
* Fast Eof interrupt routine for Ed.
*
* Interface assumptions:
*   Fast action setup
*
* Return value:
*   NONE
*
* Revision history:
*
*    Date    Author    Comments
*   ------   ------    --------
*   061003   TOJ       Created 
*   041004   JT        Separated from CCA  
*
************************************************************************************/
void DoFastEdEof(void)
{
  uint8_t energyLevel;

  RX_DISABLE_LNA;
  CODE_PROFILING_SETPIN_0;
  mPhyTxRxState=cIdle;
  gIsrFastAction = DummyFastIsr;

  energyLevel=GetEnergyLevel();

  PhyPlmeEdConfirm(energyLevel);
  gIsrMask = ~cCCA_IRQ;
}

/************************************************************************************
* Fast Eof interrupt routine for CCA
*
* Interface assumptions:
*   Fast action setup
*
* Return value:
*   NONE
*
* Revision history:
*
*    Date    Author    Comments
*   ------   ------    --------
*   061003   TOJ       Created 
*   041004   JT        Separated from ED  
*
************************************************************************************/
void DoFastCcaEof(void)
{
  RX_DISABLE_LNA;
  mPhyTxRxState=cIdle;

  if (IsAbelCcaBusy()){
    mpfPendingSetup = NULL; // Prevent Tx action setup when channel busy
    CODE_PROFILING_SETPIN_0;
  }
  if (mpfPendingSetup) {
    SetupPendingProtected();
  }

  gIsrFastAction = DummyFastIsr;
  PhyPlmeCcaConfirm(IsAbelCcaBusy());  // Pass message 
  gIsrMask = ~cCCA_IRQ;
}



/************************************************************************************
* In order to speed up EOF generation, it is possible to poll Abel GPIO's. This
* busy-waiting scheme is only suggested if timing does not allow use of interrupt!
*
* After calling this function, the TxEof routine is automatically exectuted
* (transparent to the system whether from poll or interrupt).
*
* Interface assumptions:
*   Fast action setup
*
* Return value:
*   NONE
*
* Revision history:
*
*    Date    Author    Comments
*   ------   ------    --------
*   061003   TOJ       Created 
*
************************************************************************************/
void DoFastTxEof(void)
{
  TX_DISABLE_PA;  
    // Enter here on expected EOF
    // Assert if not in tx state
  if (mPhyTxRxState != cBusy_Tx) return;  // EOF assumed to be generated due to action abort by sequential action
    // Set state to idle
  mPhyTxRxState=cIdle;
  gIsrFastAction = DummyFastIsr;

  if (mpfPendingSetup) {
    SetupPendingProtected();
  }
  else{
    CODE_PROFILING_SETPIN_0;
    if(IsCurrentActionAutoRx()){
      mpfPendingSetup = SetupImmediateRx; // Fall back to Rx if in Auto Rx mode
      SetupPendingProtected();
    }
  }

    // Send Data.confirm to MAC
  PhyPdDataConfirm();
  gIsrMask = ~cTX_DONE;
}


/************************************************************************************
* In order to speed up EOF generation, it is possible to poll Abel GPIO's. This
* busy-waiting scheme is only suggested if timing does not allow use of interrupt!
*
* These two functions serve as the fast actions on Eof. The functions are called 
* according to the status of the crc. (Set up in super fast action).
* In the busy wait scenario these functions are called directly from the polling routine. 
*
* Interface assumptions:
*   Fast action 
*
* Return value:
*   NONE
*
* Revision history:
*
*    Date    Author    Comments
*   ------   ------    --------
*   061003   TOJ       Created 
*   170204   JT        Updated 
*
************************************************************************************/
void DoFastRxEofCrcValid(void)
{
  gIsrAsyncTailFunction = DummyFastIsr;
  gIsrFastAction = DummyFastIsr;

  if(IsCurrentActionAutoRx()){
    gIsrMask = ~(cRX_DONE);
  }
  else {
    DisableEventTimeout();
    gIsrMask = ~(cRX_DONE | cTMR4_IRQ);
  }
  ConvertLinkQuality();
  PhyPdDataIndication();
}


void DoFastRxEofCrcInvalid(void)
{
  RestartRxOrTimeout();                               // Handle CRC failure the same way as when aborting Rx in Filter
  gIsrMask = ~(cRX_DONE | cTMR2_IRQ | cRX_RCVD_IRQ);  // cRX_RCVD_IRQ added in case function called from RxStreamIsr
}



#ifdef USE_INTERRUPT_RXEOF
/************************************************************************************
* In order to speed up EOF generation, it is possible to poll Abel GPIO's. This
* busy-waiting scheme is only suggested if timing does not allow use of interrupt!
*
* Since the Eof on Rx is delayed we need to setup a pending action ASAP in the Eof 
* interrupt. So this super-fast action is called. An interruptable fast action is 
* setup depending on the crc status.  
*
* Interface assumptions:
*   Superfast action setup with interrupts disabled.
*
* Return value:
*   NONE
*
* Revision history:
*
*    Date    Author    Comments
*   ------   ------    --------
*   240204   JT       Created 
*
************************************************************************************/
#ifndef I_AM_A_SNIFFER
void DoSuperFastRxEof(void)
{
  RX_DISABLE_LNA;
  if(IsAbelCrcOk()){
    if (gBeaconWithBadSrcDetected) {
      gBeaconWithBadSrcDetected = FALSE;
      if (gpPhyRxData->rxData[gpPhyRxData->headerLength + 1] & 0x40) { // chech PAN coordinator bit in beacon superframe spec. (bit 14)
        gPanIdConflict= TRUE;
        gIsrFastAction = DoFastRxEofCrcInvalid;
        return;
      }
    }
    if (mpfPendingSetup) {
      mpfPendingSetup();  // Does not disable or enable interrupts, which is desired here 
      mpfPendingSetup=NULL;

⌨️ 快捷键说明

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