📄 cal_com.c
字号:
#ifdef __ATH_DJGPPDOS__
#include <unistd.h>
#ifndef EILSEQ
#define EILSEQ EIO
#endif // EILSEQ
#define __int64 long long
#define HANDLE long
typedef unsigned long DWORD;
#define Sleep delay
#include <bios.h>
#include <dir.h>
#endif // #ifdef __ATH_DJGPPDOS__
#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
#ifdef __ATH_DJGPPDOS__
#include "mlibif_dos.h"
#endif
#include "manlibInst.h" /* The Manufacturing Library Instrument Library extension */
#include "mEeprom.h" /* Definitions for the data structure */
#include "test.h"
#include "parse.h"
#include "dynArray.h"
#include "art_if.h"
#include "dynamic_optimizations.h"
#include "maui_cal.h" /* Definitions for the Calibration Library */
#include "dk_ver.h"
// non-ansi functions are mapped to some equivalent functions
#ifdef LINUX
#include "linux_ansi.h"
#endif
A_UINT16 numRAWChannels_2p4 = 3;
GOLDEN_PARAMS goldenParams = { 4900,5850,20,70,0,63, 1,
11,{0,10,20,30,40,50,60,70,80,90,100} } ;
CAL_SETUP CalSetup = {42, 0, ATHEROS_CB22, EEPROM_SIZE_16K, 0x168C,
0, 0, 0x010, // country code, WWR, default domain 0x010 (FCC)
0, // calpower
0, // useFastCal
0, 0, 0, 0, 0, 0, 0, // 11a test flags
{0,0,0}, .5, 1.0, // target power test flags: g/b/a modes
// {-68, -68, -68, -68, -68, -68, -68, -68}, //target 11a sensitivity at 54 mbps
0, 3, 11.0, // 11a golden power cal data
{3,3}, {-2.0, -2.0}, // 11g and 11b golden pcdacs and power
PM_436A, 13, 18, 6, // PM_model number and GPIB addresses
11.3,11.3, 50, // attenuation factors
{10.0, 10.0},{10.0, 10.0}, {30.0, 30.0}, //2.5G atten factors
1, // numEthernetPorts
0, // startEthernetPort
0, 0, 0, // turbo_disable, turbo_disable_11g, rf_silent
1, // deviceType
15, 15, // turboMaxPwr_5G, TurboMaxPower_11g
1,0,0, // Amode, Bmode, Gmode
0,0, // antennaGain5G and 2.5G
// 11a parameters
0x2D, 0xB, 2, 2, 2,2, 1,2, 1,2, 0x1C, 0, 0, 0xE, 1, 13, 14, -85, -32, -72,
{0,0,0,0,0,0,0,0,0,0,0},
{0, 0, 0}, // fixed_bias
TRUE, // do_iq_cal
{0, 0, 0}, // iqcal_i_corr
{0, 0, 0}, // iqcal_q_corr
//ofdm@2.4 and 11b parameters
{0x2D,0x2D}, {0xB, 0xB},
{2,2}, {2,2}, {3,3}, {3,3}, // ob/db, b_ob/b_db
{0x1C, 0x1C}, {0,0}, {0,0},
{0xE, 0xE}, {1,1}, {13,13}, {13,13}, {-70,-75}, {-32,-32}, {-72,-72},
{{0,0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0,0}},
0, "cal_AR5211_power.log", // readFromFile
0, // customrDebug
0, // showTimingReport
"L:\\ART\\macid.txt",
0, {0,0}, 0, // force piers, list, num_piers
{0,0}, {{2312, 2412, 2484}, {2412, 2442, 2484}}, {3,3}, // force piers info for 11g, 11b
FALSE, // useOneCal for 11g/11b
// 40, // pcdac_5dB
"calTargetPower_cb21.txt",
{FALSE, FALSE},
{"cal_AR5211_Power_11g.log", "cal_AR5211_Power_11b.log"},
// {FALSE, FALSE}, // was calpower_11g, 11b
// {1,1},
{FALSE, FALSE},
{FALSE, FALSE},
{FALSE, FALSE},
{FALSE, FALSE}, // no turbo mode available in 11b, though
{FALSE, FALSE, FALSE}, // testTempMargin
FALSE, // test32KHzSleepCrystal
{FALSE, FALSE, FALSE}, // testDataIntegrity
{{-68, -68, -68}, {-88, -88},{-68, -68, -68, -68, -68, -68, -68, -68}}, // target sensitivity for 11g, 11b and 11a modes
//{{4, 1, 1, 0}, {4, 1, 1, 0}, {4, 1, 1, 0}, {4, 1, 1, 0}},
"0.0.0.0", // golden IP address
45, // case Temperature
{0, 0, 0}, // falsedetect backoff for all modes
90, 90, 9, -9, 0, // test limits
{30.0, 30.0, 30.0}, // maxPowerCap for 11a/11g/11b modes
1.5, // cck_ofdm_delta in dB
1.5, // ch14_filter_cck_delta in dB
3, // maxRetestIters
{INVALID_FG, INVALID_FG, INVALID_FG},
0, // eeprom_map 0 - gen2, 1 - gen3
{0x9, 0x9, 0x9}, // cal_mult_xpd_gain_mask
0x2BF, // EAR start addr
0x1A5, // TrgtPwr start
{100, 100, 100}, // number of packets to use for sensitivity
10, // txperBackoff
0, // Enable_32khz - enable sleep crystal.
{16, 16, 11}, // rxtx_margin_2ghz for all modes
7.5, // ofdm_cck_gain_delta
{1, 1, 1}, // instanceForMode
{0x3, 0}, // modeMaskForRadio
0, 0, 0, 0 // iq_coeffs for 5G 2G
};
TARGETS_SET TargetsSet ;
TARGETS_SET TargetsSet_11b ;
TARGETS_SET TargetsSet_11g ;
TARGETS_SET *pTargetsSet = &TargetsSet ;
TARGETS_SET *pTargetsSet_2p4[2] = {&TargetsSet_11g, &TargetsSet_11b} ;
extern A_UINT32 VERIFY_DATA_PACKET_LEN;
TEST_GROUP_SET TG_Set ;
TEST_GROUP_SET *pTestGroupSet= &TG_Set ;
TEST_SET TestSet_11g ;
TEST_SET TestSet_11b ;
TEST_SET TestSet_11a ;
TEST_SET *pTestSet[3] = {&TestSet_11g, &TestSet_11b, &TestSet_11a} ;
char modeName[3][122] = {"11g", "11b", "11a"};
double ofdm_gain[] = {-30, -12, -6, -2.5, 0, 2, 3.5, 5};
double cck_gain[] = {0, -6, -12};
//extern GOLDEN_PARAMS goldenParams ;
A_UINT16 global_prev_gainf = 0;
void load_cal_section(void)
{
FILE *fStream;
char lineBuf[122], *pLine;
A_UINT32 testVal;
A_UINT16 ii ;
A_BOOL parsingCal = FALSE ;
A_UINT16 parsingLine1 = 1;
char delimiters[] = " \t\n\r;=" ;
char *eep_file = configSetup.cfgTable.pCurrentElement->eepFilename;
uiPrintf("\nReading in Cal Section from %s\n", eep_file);
if( (fStream = fopen( eep_file, "r")) == NULL ) {
uiPrintf("Failed to open %s - using Defaults\n", eep_file);
return;
}
while(fgets(lineBuf, 120, fStream) != NULL) {
pLine = lineBuf;
while(isspace(*pLine)) pLine++;
if(strnicmp("@cal_section_begin", pLine, strlen("@cal_section_begin")) == 0) {
parsingCal = TRUE;
ii = 0;
continue;
}
// skip comments
if(*pLine == '#') {
continue;
}
while(parsingCal && (fgets(lineBuf, 120, fStream) != NULL)) {
pLine = lineBuf;
// pLine = strtok(pLine, delimiters);
// while(isspace(*pLine)) pLine++;
if(pLine == NULL) continue;
if(strnicmp("@cal_section_end", pLine, strlen("@cal_section_end")) == 0) {
parsingCal = FALSE;
}
if (pLine[0] == '#') {
continue ;
}
else if((strnicmp("TARGET_POWER_FILENAME", pLine, strlen("TARGET_POWER_FILENAME")) == 0) &&
((pLine[strlen("TARGET_POWER_FILENAME")] == ' ') ||
(pLine[strlen("TARGET_POWER_FILENAME")] == '\t') ) ){
pLine = strchr(pLine, '=');
pLine = strtok(pLine, delimiters);
if(!sscanf(pLine, "%s", CalSetup.tgtPwrFilename)) {
uiPrintf("Unable to read the TARGET_POWER_FILENAME from %s\n", eep_file);
}
}
else if(strnicmp("EEPROM_MAP_TYPE", pLine, strlen("EEPROM_MAP_TYPE")) == 0) {
pLine = strchr(pLine, '=');
pLine = strtok(pLine, delimiters);
if(!sscanf(pLine, "%d", &CalSetup.eeprom_map)) {
uiPrintf("Unable to read the EEPROM_MAP_TYPE from %s\n", eep_file);
}
}
else if(strnicmp("SUBSYSTEM_ID", pLine, strlen("SUBSYSTEM_ID")) == 0) {
pLine = strchr(pLine, '=');
pLine = strtok(pLine, delimiters);
CalSetup.subsystemID = (A_UINT16) strtoul(pLine, NULL, 0);
}
else if(strnicmp("NUM_ETHERNET_PORTS", pLine, strlen("NUM_ETHERNET_PORTS")) == 0) {
pLine = strchr(pLine, '=');
pLine = strtok(pLine, delimiters);
if(!sscanf(pLine, "%d", &CalSetup.numEthernetPorts)) {
uiPrintf("Unable to read the NUM_ETHERNET_PORTS from %s\n", eep_file);
}
}
else if(strnicmp("START_ETHERNET_PORT", pLine, strlen("START_ETHERNET_PORT")) == 0) {
pLine = strchr(pLine, '=');
pLine = strtok(pLine, delimiters);
if(!sscanf(pLine, "%d", &CalSetup.startEthernetPort)) {
uiPrintf("Unable to read the START_ETHERNET_PORT from %s\n", eep_file);
}
}
else if(strnicmp("TURBO_DISABLE", pLine, strlen("TURBO_DISABLE")) == 0) {
pLine = strchr(pLine, '=');
pLine = strtok(pLine, delimiters);
if(!sscanf(pLine, "%d", &testVal)) {
uiPrintf("Unable to read the TURBO_DISABLE from %s\n", eep_file);
}
else {
CalSetup.turboDisable = (testVal) ? TRUE : FALSE;
}
}
else if(strnicmp("11g_TURBO_DISABLE", pLine, strlen("11g_TURBO_DISABLE")) == 0) {
pLine = strchr(pLine, '=');
pLine = strtok(pLine, delimiters);
if(!sscanf(pLine, "%d", &testVal)) {
uiPrintf("Unable to read the 11g_TURBO_DISABLE from %s\n", eep_file);
}
else {
CalSetup.turboDisable_11g = (testVal) ? TRUE : FALSE;
}
}
else if(strnicmp("RF_SILENT", pLine, strlen("RF_SILENT")) == 0) {
pLine = strchr(pLine, '=');
pLine = strtok(pLine, delimiters);
if(!sscanf(pLine, "%d", &testVal)) {
uiPrintf("Unable to read the RF_SILENT from %s\n", eep_file);
}
else {
CalSetup.RFSilent = (testVal) ? TRUE : FALSE;
}
}
else if((strnicmp("DEVICE_TYPE", pLine, strlen("DEVICE_TYPE")) == 0) &&
((pLine[strlen("DEVICE_TYPE")] == ' ') ||
(pLine[strlen("DEVICE_TYPE")] == '\t') ) ){
pLine = strchr(pLine, '=');
pLine = strtok(pLine, delimiters);
pLine = strtok(pLine," ;#");
if(!sscanf(pLine, "%d", &CalSetup.deviceType)) {
uiPrintf("Unable to read the DEVICE_TYPE from %s\n", eep_file);
}
}
else if((strnicmp("ENABLE_32KHZ", pLine, strlen("ENABLE_32KHZ")) == 0) &&
((pLine[strlen("ENABLE_32KHZ")] == ' ') ||
(pLine[strlen("ENABLE_32KHZ")] == '\t') ) ){
pLine = strchr(pLine, '=');
pLine = strtok(pLine, delimiters);
pLine = strtok(pLine," ;#");
if(!sscanf(pLine, "%d", &CalSetup.Enable_32khz)) {
uiPrintf("Unable to read the ENABLE_32KHZ from %s\n", eep_file);
}
}
else if(strnicmp("TURBO_MAXPOWER_5G", pLine, strlen("TURBO_MAXPOWER_5G")) == 0) {
pLine = strchr(pLine, '=');
pLine = strtok(pLine, delimiters);
if(!sscanf(pLine, "%lf", &CalSetup.TurboMaxPower_5G)) {
uiPrintf("Unable to read the TURBO_MAXPOWER_5G from %s\n", eep_file);
}
}
else if(strnicmp("TURBO_MAXPOWER_2p5G", pLine, strlen("TURBO_MAXPOWER_2p5G")) == 0) {
pLine = strchr(pLine, '=');
pLine = strtok(pLine, delimiters);
if(!sscanf(pLine, "%lf", &CalSetup.TurboMaxPower_11g)) {
uiPrintf("Unable to read the TURBO_MAXPOWER_2p5G from %s\n", eep_file);
}
}
else if(strnicmp("CCK_OFDM_DELTA", pLine, strlen("CCK_OFDM_DELTA")) == 0) {
pLine = strchr(pLine, '=');
pLine = strtok(pLine, delimiters);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -