Skip to content

Commit

Permalink
gui: show all board's non volatile memory parameters.
Browse files Browse the repository at this point in the history
Fix LimeSDR-USB VCTCXO non volatile value reading
xtrx: add VCTCXO non volatile value access
  • Loading branch information
rjonaitis committed May 20, 2024
1 parent d670361 commit bf4ce5f
Show file tree
Hide file tree
Showing 10 changed files with 21 additions and 24 deletions.
14 changes: 11 additions & 3 deletions GUI/boards/pnlBoardControls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ pnlBoardControls::pnlBoardControls(

pnlEEPROMControls = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0);
wxStaticBoxSizer* eepromBoxSizer =
new wxStaticBoxSizer(new wxStaticBox(pnlEEPROMControls, wxID_ANY, wxT("EEPROM")), wxVERTICAL);
new wxStaticBoxSizer(new wxStaticBox(pnlEEPROMControls, wxID_ANY, wxT("Non Volatile memory")), wxVERTICAL);
pnlEEPROMControls->SetSizer(eepromBoxSizer);
EEPROMsizer = new wxFlexGridSizer(0, 4, 0, 0);
eepromBoxSizer->Add(EEPROMsizer, 1, wxEXPAND | wxALL, 5);
Expand Down Expand Up @@ -430,7 +430,7 @@ OpStatus pnlBoardControls::ReadMemory(MemoryParamGUI* gui)
long val = 0;
assert(sizeof(val) >= size_t(gui->memoryRegion.size));
OpStatus rez = mDevice->MemoryRead(gui->dataStorage, gui->memoryRegion, &val);
if (rez != OpStatus::Success)
if (rez == OpStatus::Success)
gui->txtValue->SetValue(std::to_string(val));
return rez;
}
Expand Down Expand Up @@ -557,8 +557,16 @@ void pnlBoardControls::SetupControls(const std::string_view boardID)
for (const auto& region : regions)
{
MemoryParamGUI* gui = new MemoryParamGUI();
gui->title = new wxStaticText(pnlEEPROMControls, wxID_ANY, ToString(region.first));
gui->title = new wxStaticText(pnlEEPROMControls, wxID_ANY, region.first);
gui->txtValue = new wxTextCtrl(pnlEEPROMControls, wxNewId(), _("0"), wxDefaultPosition, wxDefaultSize);
#if wxUSE_TOOLTIPS
wxString tooltip = wxString::Format(_("[%s]\n%s @ 0x%08X : %i Bytes"),
mem.first.c_str(),
region.first.c_str(),
region.second.address,
region.second.size);
gui->txtValue->SetToolTip(tooltip);
#endif
gui->btnRead = new wxButton(pnlEEPROMControls, wxNewId(), _("Read"), wxDefaultPosition, wxDefaultSize);
gui->btnWrite = new wxButton(pnlEEPROMControls, wxNewId(), _("Write"), wxDefaultPosition, wxDefaultSize);
gui->dataStorage = mem.second;
Expand Down
4 changes: 2 additions & 2 deletions src/API/LMS_APIWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1955,7 +1955,7 @@ API_EXPORT int CALL_CONV LMS_VCTCXOWrite(lms_device_t* device, uint16_t val)
const auto& dataStorage = apiDevice->device->GetDescriptor().memoryDevices.at(ToString(memoryDevice));
try
{
const auto& region = dataStorage->regions.at(lime::eMemoryRegion::VCTCXO_DAC);
const auto& region = dataStorage->regions.at("VCTCXO_DAC"s);
OpStatus status = apiDevice->device->MemoryWrite(dataStorage, region, &val);
return OpStatusToReturnCode(status);
} catch (std::out_of_range& e)
Expand Down Expand Up @@ -2006,7 +2006,7 @@ API_EXPORT int CALL_CONV LMS_VCTCXORead(lms_device_t* device, uint16_t* val)
const auto& dataStorage = apiDevice->device->GetDescriptor().memoryDevices.at(ToString(memoryDevice));
try
{
const auto& region = dataStorage->regions.at(lime::eMemoryRegion::VCTCXO_DAC);
const auto& region = dataStorage->regions.at("VCTCXO_DAC"s);

OpStatus status = apiDevice->device->MemoryRead(dataStorage, region, val);
return OpStatusToReturnCode(status);
Expand Down
2 changes: 1 addition & 1 deletion src/boards/LimeSDR/LimeSDR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,8 @@ LimeSDR::LimeSDR(std::shared_ptr<IComms> spiLMS,
descriptor.socTree = std::make_shared<DeviceTreeNode>("SDR-USB"s, eDeviceTreeNodeClass::SDRDevice, this);
descriptor.socTree->children.push_back(fpgaNode);

const std::unordered_map<eMemoryRegion, Region> eepromMap = { { eMemoryRegion::VCTCXO_DAC, { 16, 2 } } };
descriptor.memoryDevices[ToString(eMemoryDevice::FPGA_FLASH)] = std::make_shared<DataStorage>(this, eMemoryDevice::FPGA_FLASH);
const std::unordered_map<std::string, Region> eepromMap = { { "VCTCXO_DAC"s, { 0x0010, 1 } } };
descriptor.memoryDevices[ToString(eMemoryDevice::EEPROM)] =
std::make_shared<DataStorage>(this, eMemoryDevice::EEPROM, eepromMap);

Expand Down
2 changes: 1 addition & 1 deletion src/boards/LimeSDR_X3/LimeSDR_X3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ LimeSDR_X3::LimeSDR_X3(std::shared_ptr<IComms> spiLMS7002M,
{ "FPGA"s, SPI_FPGA },
};

const std::unordered_map<eMemoryRegion, Region> eepromMap = { { eMemoryRegion::VCTCXO_DAC, { 16, 2 } } };
const std::unordered_map<std::string, Region> eepromMap = { { "VCTCXO_DAC"s, { 16, 2 } } };

desc.memoryDevices[ToString(eMemoryDevice::FPGA_FLASH)] = std::make_shared<DataStorage>(this, eMemoryDevice::FPGA_FLASH);
desc.memoryDevices[ToString(eMemoryDevice::EEPROM)] = std::make_shared<DataStorage>(this, eMemoryDevice::EEPROM, eepromMap);
Expand Down
5 changes: 3 additions & 2 deletions src/boards/LimeSDR_XTRX/LimeSDR_XTRX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,9 @@ LimeSDR_XTRX::LimeSDR_XTRX(std::shared_ptr<IComms> spiRFsoc,

desc.spiSlaveIds = { { "LMS7002M"s, SPI_LMS7002M }, { "FPGA"s, SPI_FPGA } };

// desc.memoryDevices[ToString(eMemoryDevice::FPGA_RAM)] = std::make_shared<DataStorage>(this, eMemoryDevice::FPGA_RAM);
desc.memoryDevices[ToString(eMemoryDevice::FPGA_FLASH)] = std::make_shared<DataStorage>(this, eMemoryDevice::FPGA_FLASH);
const std::unordered_map<std::string, Region> flashMap = { { "VCTCXO_DAC"s, { 16, 2 } } };
desc.memoryDevices[ToString(eMemoryDevice::FPGA_FLASH)] =
std::make_shared<DataStorage>(this, eMemoryDevice::FPGA_FLASH, flashMap);

desc.customParameters.push_back(cp_vctcxo_dac);

Expand Down
2 changes: 1 addition & 1 deletion src/boards/MMX8/MM_X8.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ LimeSDR_MMX8::LimeSDR_MMX8(std::vector<std::shared_ptr<IComms>>& spiLMS7002M,
mSubDevices.resize(8);
desc.spiSlaveIds["FPGA"s] = 0;

const std::unordered_map<eMemoryRegion, Region> eepromMap = { { eMemoryRegion::VCTCXO_DAC, { 16, 2 } } };
const std::unordered_map<std::string, Region> eepromMap = { { "VCTCXO_DAC"s, { 16, 2 } } };

desc.memoryDevices[ToString(eMemoryDevice::FPGA_FLASH)] = std::make_shared<DataStorage>(this, eMemoryDevice::FPGA_FLASH);
desc.memoryDevices[ToString(eMemoryDevice::EEPROM)] = std::make_shared<DataStorage>(this, eMemoryDevice::EEPROM, eepromMap);
Expand Down
4 changes: 2 additions & 2 deletions src/include/limesuiteng/SDRDescriptor.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ struct CustomParameter {
struct DataStorage {
SDRDevice* ownerDevice; ///< Pointer to the device that actually owns the data storage
eMemoryDevice memoryDeviceType; ///< The type of memory being described
std::unordered_map<eMemoryRegion, Region> regions; ///< The documented memory regions of the data storage
std::unordered_map<std::string, Region> regions; ///< The documented memory regions of the data storage

/// @brief Constructs a new Data Storage object
/// @param device The device this storage belongs to.
/// @param type The type of memory being described in this object.
/// @param regions The memory regions this memory contains.
DataStorage(SDRDevice* device = nullptr,
eMemoryDevice type = eMemoryDevice::COUNT,
std::unordered_map<eMemoryRegion, Region> regions = {})
std::unordered_map<std::string, Region> regions = {})
: ownerDevice(device)
, memoryDeviceType(type)
, regions(regions)
Expand Down
2 changes: 0 additions & 2 deletions src/include/limesuiteng/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ struct Range {
double step; ///< The step of the range (or 0.0 for any step)
};

enum class eMemoryRegion : uint8_t { VCTCXO_DAC, COUNT };

/// @brief Structure for storing the information of a memory region.
struct Region {
int32_t address; ///< Starting address of the memory region
Expand Down
9 changes: 0 additions & 9 deletions src/utilities/toString.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,6 @@ const std::string& ToString(OpStatus value)
return OP_STATUS_TEXT.at(value);
}

static const std::unordered_map<eMemoryRegion, const std::string> MEMORY_REGIONS_TEXT{
{ eMemoryRegion::VCTCXO_DAC, "VCTCXO DAC (non-volatile)"s },
};

const std::string& ToString(eMemoryRegion value)
{
return MEMORY_REGIONS_TEXT.at(value);
}

static const std::unordered_map<eGainTypes, const std::string> GAIN_TYPES_TEXT{
{ eGainTypes::LNA, "LNA"s },
{ eGainTypes::LoopbackLNA, "LB_LNA"s },
Expand Down
1 change: 0 additions & 1 deletion src/utilities/toString.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ LIME_API const std::string& ToString(TRXDir dir);
/// @return The string representing the status.
LIME_API const std::string& ToString(OpStatus value);

LIME_API const std::string& ToString(eMemoryRegion value);
LIME_API const std::string& ToString(eGainTypes value);
LIME_API const std::string& ToString(eMemoryDevice value);

Expand Down

0 comments on commit bf4ce5f

Please sign in to comment.