Moved AVR8 physicalInterface config extraction out of EDBG driver
This commit is contained in:
@@ -52,39 +52,6 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
|
||||
using Bloom::Targets::TargetRegisters;
|
||||
|
||||
void EdbgAvr8Interface::configure(const TargetConfig& targetConfig) {
|
||||
auto physicalInterface = targetConfig.jsonObject.find("physicalInterface")->toString().toLower().toStdString();
|
||||
|
||||
auto availablePhysicalInterfaces = this->getPhysicalInterfacesByName();
|
||||
|
||||
if (physicalInterface.empty()
|
||||
|| availablePhysicalInterfaces.find(physicalInterface) == availablePhysicalInterfaces.end()
|
||||
) {
|
||||
throw InvalidConfig("Invalid or missing physical interface config parameter for AVR8 target.");
|
||||
}
|
||||
|
||||
auto selectedPhysicalInterface = availablePhysicalInterfaces.find(physicalInterface)->second;
|
||||
|
||||
if (selectedPhysicalInterface == PhysicalInterface::DEBUG_WIRE) {
|
||||
Logger::warning("AVR8 debugWire interface selected - the DWEN fuse will need to be enabled");
|
||||
}
|
||||
|
||||
this->physicalInterface = selectedPhysicalInterface;
|
||||
|
||||
if (!this->family.has_value()) {
|
||||
if (this->physicalInterface == PhysicalInterface::JTAG) {
|
||||
throw InvalidConfig("The JTAG physical interface cannot be used with an ambiguous target name"
|
||||
" - please specify the exact name of the target in your configuration file. "
|
||||
"See " + Paths::homeDomainName() + "/docs/supported-targets"
|
||||
);
|
||||
|
||||
} else if (this->physicalInterface == PhysicalInterface::UPDI) {
|
||||
throw InvalidConfig("The UPDI physical interface cannot be used with an ambiguous target name"
|
||||
" - please specify the exact name of the target in your configuration file. "
|
||||
"See " + Paths::homeDomainName() + "/docs/supported-targets"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
this->configVariant = this->resolveConfigVariant().value_or(Avr8ConfigVariant::NONE);
|
||||
|
||||
if (targetConfig.jsonObject.contains("disableDebugWirePreDisconnect")) {
|
||||
|
||||
@@ -83,6 +83,10 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
|
||||
*/
|
||||
void configure(const TargetConfig& targetConfig) override;
|
||||
|
||||
void setPhysicalInterface(Targets::Microchip::Avr::Avr8Bit::PhysicalInterface physicalInterface) override {
|
||||
this->physicalInterface = physicalInterface;
|
||||
}
|
||||
|
||||
/**
|
||||
* Configures the target family. For some physical interfaces, the target family is required in order
|
||||
* properly configure the EDBG tool. See EdbgAvr8Interface::resolveConfigVariant() for more.
|
||||
@@ -346,22 +350,6 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
|
||||
*/
|
||||
bool disableDebugWireOnDeactivate = false;
|
||||
|
||||
/**
|
||||
* Users are required to set their desired physical interface in their Bloom configuration. This would take
|
||||
* the form of a string, so we map the available options to the appropriate enums.
|
||||
*/
|
||||
static inline auto getPhysicalInterfacesByName() {
|
||||
using Targets::Microchip::Avr::Avr8Bit::PhysicalInterface;
|
||||
|
||||
return std::map<std::string, PhysicalInterface>({
|
||||
{"debugwire", PhysicalInterface::DEBUG_WIRE},
|
||||
{"debug-wire", PhysicalInterface::DEBUG_WIRE},
|
||||
{"pdi", PhysicalInterface::PDI},
|
||||
{"jtag", PhysicalInterface::JTAG},
|
||||
{"updi", PhysicalInterface::UPDI},
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* This mapping allows us to determine which config variant to select, based on the target family and the
|
||||
* selected physical interface.
|
||||
|
||||
Reference in New Issue
Block a user