Made physical interface enum more generic (moved out of AVR8-specific context)

This commit is contained in:
Nav
2024-02-15 21:24:41 +00:00
parent f33b4d8c70
commit 7e9e28286f
20 changed files with 156 additions and 160 deletions

View File

@@ -97,6 +97,30 @@ namespace Targets::TargetDescription
return addressSpace->get();
}
std::set<TargetPhysicalInterface> TargetDescriptionFile::getPhysicalInterfaces() const {
static const auto physicalInterfacesByName = BiMap<std::string, TargetPhysicalInterface>({
{"updi", TargetPhysicalInterface::UPDI},
{"debugwire", TargetPhysicalInterface::DEBUG_WIRE},
{"jtag", TargetPhysicalInterface::JTAG},
{"pdi", TargetPhysicalInterface::PDI},
{"isp", TargetPhysicalInterface::ISP},
});
auto output = std::set<TargetPhysicalInterface>();
for (const auto& physicalInterface : this->physicalInterfaces) {
const auto interface = physicalInterfacesByName.valueAt(
StringService::asciiToLower(physicalInterface.name)
);
if (interface.has_value()) {
output.insert(*interface);
}
}
return output;
}
void TargetDescriptionFile::init(const std::string& xmlFilePath) {
auto file = QFile(QString::fromStdString(xmlFilePath));
if (!file.exists()) {