Files
BloomPatched/src/Targets/Microchip/AVR/AVR8/Avr8TargetConfig.cpp

57 lines
2.2 KiB
C++
Raw Normal View History

#include "Avr8TargetConfig.hpp"
#include "src/Helpers/String.hpp"
2022-08-04 21:08:41 +01:00
#include "src/Helpers/Paths.hpp"
#include "src/Exceptions/InvalidConfig.hpp"
namespace Bloom::Targets::Microchip::Avr::Avr8Bit
{
2022-11-16 23:51:07 +00:00
Avr8TargetConfig::Avr8TargetConfig(const TargetConfig& targetConfig)
: TargetConfig(targetConfig)
{
using Bloom::Exceptions::InvalidConfig;
const auto& targetNode = targetConfig.targetNode;
if (!targetNode["physicalInterface"]) {
throw InvalidConfig("Missing physical interface config parameter for AVR8 target.");
}
const auto physicalInterfaceName = String::asciiToLower(targetNode["physicalInterface"].as<std::string>());
2022-12-03 22:16:21 +00:00
const auto physicalInterfaceIt = Avr8TargetConfig::debugPhysicalInterfacesByConfigName.find(
physicalInterfaceName
);
2022-12-03 22:16:21 +00:00
if (physicalInterfaceIt == Avr8TargetConfig::debugPhysicalInterfacesByConfigName.end()) {
2022-08-04 21:08:41 +01:00
throw InvalidConfig(
"Invalid physical interface provided (\"" + physicalInterfaceName + "\") for AVR8 target. "
"See " + Paths::homeDomainName() + "/docs/configuration/avr8-physical-interfaces for valid physical "
"interface configuration values."
);
}
2022-12-03 22:16:21 +00:00
this->physicalInterface = physicalInterfaceIt->second;
// The 'manageDwenFuseBit' param used to be 'updateDwenFuseBit' - we still support the old, for now.
if (targetNode["updateDwenFuseBit"]) {
this->manageDwenFuseBit = targetNode["updateDwenFuseBit"].as<bool>();
}
if (targetNode["manageDwenFuseBit"]) {
this->manageDwenFuseBit = targetNode["manageDwenFuseBit"].as<bool>();
}
if (targetNode["cycleTargetPowerPostDwenUpdate"]) {
this->cycleTargetPowerPostDwenUpdate = targetNode["cycleTargetPowerPostDwenUpdate"].as<bool>();
}
if (targetNode["disableDebugWirePreDisconnect"]) {
this->disableDebugWireOnDeactivate = targetNode["disableDebugWirePreDisconnect"].as<bool>();
}
if (targetNode["targetPowerCycleDelay"]) {
this->targetPowerCycleDelay = std::chrono::milliseconds(targetNode["targetPowerCycleDelay"].as<int>());
}
}
}