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

📄 setrxtxstate.c

📁 This network protcol stack,it is very strong and powerful!
💻 C
📖 第 1 页 / 共 2 页
字号:
#endif



// HACK: Set threshold to normal for Rx
void SetCorrThresholdNormal(){
  ABEL_WRITE_INT(ABEL_reg38, 0x0008); // Set correlation threshold to normal value
}

// HACK: CCA-Rx issue. Set threshold to max value for Ed and Cca to prevent correlation
void SetCorrThresholdHigh(){
  ABEL_WRITE_INT(ABEL_reg38, 0x03FF); // Set correlation threshold to high value
}


// Helper function for action setup (used to save code, not used with tx due to tight critical path)
void SetupAction(uint16_t command)
{
  RxTxDisable                  // RxTxEnable = 0;
  ABEL_WRITE_INT_FAST(ABEL_CONTROL_REG, command);
  RxTxEnable                   // RxTxEnable = 1;
}

void SetupPendingTx(void)
{
  uint16_t command = cTX_STRM | cTX_SENT_MASK | SEQ_T | cTMR_TRIG_EN;
  SetupAction(command);
  TX_ANTENNE_ENABLED  
  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);
  RX_ANTENNE_ENABLED
  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);
  RX_ANTENNE_ENABLED
  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;

  RX_DISABLE_LNA;
  TX_DISABLE_PA;
  mPhyTxRxState=cIdle;
  SetupAction(command);
}

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

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

void SetupPendingProtected(void){
  DISABLE_ALL_INTERRUPTS  
  mpfPendingSetup();
  mpfPendingSetup=NULL;
  CODE_PROFILING_CLRPIN_1
  ENABLE_ALL_INTERRUPTS
}


/************************************************************************************
* 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
    gIsrSuperFastAction = NULL;
    gIsrFastAction = DummyFastIsr;
    gIsrAsyncTailFunction = DummyFastIsr;
    DisableEventTimeout();
      // Clear ABEL status register... we are now IDLE!!!!!!!!
    {uint16_t retReg; CLEAR_IRQ_STATUSREG(retReg);}
}

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