Skip to content

Commit

Permalink
LimeQuickTest: Restore DAC value after test
Browse files Browse the repository at this point in the history
  • Loading branch information
ignasJ committed Jun 13, 2018
1 parent f1e5444 commit 192b512
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions QuickTest/LimeSDRTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,33 +239,44 @@ int LimeSDRTest::GPIFClkTest()

int LimeSDRTest::VCTCXOTest()
{
uint8_t id = 0;
const uint8_t id = 0;
double val = 0;
unsigned count1;
unsigned count2;
double dac_value;
std::string units = "";
auto conn = device->GetConnection();

if (conn->CustomParameterRead(&id, &dac_value, 1, nullptr) != 0)
return -1;

auto restore_dac = [&,id](int ret){
if (conn->CustomParameterWrite(&id, &dac_value, 1, units) != 0)
return -1;
return ret;
};

if (conn->CustomParameterWrite(&id, &val, 1, units) != 0)
return -1;

if ((InitFPGATest(0x04, 1.0) & 0x4) != 0x4)
return -1;
return restore_dac(-1);

uint32_t addr[] = { 0x72, 0x73 };
uint32_t vals[2];
if (conn->ReadRegisters(addr, vals, 2) != 0)
return -1;
return restore_dac(-1);

count1 = vals[0] + (vals[1] << 16);
val = 254;
if (conn->CustomParameterWrite(&id, &val, 1, units) != 0)
return -1;

if ((InitFPGATest(0x04, 1.0) & 0x4) != 0x4)
return -1;
return restore_dac(-1);;

if (conn->ReadRegisters(addr, vals, 2) != 0)
return -1;
return restore_dac(-1);;

count2 = vals[0] + (vals[1] << 16);
std::string str = " Results : " + std::to_string(count1) + " (min); " + std::to_string(count2) + " (max)";
Expand All @@ -274,11 +285,11 @@ int LimeSDRTest::VCTCXOTest()
{
str += " - FAILED";
UpdateStatus(LMS_TEST_INFO, str.c_str());
return -1;
return restore_dac(-1);;
}
str += " - PASSED";
UpdateStatus(LMS_TEST_INFO, str.c_str());
return 0;
return restore_dac(0);
}

int LimeSDRTest::Reg_write(uint16_t address, uint16_t data)
Expand Down

0 comments on commit 192b512

Please sign in to comment.