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

📄 maui_cal.c

📁 atheros ar5001 5002 driver
💻 C
📖 第 1 页 / 共 5 页
字号:
#ifdef _WINDOWS
#include <windows.h>
#endif 
#include <stdio.h>
#ifndef LINUX
#include <conio.h>
#endif
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <ctype.h>
#include <stdarg.h>
#include "wlantype.h"   /* typedefs for A_UINT16 etc.. */
#include "wlanproto.h"
#include "athreg.h"
#include "manlib.h"     /* The Manufacturing Library */
#include "MLIBif.h"     /* Manufacturing Library low level driver support functions */
#ifdef JUNGO
#include "mld.h"        /* Low level driver information */
#endif
#ifdef ANWI
#include "mld_anwi.h"
#endif
#ifdef LINUX
#include "mld_linux.h"
#endif
#include "manlibInst.h" /* The Manufacturing Library Instrument Library extension */
#include "mEeprom.h"    /* Definitions for the data structure */
#include "dynamic_optimizations.h"
#include "maui_cal.h"   /* Definitions for the Calibration Library */
#include "rssi_power.h"
#include "test.h"
#include "parse.h"
#include "dk_cmds.h"
#include "dk_ver.h"

#ifdef LINUX
#include "linux_ansi.h"
#include "unistd.h"
#endif	

#include "art_if.h"
#include "ar5212/mEEPROM_d.h"
#include "cal_gen3.h"
#include "ar5211/ar5211reg.h"  /* AR5001 register definitions */

extern A_UINT32 subSystemID;
extern A_UCHAR DataRate[]; // declared in test.c



//extern GAIN_OPTIMIZATION_LADDER gainLadder;
extern GAIN_OPTIMIZATION_LADDER *pCurrGainLadder;

//extern MLD_CONFIG configSetup;
extern ART_SOCK_INFO *artSockInfo;
extern CAL_SETUP CalSetup;
//extern A_BOOL printLocalInfo;
	   
// extern declarations for dut-golden sync
extern ART_SOCK_INFO *pArtPrimarySock;
extern ART_SOCK_INFO *pArtSecondarySock;

extern  EEPROM_DATA_STRUCT_GEN3 *pCalDataset_gen3[] ;

 char ackRecvStr[1024];
 char ackSendStr[1024];
 A_INT32 ackSendPar1, ackSendPar2, ackSendPar3;
 A_INT32 ackRecvPar1, ackRecvPar2, ackRecvPar3;


static A_UINT16 SideChannel = 5120; // channel used for sending handshake.
static A_UINT16 SideChannel_2p4 = 2312; // channel used for sending handshake.
A_UINT16 eepromType = EEPROM_SIZE_16K;

extern GOLDEN_PARAMS  goldenParams;

A_UINT32 devlibModeFor[3] = {MODE_11G, MODE_11B, MODE_11A};
A_UINT32 calModeFor[3] = {MODE_11a, MODE_11g, MODE_11b};

static A_UINT16 rates[MAX_RATES] = {6,9,12,18,24,36,48,54};

A_UINT32 VERIFY_DATA_PACKET_LEN   = 2352;

 A_INT32 devPM, devSA, devATT;
 A_INT32 guDevPM, guDevAtt;

static A_UINT16 MKK_CHAN_LIST[] = {5170, 5190, 5210, 5230}; // channels used for OBW test
A_UINT16 numRAWChannels = 0; //will be computed prior to measurements.
A_UINT16 RAW_CHAN_LIST[201] ; // can accomodate 5000 - 6000 in steps of 5 MHz
A_UINT16 PCDACS_MASTER_LIST[] = {1,4, 7,10, 12,14,15,16,18,20, 22, 25, 28,32,37, 42, 48, 54, 60, 63};
//A_UINT16 PCDACS_MASTER_LIST[] = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,
//								 27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,
//								 55,56,57,58,59,60,61,62,63};
A_UINT16 *RAW_PCDACS;
A_UINT16 sizeOfRawPcdacs = (A_UINT16) sizeof(PCDACS_MASTER_LIST)/sizeof(A_UINT16);

static 	A_UINT32  devNumArr[3];

static A_UCHAR  bssID[6]     = {0x50, 0x55, 0x5A, 0x50, 0x00, 0x00};
static A_UCHAR  rxStation[6] = {0x10, 0x11, 0x12, 0x13, 0x00, 0x00};	// DUT
static A_UCHAR  txStation[6] = {0x20, 0x22, 0x24, 0x26, 0x00, 0x00};	// Golden
static A_UCHAR  NullID[6]    = {0x66, 0x66, 0x66, 0x66, 0x66, 0x66};
static A_UCHAR  pattern[2] = {0xaa, 0x55};


static A_UCHAR  verifyDataPattern[NUM_VERIFY_DATA_PATTERNS][LEN_VERIFY_DATA_PATTERNS]  = { 
											{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
											{0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF},
											{0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA},
											{0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55},
											{0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66},
											{0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99},
											{0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80},
											{0xFE, 0xFD, 0xFB, 0xF7, 0xEF, 0xDF, 0xBF, 0x7F}
										};



static A_UINT32 PER_TEST_RATE[] = {6, 36, 48, 54};
static A_UINT32 PER_RATEMASK = RATE_6|RATE_36|RATE_48|RATE_54;
static A_UINT32 PER_RATE_COUNT = 4;
static A_UINT32 PER_TEST_FRAME = 100;
static A_UINT32 PER_FRAME_LEN  = 1000;
static A_UINT32 NUM_11G_PPM_PKTS = 40;
//static A_UINT32 PER_GOOD_FRAME = 90;	// 90% of the frame send/receive

static A_UINT32 NUM_DATA_CHECK_FRAME = 4;

static A_UINT32 SEN_TEST_RATE[] = {48, 54};
static A_UINT32 SEN_RATEMASK = RATE_GROUP | RATE_48 | RATE_54;
static A_UINT32 SEN_RATE_COUNT = 2;
//static A_UINT32 SEN_TEST_FRAME = 100;  // use deprecated by CalSetup.numSensPackets[mode] starting w/ ART_2.5b18
static A_UINT32 SEN_FRAME_LEN  = 1000;
//static A_UINT32 SEN_GOOD_FRAME = 90;	// 90% of the frame send/receive

//static A_INT32 PPM_MAX = 9;
//static A_INT32 PPM_MIN = -9;
static A_BOOL  TestFail;

 dPCDACS_EEPROM RawDataset ; // raw power measurements
 dPCDACS_EEPROM *pRawDataset = &RawDataset ; // raw power measurements
 dPCDACS_EEPROM RawGainDataset ; // raw gainf measurements
 dPCDACS_EEPROM *pRawGainDataset = &RawGainDataset ; // raw gainf measurements
 dPCDACS_EEPROM CalDataset ; // calibration dataset
 dPCDACS_EEPROM *pCalDataset = &CalDataset ; // calibration dataset
 dPCDACS_EEPROM FullDataset ; // full dataset
 dPCDACS_EEPROM *pFullDataset = &FullDataset ; // full dataset

 dPCDACS_EEPROM RawDataset_11g ; // raw power measurements for 11g
 dPCDACS_EEPROM RawDataset_11b ; // raw power measurements for 11b
 dPCDACS_EEPROM *pRawDataset_2p4[2] = {&RawDataset_11g, &RawDataset_11b} ; // raw power measurements

 dPCDACS_EEPROM CalDataset_11g ; // calibration dataset
 dPCDACS_EEPROM CalDataset_11b ; // calibration dataset
 dPCDACS_EEPROM *pCalDataset_2p4[2] = {&CalDataset_11g, &CalDataset_11b} ; // calibration dataset

 dPCDACS_EEPROM RawGainDataset_11g ; // raw power measurements for 11b
 dPCDACS_EEPROM RawGainDataset_11b ; // raw power measurements for 11b
 dPCDACS_EEPROM *pRawGainDataset_2p4[2] = {&RawGainDataset_11g, &RawGainDataset_11b} ; // raw power measurements

char calPowerLogFile_2p4[2][122] = {"cal_AR5211_Power_11g.log", "cal_AR5211_Power_11b.log"};
static char calGainfLogFile_2p4[2][122] = {"cal_AR5211_Gainf_11g.log", "cal_AR5211_Gainf_11b.log"};

extern A_UINT16 numRAWChannels_2p4;
//A_UINT16 RAW_CHAN_LIST_2p4[3] = {2412, 2447, 2484}; // Never change them. These values are NOT stored 
														   // on EEPROM, but are hardcoded in the driver instead.
// Needed to change these channels starting eeprom version 3.3 to accomodate
// Korea channels for 11g. - PD 9/02.
A_UINT16 RAW_CHAN_LIST_2p4[2][3] = {{2312, 2412, 2484}, {2412, 2472, 2484}}; // {11g, 11b}


extern TARGETS_SET	  *pTargetsSet;
extern TARGETS_SET	  *pTargetsSet_2p4[];

extern TEST_SET	  *pTestSet[3] ;
extern  char modeName[3][122]  ;

static A_UINT32		reportTiming = 1;
static char			testname[30][32] ;
static A_INT32		testtime[30];
static A_UINT32		timestart, timestop, globalteststarttime;
static A_UINT32		testnum = 0;
static char			failTest[30]; // flag if curr test has a failure.

A_BOOL		REWIND_TEST = FALSE;
static A_BOOL		SETUP_PM_MODEL2_ONCE = FALSE;
static A_BOOL		DUT_SUPPORTS_MODE[3] = {FALSE, FALSE, FALSE}; // flags used by golden

extern A_BOOL printLocalInfo;

static A_UINT32	optGainLadderIndex[3];
static A_BOOL	NEED_GAIN_OPT_FOR_MODE[] = {FALSE, FALSE, FALSE};

static A_UINT32 loadEARState;

void topCalibrationEntry(A_UINT32 *pdevNum_inst1, A_UINT32 *pdevNum_inst2) 
{
	A_UINT32 devNum_inst1, devNum_inst2;

	devNum_inst1 = *pdevNum_inst1;
	devNum_inst2 = *pdevNum_inst2;

	loadEARState = configSetup.loadEar;

	// force loadEAR to 0 to capture values from new config file
	// loadEAR is restored just before the dutTest
	configSetup.loadEar = 0;
	art_configureLibParams(devNum_inst1);
	art_configureLibParams(devNum_inst2);
	art_resetDevice(devNum_inst1, rxStation, bssID, 5220, 0);	
    if (devNum_inst1 != devNum_inst2) 
	    art_resetDevice(devNum_inst2, rxStation, bssID, 2412, 0);	
	processEepFile(devNum_inst1, configSetup.cfgTable.pCurrentElement->eepFilename, &configSetup.eepFileVersion);
	processEepFile(devNum_inst2, configSetup.cfgTable.pCurrentElement->eepFilename, &configSetup.eepFileVersion);

   	art_writeField(devNum_inst1, "mc_eeprom_size_ovr", 3);
   	art_writeField(devNum_inst2, "mc_eeprom_size_ovr", 3);
	devNumArr[MODE_11a] = devNum_inst1;
	devNumArr[MODE_11g] = devNum_inst2;
	devNumArr[MODE_11b] = devNum_inst2;
	
	setup_raw_pcdacs();
	calibrationMenu() ;

	*pdevNum_inst1 = devNumArr[MODE_11a];
	*pdevNum_inst2 = devNumArr[MODE_11g];
} 
		

void calibrationMenu() 
{
    A_BOOL exitLoop  = FALSE;
	A_UINT32 channel = 5220;
	A_UINT32 devNum  = devNumArr[MODE_11a];

	if (configSetup.validInstance == 2) {
		devNum = devNumArr[MODE_11g];
	}

	if ( !processEepFile(devNum, configSetup.cfgTable.pCurrentElement->eepFilename, &configSetup.eepFileVersion))
	{ 
		uiPrintf("Could Not Parse the .eep file %s for SubsystemID %x.\n", configSetup.cfgTable.pCurrentElement->eepFilename, 
			configSetup.cfgTable.pCurrentElement->subsystemID);
		exit(0);
	}
	parseSetup(devNum);  
	if (CalSetup.useFastCal)
	{
		if ( (!setup_raw_datasets()) ||
			 (!setup_raw_datasets_2p4(MODE_11g)) ||
			 (!setup_raw_datasets_2p4(MODE_11b))	 )			
		{ 
			uiPrintf("Could not setup raw datasets. Exiting...\n");
			closeEnvironment();
			exit(0);
		}
	}

	if (CalSetup.eeprom_map == CAL_FORMAT_GEN3) {
		CalSetup.TrgtPwrStartAddr = 0x150;
		if (CalSetup.cal_mult_xpd_gain_mask[MODE_11a] == 0) {
			CalSetup.xgain = 1 << CalSetup.xgain ;
		} else {
			CalSetup.xgain = CalSetup.cal_mult_xpd_gain_mask[MODE_11a];
		}
		if (CalSetup.cal_mult_xpd_gain_mask[MODE_11b] == 0) {
			CalSetup.xgain_2p4[MODE_11b] = 1 << CalSetup.xgain_2p4[MODE_11b] ;
		} else {
			CalSetup.xgain_2p4[MODE_11b] = CalSetup.cal_mult_xpd_gain_mask[MODE_11b];			
		}
		if (CalSetup.cal_mult_xpd_gain_mask[MODE_11g] == 0) {
			CalSetup.xgain_2p4[MODE_11g] = 1 << CalSetup.xgain_2p4[MODE_11g] ;
		} else {
			CalSetup.xgain_2p4[MODE_11g] = CalSetup.cal_mult_xpd_gain_mask[MODE_11g];
		}
	}

	while(exitLoop == FALSE) {
        printf("\n");
        printf("=============================================\n");
        printf("| Manufacturing Test & Calibration Options: |\n");
        printf("|   d - (D)evice Under Test Begin           |\n");
        printf("|   g - (G)olden Unit Test Begin            |\n");
		if (CalSetup.useFastCal)
		{
			printf("|   f - Fastcal Cal - start (f)irst on GU   |\n");
			printf("|   s - Fastcal Cal - start (s)econd on DUT |\n");
		}
        printf("|   q - (Q)uit                              |\n");
        printf("=============================================\n");
        switch(toupper(getch())) {
        case 'D':
			dutBegin();
			break;
        case 'G':
			goldenTest();
			break;
        case 'F':
			if (CalSetup.useFastCal)
				fastCalMenu_GU(devNum);
			break;
        case 'S':
			if (CalSetup.useFastCal)
				fastCalMenu_DUT(devNum);
			break;
        case 0x1b:
        case 'Q':
            exitLoop = TRUE;
            uiPrintf("exiting\n");
            break;
        default:
            uiPrintf("Unknown command\n");
            break;
        }
    }
}


void dutBegin() 
{
    A_BOOL		exitLoop = FALSE;
	A_UINT32	tmpVal, ii;
	A_UINT32	attenVal;

	testnum = 0;	

	if ( configSetup.dutSSID < 1 ) 		
	{
		uiPrintf("please specify appropriate DUT_CARD_SSID in artsetup.txt\n");
		exit(0);
	} else if (configSetup.dutSSID != configSetup.cfgTable.pCurrentElement->subsystemID)
	{
		uiPrintf("DUT_CARD_SSID specified in artsetup.txt (%x) does not match with the  SSID of this card: (%x). ",configSetup.dutSSID ,
				  configSetup.cfgTable.pCurrentElement->subsystemID);
		uiPrintf("Set the 'DUT_CARD_SSID' in artsetup.txt appropriately to calibrate the desired card.\n");
		exit(0);
	}

	// setup the channel lists 
	setupChannelLists();
	
	if(!parseTargets()) {
		uiPrintf("An error occured while parsing the file %s. Pl. check for format errors.\n", CalSetup.tgtPwrFilename);
	}

	eepromType = (A_UINT16) CalSetup.dutPromSize ;

	uiPrintf("\n=======================================");
	uiPrintf("\nPlug in DUT (Device Under Test)        ");
	uiPrintf("\nPress any key to start or <ESC> to quit");
	uiPrintf("\n=======================================\n");
	while (!kbhit())
		;
	
	globalteststarttime = milliTime();

	if(getch() == 0x1b)
		exitLoop = TRUE;

/*	devNumArr[MODE_11a] = devNum_def;
	if ((swDeviceID == 0xa014)||(swDeviceID == 0xa016)) {
		devNumArr[MODE_11b] = art_setupDevice(2); // get devNum for instance = 2 for freedom2 for 2.5G
		devNumArr[MODE_11g] = devNumArr[MODE_11b];
		art_resetDevice(devNumArr[MODE_11b], rxStation, bssID, 2412, 0);	
	} else {
		devNumArr[MODE_11b] = devNum_def;
		devNumArr[MODE_11g] = devNum_def;
	}
*/


	while (!exitLoop) {
		REWIND_TEST = FALSE;
		TestFail = FALSE;
		for (ii=0; ii<30; ii++) failTest[ii] = 0; // initialize test fail flags

		configSetup.eepromLoad = 0;
		

		if ( CalSetup.useFastCal || CalSetup.testTXPER || CalSetup.testRXSEN ||
			 CalSetup.testTXPER_2p4[MODE_11b] || CalSetup.testRXSEN_2p4[MODE_11b] ||
			 CalSetup.testTXPER_2p4[MODE_11g] || CalSetup.testRXSEN_2p4[MODE_11g] ||
			 CalSetup.testDataIntegrity[MODE_11a] || CalSetup.testDataIntegrity[MODE_11g] ||
			 CalSetup.testDataIntegrity[MODE_11b] || (CalSetup.do_iq_cal))
//			 ((swDeviceID & 0xFF) >= 0x14))
		{
			sendSync(devNumArr[MODE_11a], CalSetup.goldenIPAddr, CalSetup.customerDebug);
			waitForAck(CalSetup.customerDebug);
		}

		if (REWIND_TEST) {
			exitLoop = prepare_for_next_card(&(devNumArr[0]));
			continue;
		}
		

⌨️ 快捷键说明

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