Ejemplo n.º 1
0
/**************************************************************************************************
 * @fn          macTxStartQueuedFrame
 *
 * @brief       See if there is a queued frame waiting to transmit.  If so, initiate
 *              the transmit now.
 *
 * @param       none
 *
 * @return      none
 **************************************************************************************************
 */
MAC_INTERNAL_API void macTxStartQueuedFrame(void)
{
  halIntState_t  s;

  MAC_ASSERT(!macRxActive && !macRxOutgoingAckFlag); /* queued frames should not transmit in middle of a receive */

  /*
   *  Critical sections around the state change prevents any sort of race condition
   *  with macTxFrame().  This guarantees function txGo() will only be be called once.
   */
  HAL_ENTER_CRITICAL_SECTION(s);
  if (macTxActive == MAC_TX_ACTIVE_QUEUED)
  {
    macTxActive = MAC_TX_ACTIVE_GO;
    HAL_EXIT_CRITICAL_SECTION(s);
    txGo();
  }
  else
  {
    HAL_EXIT_CRITICAL_SECTION(s);
  }
}
Ejemplo n.º 2
0
/**************************************************************************************************
 * @fn          macTxFrame
 *
 * @brief       Transmit the frame pointed to by pMacDataTx with the specified type.
 *              NOTE! It is not legal to call this function from interrupt context.
 *
 * @param       txType - type of transmit
 *
 * @return      none
 **************************************************************************************************
 */
MAC_INTERNAL_API void macTxFrame(uint8 txType)
{
  MAC_ASSERT(!macTxActive);            /* transmit on top of transmit */

  /* mark transmit as active */
  macTxActive = MAC_TX_ACTIVE_INITIALIZE;

  /*
   *  The MAC will not enter sleep mode if there is an active transmit.  However, if macSleep() is
   *  ever called from interrupt context, it possible to enter sleep state after a transmit is
   *  intiated but before macTxActive is set.  To recover from this, the transmit must be aborted
   *  and proper notificiation given to high-level.
   */
  if (macSleepState != MAC_SLEEP_STATE_AWAKE)
  {
    /* notify high-level that transmit had to be aborted */
    txComplete(MAC_TX_ABORTED);

    /* exit from transmit logic */
    return;
  }

  /* save transmit type */
  macTxType = txType;

  /*-------------------------------------------------------------------------------
   *  Prepare for transmit.
   */
  if (macTxType == MAC_TX_TYPE_SLOTTED)
  {
    MAC_RADIO_TX_PREP_SLOTTED();
  }

#ifdef FEATURE_GREEN_POWER
  else if (macTxType == MAC_TX_TYPE_GREEN_POWER)
  {
    txGreenPowerPrep();
  }
#endif /* #ifdef FEATURE_GREEN_POWER */

  else
  {
    MAC_ASSERT((macTxType == MAC_TX_TYPE_SLOTTED_CSMA) || (macTxType == MAC_TX_TYPE_UNSLOTTED_CSMA));

    nb = 0;
    macTxBe = (pMacDataTx->internal.txOptions & MAC_TXOPTION_ALT_BE) ? pMacPib->altBe : pMacPib->minBe;

    if ((macTxType == MAC_TX_TYPE_SLOTTED_CSMA) && (pMacPib->battLifeExt))
    {
      macTxBe = MIN(2, macTxBe);
    }

    txCsmaPrep();
  }

  /*-------------------------------------------------------------------------------
   *  Load transmit FIFO unless this is a retransmit.  No need to write
   *  the FIFO again in that case.
   */
  if (!txRetransmitFlag)
  {
    uint8 * p;
    uint8   lenMhrMsdu;

    MAC_ASSERT(pMacDataTx != NULL); /* must have data to transmit */

    /* save needed parameters */
    txAckReq = MAC_ACK_REQUEST(pMacDataTx->msdu.p);
    txSeqn   = MAC_SEQ_NUMBER(pMacDataTx->msdu.p);

    /* set length of frame (note: use of term msdu is a misnomer, here it's actually mhr + msdu) */
    lenMhrMsdu = pMacDataTx->msdu.len;

    /* calling code guarantees an unused prepended byte  */
    p = pMacDataTx->msdu.p - PREPENDED_BYTE_LEN;

    /* first byte of buffer is length of MPDU */
    *p = lenMhrMsdu + MFR_LEN;

    /*
     *  Flush the TX FIFO.  This is necessary in case the previous transmit was never
     *  actually sent (e.g. CSMA failed without strobing TXON).  If bytes are written to
     *  the FIFO but not transmitted, they remain in the FIFO to be transmitted whenever
     *  a strobe of TXON does happen.
     */
    MAC_RADIO_FLUSH_TX_FIFO();

    /* write bytes to FIFO, prepended byte is included, MFR is not (it's generated by hardware) */
    MAC_RADIO_WRITE_TX_FIFO(p, PREPENDED_BYTE_LEN + lenMhrMsdu);
  }

  /*-------------------------------------------------------------------------------
   *  If not receiving, start the transmit.  If receive is active
   *  queue up the transmit.
   *
   *  Critical sections around the state change prevents any sort of race condition
   *  with  macTxStartQueuedFrame().  This guarantees function txGo() will only be
   *  called once.
   */
  {
    halIntState_t  s;

    HAL_ENTER_CRITICAL_SECTION(s);
    if (!macRxActive && !macRxOutgoingAckFlag)
    {
      macTxActive = MAC_TX_ACTIVE_GO;
      HAL_EXIT_CRITICAL_SECTION(s);
      txGo();
    }
    else
    {
      macTxActive = MAC_TX_ACTIVE_QUEUED;
      HAL_EXIT_CRITICAL_SECTION(s);
    }
  }
}
Ejemplo n.º 3
0
extern "C" int main(int argc, char *argv[])
{
	const char* str = "local";
//	CWrapper *cw = new CWrapper(str);
	UINT_32	val;
	INT_32	ret;
	INT_32 	select = 0;
	
	CWrapper::Initialize(str);

	while(1){
		printf("1:Enter test mode\n");
		printf("2:Enter normal mode\n");
		printf("3:Enter standby mode\n");
		printf("4:set EEPROM size to 512\n");
		printf("5:setEEPRomFromFile /data/eeprom.mobile\n");
		printf("6:setEEPromCKSUpdated\n");
		printf("7:getPacketTxStatusEx\n");
		printf("8:getPacketRxStatus\n");
		printf("9:setOutputPower\n");
		printf("10:setLocalFrequecy\n");
		printf("11:setCarrierSuppression\n");
		printf("12:setChannel\n");
		printf("14:writeEEPRom16\n");
		printf("15:eepromWriteByteStr\n");
		printf("16:setATParam(13, 1) -retry limit\n");
		printf("19:queryThermoInfo\n");
		printf("20:getEEPRomSize\n");
		printf("22:MCR32 read and write\n");
		printf("24:tx test\n");
		printf("25:rx test\n");
		printf("26:unInitialize\n");
		
		
		printf("Please Input Your the Selection of Test:\n");
		
		scanf("%d", &select);

		if(select > 24){
			printf("Incorrect  input.\n");
			break;
		}	

		ret = -1;
		switch(select){		
		case 1:		
		ret = CWrapper::setTestMode();
		if(ERROR_RFTEST_SUCCESS != ret)
			em_printf(MSG_ERROR, "%s %d failed\n", __FILE__, __LINE__);
		break;

		case 2:
		ret = CWrapper::setNormalMode();
		if(ERROR_RFTEST_SUCCESS != ret)
			em_printf(MSG_ERROR, "%s %d failed\n", __FILE__, __LINE__);
		break;

		case 3:
		ret = CWrapper::setStandBy();
		if(ERROR_RFTEST_SUCCESS != ret)
			em_printf(MSG_ERROR, "%s %d failed\n", __FILE__, __LINE__);
		break;

		case 4:
		ret = CWrapper::setEEPRomSize(512);
		if(ERROR_RFTEST_SUCCESS != ret)
			em_printf(MSG_ERROR, "%s %d failed\n", __FILE__, __LINE__);
		break;

		case 5:
		ret = CWrapper::setEEPRomFromFile ("/data/eeprom.mobile");
		if(ERROR_RFTEST_SUCCESS != ret)
			em_printf(MSG_ERROR, "%s %d failed\n", __FILE__, __LINE__);
		break;
#if 0
		INT_32 i4TxPwrGain, i4Eirp, i4ThermoVal;
		ret = CWrapper::readTxPowerFromEEPromEx (chnlList[6].chnlFreq,
						rateSetting[0].i4RateCfg, 
						&i4TxPwrGain, &i4Eirp, &i4ThermoVal);
		if(ERROR_RFTEST_SUCCESS != ret)
			em_printf(MSG_ERROR, "%s %s failed\n", __FILE__, __LINE__);
		else
			em_printf(MSG_DEBUG, "i4TxPwrGain %d, i4Eirp %d, i4ThermoVal %d \n",
						i4TxPwrGain, i4Eirp, i4ThermoVal);
#endif
		case 6:
		ret = CWrapper::setEEPromCKSUpdated ();
		if(ERROR_RFTEST_SUCCESS != ret)
			em_printf(MSG_ERROR, "%s %d failed\n", __FILE__, __LINE__);
		break;
		
		case 7:
		{
		INT_32 i4SentCount, i4AckCount, i4Alc, i4CckGainControl, i4OfdmGainControl;
		ret = CWrapper::getPacketTxStatusEx ( &i4SentCount, &i4AckCount, &i4Alc, &i4CckGainControl, &i4OfdmGainControl);
		if(ERROR_RFTEST_SUCCESS != ret)
			em_printf(MSG_ERROR, "%s %d failed\n", __FILE__, __LINE__);
		else
			em_printf(MSG_DEBUG, "i4SentCount %d, i4AckCount %d, i4AckCount %d, i4Alc %d, i4CckGainControl %d, i4OfdmGainControl %d\n",
					i4SentCount, i4AckCount, i4AckCount, i4Alc, 
					i4CckGainControl, i4OfdmGainControl);
		}
		break;

		case 8:
		INT_32 i4RxOk, i4RxCrcErr;
		ret =  CWrapper::getPacketRxStatus (&i4RxOk, &i4RxCrcErr);
		if(ERROR_RFTEST_SUCCESS != ret)
			em_printf(MSG_ERROR, "%s %d failed\n", __FILE__, __LINE__);
		else
			em_printf(MSG_DEBUG, "getPacketRxStatus: i4RxOk is %d, i4RxCrcErr is %d\n", i4RxOk, i4RxCrcErr);
		break;

		case 9:
		ret = CWrapper::setOutputPower ( rateSetting[0].i4RateCfg,
									20, 0);
		if(ERROR_RFTEST_SUCCESS != ret)
			em_printf(MSG_ERROR, "%s %d failed\n", __FILE__, __LINE__);
		break;
		
		case 10:
		ret =  CWrapper::setLocalFrequecy (20, 0);
		if(ERROR_RFTEST_SUCCESS != ret)
			em_printf(MSG_ERROR, "%s %d failed\n", __FILE__, __LINE__);
		break;
	
		case 11:
		ret = CWrapper::setCarrierSuppression ( 0, 20, 0);
		if(ERROR_RFTEST_SUCCESS != ret)
			em_printf(MSG_ERROR, "%s %d failed\n", __FILE__, __LINE__);
		break;
	/*	ret = CWrapper::setOperatingCountry ( INT_8* acChregDomain);
		if(ERROR_RFTEST_SUCCESS != ret)
			em_printf(MSG_ERROR, "%s %s failed\n", __FILE__, __LINE__);

		cancel, not used
	*/	case 12:	
		
ret = CWrapper::setChannel ( chnlList[6].chnlFreq);
		if(ERROR_RFTEST_SUCCESS != ret)
			em_printf(MSG_ERROR, "%s %d failed\n", __FILE__, __LINE__);
		break;
	/*	ret = CWrapper::getSupportedRates ( UINT_16 *pu2RateBuf, INT_32 i4MaxNum);
		if(ERROR_RFTEST_SUCCESS != ret)
			em_printf(MSG_ERROR, "%s %s failed\n", __FILE__, __LINE__);
		cancel, not used
	*/
		case 13:
		ret = CWrapper::setOutputPin ( 20, 0);
		if(ERROR_RFTEST_SUCCESS != ret)
			em_printf(MSG_ERROR, "%s %d failed\n", __FILE__, __LINE__);
		break;

		case 14:
		{

		ret =  CWrapper::writeEEPRom16 ( 100, 0x55);
		if(ERROR_RFTEST_SUCCESS != ret)
			em_printf(MSG_ERROR, "%s %d failed\n", __FILE__, __LINE__);
		/*u4Offset  < 256*/

		UINT_32	u4Value = 0; 
		ret = CWrapper::readEEPRom16 ( 100, &u4Value );
		if(ERROR_RFTEST_SUCCESS != ret)
			em_printf(MSG_ERROR, "%s %d failed\n", __FILE__, __LINE__);
		else
			em_printf(MSG_DEBUG, "readEEPRom16  0x%x", u4Value);
		break;
		}
		case 15:
#if 0

		{
		INT_8 str_eeprom[8] = {0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88};
		ret = CWrapper::eepromWriteByteStr( 0, sizeof(str_eeprom), str_eeprom);
		if(ERROR_RFTEST_SUCCESS != ret)
			em_printf(MSG_ERROR, "%s %d failed\n", __FILE__, __LINE__);

	
	memset(str_eeprom, 0, sizeof(str_eeprom));
		ret = CWrapper::eepromReadByteStr(0, sizeof(str_eeprom), str_eeprom);
		if(ERROR_RFTEST_SUCCESS != ret)
			em_printf(MSG_ERROR, "%s %d failed\n", __FILE__, __LINE__);
		break;
		}
#else

		{
		char str_eeprom[9] = "12345678";
		ret = CWrapper::eepromWriteByteStr( 0, strlen(str_eeprom) / 2, (INT_8 *)str_eeprom);
		if(ERROR_RFTEST_SUCCESS != ret)
			em_printf(MSG_ERROR, "%s %d failed\n", __FILE__, __LINE__);

	
	memset(str_eeprom, 0, sizeof(str_eeprom));
		ret = CWrapper::eepromReadByteStr(0, 4, (INT_8 *)str_eeprom);
		if(ERROR_RFTEST_SUCCESS != ret)
			em_printf(MSG_ERROR, "%s %d failed\n", __FILE__, __LINE__);
		em_printf(MSG_DEBUG, "case 15 : ");
		em_dump(str_eeprom, strlen(str_eeprom));
		break;
		}

#endif
		case 16:
		ret = CWrapper::setATParam(13, 1);
		if(ERROR_RFTEST_SUCCESS != ret)
			em_printf(MSG_ERROR, "%s %d failed\n", __FILE__, __LINE__);
		else
			em_printf(MSG_DEBUG, "setATParam successed.\n");
		
		val = 0;
		ret = CWrapper::getATParam(13, &val);
		if(ERROR_RFTEST_SUCCESS != ret)
			em_printf(MSG_ERROR, "%s %d failed\n", __FILE__, __LINE__);
		else
			em_printf(MSG_DEBUG, "getATParam return %d\n", val);
		break;

		case 17:
		ret =  CWrapper::setXtalTrimToCr (20);
		if(ERROR_RFTEST_SUCCESS != ret)
			em_printf(MSG_ERROR, "%s %d failed\n", __FILE__, __LINE__);
		UINT_32 u4Value;
		ret = CWrapper::getXtalTrimToCr(&u4Value);
		if(ERROR_RFTEST_SUCCESS != ret)
			em_printf(MSG_ERROR, "%s %d failed\n", __FILE__, __LINE__);
		else
			em_printf(MSG_DEBUG, "getXtalTrimToCr %d\n", u4Value);		
		break;
		
		case 18:
		ret = CWrapper::setThermoEn (1);
		if(ERROR_RFTEST_SUCCESS != ret)
			em_printf(MSG_ERROR, "%s %d failed\n", __FILE__, __LINE__);
		break;

		case 19:
		INT_32 i4AlcEn;
		ret = CWrapper::queryThermoInfo (&i4AlcEn, NULL);
		if(ERROR_RFTEST_SUCCESS != ret)
			em_printf(MSG_ERROR, "%s %d failed\n", __FILE__, __LINE__);
		else
			em_printf(MSG_DEBUG, "queryThermoInfo %d\n", i4AlcEn);
		break;
		
		case 20:
		{
		INT_32 i4EepromSz = 0;
		ret = CWrapper::getEEPRomSize(&i4EepromSz);
		if(ERROR_RFTEST_SUCCESS != ret)
			em_printf(MSG_ERROR, "%s %d failed\n", __FILE__, __LINE__);
		else
			em_printf(MSG_DEBUG, "getEEPRomSize  i4EepromSz is %d", i4EepromSz);
		break;
		}
		case 21:
		{
		ret = CWrapper::setPnpPower (ParamDeviceStateD0);
		if(ERROR_RFTEST_SUCCESS != ret)
			em_printf(MSG_ERROR, "%s %d failed\n", __FILE__, __LINE__);
		break;
		}
		case 22:
		{
		UINT_32 mcr_value = 0;
		ret = CWrapper::readMCR32(MCR_ICCR2, &mcr_value);
		if(ERROR_RFTEST_SUCCESS != ret)
			em_printf(MSG_ERROR, "%s %d failed\n", __FILE__, __LINE__);
		else
			em_printf(MSG_DEBUG, "readMCR32 MCR_ICCR2 0x%x\n", mcr_value);

		ret = CWrapper::writeMCR32(MCR_ICCR2, 1);
		if(ERROR_RFTEST_SUCCESS != ret)
			em_printf(MSG_ERROR, "%s %d failed\n", __FILE__, __LINE__);

		ret = CWrapper::readMCR32(MCR_ICCR2, &mcr_value);
		if(ERROR_RFTEST_SUCCESS != ret)
			em_printf(MSG_ERROR, "%s %d failed\n", __FILE__, __LINE__);
		else
			em_printf(MSG_DEBUG, "readMCR32 MCR_ICCR2 0x%x\n", mcr_value);
		break;
		}
		case 23:
		ret = CWrapper::setAnritsu8860bTestSupportEn (1);
		if(ERROR_RFTEST_SUCCESS != ret)
			em_printf(MSG_ERROR, "%s %d failed\n", __FILE__, __LINE__);
		break;
		case 24:
			txGo();
		break;
		case 25:
			rxGo();
		break;
		case 26:
//			delete cw;
//			return 0;
			CWrapper::Uninitialize();
			return 0;

		default:
		break;
		}
		printf("curren loop ret = %d\n", ret);
	}

	return 0;
}