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

📄 test.c

📁 atheros ar5001 5002 driver
💻 C
📖 第 1 页 / 共 5 页
字号:
	{
		//the default instance is not needed by this board.
		art_teardownDevice(devNum);
	}
	if (!configSetup.userInstanceOverride) {
		if (CalSetup.instanceForMode[MODE_11a] != configSetup.instance) {
			tempDevNum = art_setupDevice(CalSetup.instanceForMode[MODE_11a]);
			if(tempDevNum < 0) {
				uiPrintf("main: Error attaching to the device - ending test\n");
				closeEnvironment();
				exit(0);
			}
			devNum_5g = tempDevNum;
			art_configureLibParams(devNum_5g);
			if (CalSetup.instanceForMode[MODE_11a] == CalSetup.instanceForMode[MODE_11g]) {
				devNum_2g = devNum_5g;
			}
		} else if (CalSetup.instanceForMode[MODE_11g] != configSetup.instance) {
			tempDevNum = art_setupDevice(CalSetup.instanceForMode[MODE_11g]);
			if(tempDevNum < 0) {
				uiPrintf("main: Error attaching to the device - ending test\n");
				closeEnvironment();
				exit(0);
			}
			devNum_2g = tempDevNum;
			art_configureLibParams(devNum_2g);
			if (CalSetup.instanceForMode[MODE_11a] == CalSetup.instanceForMode[MODE_11g]) {
				devNum_5g = devNum_2g;
			}
		} 

		if ((swDeviceID == 0xa016) && (devStruct.aRevID == 0x0)) { // indicates an AP31 			 
			art_resetDevice(devNum_2g, txStation, bssID, configSetup.channel, configSetup.turbo);
			art_getDeviceInfo(devNum_2g, &devStruct);
			swDeviceID = devStruct.swDevID;
			hwDeviceID = devStruct.hwDevID;					
		}

		//setup devnum correctly
		if(configSetup.mode == MODE_11A) {
			devNum = devNum_5g;
		}
		else {
			devNum = devNum_2g;
		}

		if (CalSetup.Amode) {
			if (CalSetup.Gmode) {
				if ((CalSetup.instanceForMode[MODE_11a] != 1) && (CalSetup.instanceForMode[MODE_11g] != 1)) {
					configSetup.validInstance = 2;
				}
			} else {
				if (CalSetup.instanceForMode[MODE_11a] != 1) {
					configSetup.validInstance = 2;
				}
			}
		} else if (CalSetup.Gmode) {
			if (CalSetup.instanceForMode[MODE_11g] != 1) {
				configSetup.validInstance = 2;
			}
		}
	}
#else
	devNum_5g = devNum;
	devNum_2g = devNum;
#endif //__ATH_DJGPPDOS__

/*
	if(((swDeviceID == 0xa014)||(swDeviceID == 0xa016))&&(!configSetup.userInstanceOverride)) {
		devNum_5g = devNum;

		tempDevNum = art_setupDevice(2);
	    if(tempDevNum < 0) {
		    uiPrintf("main: Error attaching to the device - ending test\n");
			closeEnvironment();
			exit(0);
		}
		devNum_2g = tempDevNum;
		art_configureLibParams(devNum_2g);
	
		if (((swDeviceID == 0xa016) && (devStruct.aRevID == 0x0)) || // indicates an AP31 
			(subSystemID == 0xa035) ) {  // indicates ap38 (casper)
			art_resetDevice(devNum_2g, txStation, bssID, configSetup.channel, configSetup.turbo);
			art_getDeviceInfo(devNum_2g, &devStruct);
			swDeviceID = devStruct.swDevID;
			hwDeviceID = devStruct.hwDevID;					
			configSetup.validInstance = 2;
		}

		if (subSystemID == 0xa035) {
			devNum_5g = devNum_2g;
		}

	}
*/
	if ((swDeviceID & 0xff) >= 0x14) { // venice or hainan with derby 1/2
		//if (((swDeviceID & 0xFF) == 0x16) && (((devStruct.aRevID >> 4) & 0xf) >= 5)) {
		if ((swDeviceID & 0xFF) >= 0x16) {
			pCurrGainLadder = &(gainLadder_derby2);
		} else {
			pCurrGainLadder = &(gainLadder_derby1);
		}
	} else {
		pCurrGainLadder = &(gainLadder);
	}


#ifdef __ATH_DJGPPDOS__
	if(!configSetup.eepromLoad) {
		uiPrintf("Error: eeprom must be loaded, enabling loading\n");
		configSetup.eepromLoad = 1;
	}

#endif
	if(configSetup.mode == MODE_11B) {
		configSetup.turbo = 0;
	}

	gainValues = xpdGainValues;
	//setup the params prior to reset
	if ((swDeviceID == 0x0007) || (swDeviceID == 0x0005) ) {
		configSetup.pCfgFile = configSetup.creteFezCfg;
		configSetup.maxChannel5G = MAX_FEZ_CHANNEL;
	}
	else if (swDeviceID == 0x0011) {
		configSetup.pCfgFile = configSetup.qmacSombreroCfg;
		configSetup.maxChannel5G = MAX_SOM_CHANNEL;
	}
	else if (swDeviceID == 0xe011) {
		configSetup.pCfgFile = configSetup.qmacSombreroBeanieCfg;
		configSetup.maxChannel5G = MAX_SOM_CHANNEL;
	}
	else if ((swDeviceID & 0xff) == 0x0012)  {
		configSetup.pCfgFile = configSetup.oahuCfg;
		configSetup.maxChannel5G = MAX_SOM_CHANNEL;
		configSetup.maxChannel2G = MAX_2G_CHANNEL;
		configSetup.minChannel2G = MIN_2G_CHANNEL;
	}
	else if (((swDeviceID & 0xff) == 0x0013) || ((swDeviceID & 0xff) == 0x0015)){
		configSetup.pCfgFile = configSetup.veniceCfg;
		configSetup.maxChannel5G = MAX_SOM_CHANNEL;
		configSetup.maxChannel2G = MAX_2G_CHANNEL;
		configSetup.minChannel2G = MIN_2G_CHANNEL;
	}
	else if (((swDeviceID & 0xff) >= 0x0014)&&((swDeviceID & 0xff) != 0x0015))  {
		configSetup.pCfgFile = configSetup.veniceCfg;
		configSetup.maxChannel5G = MAX_SOM_CHANNEL;
		gainValues = xpdGainValues_derby;
		gainIMax = DERBY_GAINI_MAX;
		configSetup.maxChannel2G = MAX_2G_CHANNEL_DERBY;
		configSetup.minChannel2G = MIN_2G_CHANNEL_DERBY;
	}

	//turn on logging if needed
	if(configSetup.logging) {
		if(configSetup.logFile[0] == '\0') {
			uiPrintf("\nPlease enter filename for logging: ");
			scanf("%s", configSetup.logFile);
		}
		uilog(configSetup.logFile, 1);
	}



	if((hwDeviceID == 0xff12) || (hwDeviceID >= 0xff13)) {
		//need to indicate eeprom size
    	art_writeField(devNum, "mc_eeprom_size_ovr", 3);
	}
#ifndef __ATH_DJGPPDOS__
	if (eeprom_verify_checksum(devNum))
	{
		configSetup.validCalData  =  TRUE;
		if(!configSetup.eepromLoadOverride) {
			configSetup.eepromLoad    =  1;
		}
		else {
			configSetup.eepromLoad = 0;
		}
	} else
	{
		configSetup.validCalData  =  FALSE;
		configSetup.eepromLoad    =  0;
		invalidEepromMessage(2000);
	}
#else
		configSetup.validCalData  =  TRUE;
#endif //__ATH_DJGPPDOS__

	//setup the hw calibration per artsetup.txt
	art_enableHwCal(devNum, configSetup.enableCal);

	if ((((swDeviceID & 0xff) >= 0x0014) && ((swDeviceID & 0xff) != 0x0015)) && (configSetup.eepromLoad)) {
		//xpdgain gets set by devlib, don't want to apply here unless there
		//is an override.
		configSetup.applyXpdGain = 0;
	}
	art_setResetParams(devNum, configSetup.pCfgFile, (A_BOOL)configSetup.eepromLoad,
			(A_BOOL)1, (A_UCHAR)configSetup.mode, configSetup.use_init);		
	art_resetDevice(devNum, txStation, bssID, configSetup.channel, configSetup.turbo);
	
	
//    if(!setEepFile(devNum)) {
//        closeEnvironment();
//		exit(0);
//	}

#ifndef __ATH_DJGPPDOS__
    if(!setEepFile(devNum)) {
        closeEnvironment();
		exit(0);
	}

	if(((swDeviceID == 0xa014)||(swDeviceID == 0xa016))&&(!configSetup.userInstanceOverride)) {
		if(!setEepFile((devNum == devNum_5g) ? devNum_2g : devNum_5g)) {
			closeEnvironment();
			exit(0);
		}
	}

	parseSetup(devNum);
	//push down the false detect values
	//need to map the mode specific backoffs in the correct order
	tempBackoff[MODE_11A] = CalSetup.falseDetectBackoff[MODE_11a];
	tempBackoff[MODE_11B] = CalSetup.falseDetectBackoff[MODE_11b];
	tempBackoff[MODE_11G] = CalSetup.falseDetectBackoff[MODE_11g];
	art_supplyFalseDetectbackoff(devNum, tempBackoff);
#endif //__ATH_DJGPPDOS__		


#ifndef __ATH_DJGPPDOS__
	if (progProm) {
		progBlankEEPROM(devNum);
		uiPrintf("Press any key to continue or <ESC> to exit\n");
		if(getch() == 0x1b) {
	        closeEnvironment();
			exit(0);
		}
	}
#endif //__ATH_DJGPPDOS__

	//setup the mode
	getSupportedModes(devNum, &supportedModes);
	configSetup.mode = getFirstMode(&supportedModes);
	if(!setupMode()) {
		uiPrintf("Illegal mode value set in %s - exiting\n");
		closeEnvironment();
		exit(0);
	}

	if(((swDeviceID == 0xa014)||(swDeviceID == 0xa016))&&(!configSetup.userInstanceOverride)) {
		if(configSetup.mode != MODE_11A) {
			devNum = devNum_2g;
		}
	}

	art_setResetParams(devNum, configSetup.pCfgFile, (A_BOOL)configSetup.eepromLoad,
			(A_BOOL)configSetup.eepromHeaderLoad, (A_UCHAR)configSetup.mode, configSetup.use_init);		
	//this is needed incase we changed modes
	art_resetDevice(devNum, txStation, bssID, configSetup.channel, configSetup.turbo);

	//test card/installation
	if(!initTest(devNum)) {
        uiPrintf("main: Error testing device - exiting\n");
        closeEnvironment();
       exit(0);
	}

	if (configSetup.cmdLineTest) {
		//just perform the command line tests then get out
		exit(performCmdLineTests(devNum));
	}

	//Read register values read in from resetDevice
	updateConfigFromRegValues(devNum);
	while(exitLoop == FALSE) {

        printf("\n");
        printf("============================================\n");
        printf("| Test Harness Main Options:               |\n");
#ifndef CUSTOMER_REL
		printf("|   n - Toggle i(N)it code use             |\n");
#endif
		if (supportMultiModes(&supportedModes))
		{
			printf("|   o - Toggle M(o)de                      |\n");
		}
#ifndef __ATH_DJGPPDOS__
        if(configSetup.eepromLoad) {
			printf("|   e - Ignore (E)EPROM Calibration        |\n");
		}
		else {
			printf("|   e - Load (E)EPROM Calibration          |\n");
		}
#endif	// __ATH_DJGPPDOS__
        printf("|   c - (C)ontinuous transmit mode         |\n");
        printf("|   r - Continuous RF (R)eceive mode       |\n");
		printf("|   l - (L)ink test menu                   |\n");
		printf("|   t - (T)hroughput test menu             |\n");
        printf("|   p - EE(P)ROM function                  |\n");
#ifndef __ATH_DJGPPDOS__
        printf("|   s - (S)witch test card                 |\n");
        printf("|   m - (M)anufacturing/Calibration Test   |\n");
#endif	// __ATH_DJGPPDOS__
        if(configSetup.logging) {
			printf("|   g - Disable lo(g)ging                  |\n");
			printf("|   w - (W)rite Comment to Log File        |\n");
		}
		else {
			printf("|   g - Enable lo(g)ging                   |\n");
		}
		printf("|   u - (U)tility Menu                     |\n");
//take out for now		printf("|   x - Additional Tests                   |\n");
        printf("|   q - (Q)uit                             |\n");
        printf("============================================\n");
        switch(toupper(getch())) {
        case 'N':
                configSetup.use_init = !configSetup.use_init;
	            art_setResetParams(devNum, configSetup.pCfgFile, (A_BOOL)configSetup.eepromLoad,
			            (A_BOOL)configSetup.eepromHeaderLoad, (A_UCHAR)configSetup.mode, configSetup.use_init);		
                if (configSetup.use_init) {
                    printf("Using Driver init code\n");
                }
                else {
                    printf("Using MDK init code\n");
                }
	            art_resetDevice(devNum, txStation, bssID, configSetup.channel, configSetup.turbo);
                break;

		case 'O':
			if (supportMultiModes(&supportedModes))
 			{
				//before changing mode, take a copy of the current frequency and rxGain for mode
				switch(configSetup.mode) {
				case MODE_11A:
					configSetup.channel5 = configSetup.channel;
					configSetup.rxGain5 = configSetup.rxGain;
					break;
				case MODE_11G:
				case MODE_11O:
					configSetup.channel2_4 = configSetup.channel;
					configSetup.rxGain2_4 = configSetup.rxGain;
					break;
				case MODE_11B:
					configSetup.channel2_4 = configSetup.channel;
					configSetup.rxGain2_4 = configSetup.rxGain;		//Not sure if will have another rxGain for b??
					break;
				}
			
				configSetup.mode = getNextMode(&supportedModes);
				if(configSetup.mode == MODE_11B) {
					configSetup.turbo = 0;
				}
				if((configSetup.mode != MODE_11G) && (configSetup.dataRateIndex > 7)) {
					configSetup.dataRateIndex = 0;
				}

				uiPrintf("\n");

				if ( ( (swDeviceID & 0xFF) == 0x14 ) || ( (swDeviceID & 0xFF) >= 0x16 ) ){
					configSetup.maxRxGain = RX_GAIN_MAX_AR5112;
					configSetup.minRxGain = RX_GAIN_MIN_AR5112;
				} else {
					if(configSetup.mode == MODE_11A) {
						configSetup.maxRxGain = RX_GAIN_MAX;
						configSetup.minRxGain = RX_GAIN_MIN;
					} else {
						configSetup.maxRxGain = RX_GAIN_MAX_11bg;
						configSetup.minRxGain = RX_GAIN_MIN_11bg;
					}
				}

				if (configSetup.rxGain > configSetup.maxRxGain) {
					configSetup.rxGain = configSetup.maxRxGain;
				} 

				if (configSetup.rxGain < configSetup.minRxGain) {
					configSetup.rxGain = configSetup.minRxGain;
				} 

				if(((swDeviceID == 0xa014)||(swDeviceID == 0xa016))&&(!configSetup.userInstanceOverride)) {
					if(configSetup.mode != MODE_11A) {
						devNum = devNum_2g;
					}
					else {
						devNum = devNum_5g;
					}
				}
				setupMode(); 
				art_setResetParams(devNum, configSetup.pCfgFile, (A_BOOL)configSetup.eepromLoad,
					(A_BOOL)configSetup.eepromHeaderLoad, (A_BOOL)configSetup.mode, configSetup.use_init);		
				art_resetDevice(devNum, txStation, bssID, configSetup.channel, configSetup.turbo);
				if (configSetup.useTargetPower == TRUE) {
					configSetup.powerOutput = art_getMaxPowerForRate(devNum, (A_UINT16)configSetup.channel, DataRate[configSetup.dataRateIndex]);
				}
				updateConfigFromRegValues(devNum);

			}
			else {
	            uiPrintf("Unknown command\n");
			}
			break;
 #ifndef __ATH_DJGPPDOS__
       case 'E':
		   if (configSetup.validCalData)
		   {	   
				if(configSetup.eepromLoad) {
					configSetup.eepromLoad = 0;
					//force the reload of eep file to override eeprom settings.
					processEepFile(devNum, configSetup.cfgTable.pCurrentElement->eepFilename, &configSetup.eepFileVersion);
				}
				else {
					configSetup.eepromLoad = 1;
				}
				//revert back to defaults for config setup params
				configSetup.pcDac = USE_REG_FILE;
				configSetup.powerOutput = USE_REG_FILE;

⌨️ 快捷键说明

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