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

📄 setrxtxstate.c

📁 freescale的基于802.15.4的无线通讯例程
💻 C
📖 第 1 页 / 共 2 页
字号:
void SetCorrThresholdNormal(){
}
void SetCorrThresholdHigh(){
}
#endif //DO_NOT_TOGGLE_SYNCH_THRESHOLD

// Helper function for action setup (used to save code, not used with tx due to tight critical path)
void SetupAction(uint16_t command)
{
#if gTransceiverType_d == gMC1319x_c
  MC1319xDrv_RxTxDisable(); // We need to force the transceiver into idle state when using abel.
#endif // gTransceiverType_d == gMC1319x_c

  MC1319xDrv_WriteSpiSyncFast(ABEL_CONTROL_REG, command);

#if gTransceiverType_d == gMC1319x_c  
  MC1319xDrv_RxTxEnable();
#endif // gTransceiverType_d == gMC1319x_c
}

void SetupPendingTx(void)
{
  uint16_t command = cTX_STRM | cTX_SENT_MASK | SEQ_T | cTMR_TRIG_EN;
  SetupAction(command);
  MC1319xDrv_TxAntennaSwitchEnable();  
  mPhyTxRxState=cBusy_Tx;
  gIsrPendingFastAction = IrqStreamingTx; 
}

void SetupPendingRx(void)
{
  uint16_t command = cRX_RCV_ALL | cRX_STRM | cRX_RCVD_MASK | SEQ_RT | cRX_AGC | cTMR_TRIG_EN;
  SetupAction(command);
  MC1319xDrv_RxAntennaSwitchEnable();
  mPhyTxRxState=cBusy_Rx;
  gIsrPendingFastAction = IrqStreamingRxFirst; 
}

void SetupImmediateRx(void)
{
  uint16_t command = cRX_RCV_ALL | cRX_STRM | cRX_RCVD_MASK | SEQ_RT | cRX_AGC;
  SetupAction(command);
  MC1319xDrv_RxAntennaSwitchEnable();
  mPhyTxRxState=cBusy_Rx;
}

void SetupPendingTtNop(void)
{
  uint16_t command=SEQ_NOP | cTMR_TRIG_EN;
  mPhyTxRxState=cBusy_Wait;
  SetupAction(command);
  gIsrPendingFastAction = DummyFastIsr;
}

void SetupPendingNop(void)
{
  uint16_t command=SEQ_NOP;

  MC1319xDrv_RxLnaDisable();
  MC1319xDrv_TxPaDisable();
  mPhyTxRxState=cIdle;
  SetupAction(command);
}

void SetupPendingCca(void)
{
  uint16_t command = cCCA_MASK | cCCA_MODE0 | SEQ_C | cTMR_TRIG_EN;
  SetupAction(command);
  MC1319xDrv_RxAntennaSwitchEnable();
  mPhyTxRxState = cRxCCA;
  gIsrPendingFastAction=DoFastCcaEof;
}

void SetupPendingEd(void)
{
  uint16_t command = cCCA_MASK | cCCA_ED | SEQ_C | cTMR_TRIG_EN;
  SetupAction(command);
  MC1319xDrv_RxAntennaSwitchEnable();
  mPhyTxRxState = cRxED;
  gIsrPendingFastAction=DoFastEdEof;
}

void SetupPendingProtected(void){
  IrqControlLib_DisableAllIrqs();  
  mpfPendingSetup();
  mpfPendingSetup=NULL;
  CODE_PROFILING_CLRPIN_1
  IrqControlLib_EnableAllIrqs();
}


/************************************************************************************
* Wait request 
* Setup wait as pending action if Phy is busy. Enter wait otherwise 
*
* Interface assumptions:
*
*
* Return value:
*   NONE
*
* Revision history:
*
*    Date    Author    Comments
*   ------   ------    --------
*   191203   JT        Created
*
************************************************************************************/
void PhyPlmeWaitRequest(void)
{
  mpfPendingSetup = SetupPendingTtNop; 
  SetupPendingProtected();
}


/************************************************************************************
* Force Trx state in PHY layer to idle
*
* Interface assumptions:
*
*
* Return value:
*   NONE
*
* Revision history:
*
*    Date    Author    Comments
*   ------   ------    --------
*   010903   TOJ       Created
*   050903   JT        Features added
*   081004   JT        Separated from SetTrxStateRequest
*
************************************************************************************/
void PhyPlmeForceTrxOffRequest(void){
    mpfPendingSetup = SetupPendingNop;
    SetupPendingProtected();

    gIsrPendingFastAction=NULL;
    
      // Reset pointers and Timeout
    gIsrFastAction = DummyFastIsr;
    gIsrAsyncTailFunction = DummyFastIsr;
    DisableEventTimeout();
      
    {
        // Clear MC1319x status register... we are now IDLE!!!!!!!!
      uint16_t retReg;
      MC1319xDrv_ReadSpiAsync(ABEL_reg24, &retReg);  // Clears all pending MC1319x interrupt 
      IrqControlLib_AckMC1319xIrq();                // Ack irqs in mcu if any latched
    }
}

/************************************************************************************
* Set state in PHY layer to Rx
* Setup Rx as pending action if Phy is busy. Enter Rx otherwise 
*
* Interface assumptions:
*
*
* Return value:
*   NONE
*
* Revision history:
*
*    Date    Author    Comments
*   ------   ------    --------
*   010903   TOJ       Created
*   050903   JT        Features added
*   081004   JT        Separated from SetTrxStateRequest
*
************************************************************************************/
void PhyPlmeRxRequest(void){
    mpfPendingSetup = SetupPendingRx;
    if (mPhyTxRxState==cIdle){  // Is Abel running, so that command must be pended?
        // Setup action immediately 
      SetupPendingProtected(); // Not really pending at this point, but this saves code! (clears mpfPendingSetup)
    }
}

/************************************************************************************
* Set state in PHY layer to Tx
* Setup Tx as pending action if Phy is busy. Enter Tx otherwise 
*
* Interface assumptions:
*
*
* Return value:
*   NONE
*
* Revision history:
*
*    Date    Author    Comments
*   ------   ------    --------
*   010903   TOJ       Created
*   050903   JT        Features added
*   081004   JT        Separated from SetTrxStateRequest
*
************************************************************************************/
void PhyPlmeTxRequest(void){
    mpfPendingSetup = SetupPendingTx;
    if (mPhyTxRxState==cIdle){  // Is Abel running, so that command must be pended?
        // Setup action immediately 
      SetupPendingProtected(); // Not really pending at this point, but this saves code! (clears mpfPendingSetup)
    }
}

/************************************************************************************
*************************************************************************************
* 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 + -