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

📄 eof.c

📁 freescale的基于802.15.4的无线通讯例程
💻 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 "MacPhyGlobalHdr.h"
#include "Mc1319xDrv.h"
#include "IrqControlLib.h"
#include "Phy.h"
#include "PhyMacMsg.h"
#include "MacPhy.h"
//#include "MlmeMain.h"

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

#if 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);
/************************************************************************************
*************************************************************************************
* Private type definitions
*************************************************************************************
************************************************************************************/

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

#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;

  MC1319xDrv_RxLnaDisable();
  CODE_PROFILING_SETPIN_0;
  mPhyTxRxState=cIdle;
  gIsrFastAction = DummyFastIsr;

  energyLevel=GetEnergyLevel();

  PhyPlmeEdConfirm(energyLevel);
  gIsrMask = (uint16_t) ~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)
{
  register bool_t channel_busy;
  MC1319xDrv_RxLnaDisable();
  mPhyTxRxState=cIdle;

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

  gIsrFastAction = DummyFastIsr;
  PhyPlmeCcaConfirm(channel_busy);  // Pass message 
  gIsrMask = (uint16_t) ~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)
{
    // 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();
    }
  }
    // Disable PA if present
  MC1319xDrv_TxPaDisable();   // Allowed after action setup, as Tx-Tx is not possible

    // Send Data.confirm to MAC
  PhyPdDataConfirm();
  gIsrMask = (uint16_t) ~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 = (uint16_t) ~(cRX_DONE);
  }
  else {
    DisableEventTimeout();
    gIsrMask = (uint16_t) ~(cRX_DONE | cTMR4_IRQ);
  }
  ConvertLinkQuality();
  PhyPdDataIndication();
}


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




/************************************************************************************
* 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.   
*
* Interface assumptions:
*   Fast action setup with.
*
* Return value:
*   NONE
*
* Revision history:
*
*    Date    Author    Comments
*   ------   ------    --------

⌨️ 快捷键说明

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