2022-03-19 13:26:04 +00:00
|
|
|
#include "Avr8TargetConfig.hpp"
|
|
|
|
|
|
2022-07-23 15:37:22 +01:00
|
|
|
#include "src/Helpers/String.hpp"
|
2022-12-26 21:47:09 +00:00
|
|
|
#include "src/Services/PathService.hpp"
|
2022-03-19 13:26:04 +00:00
|
|
|
#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)
|
|
|
|
|
{
|
2022-03-19 13:26:04 +00:00
|
|
|
using Bloom::Exceptions::InvalidConfig;
|
|
|
|
|
|
2022-07-23 15:37:22 +01:00
|
|
|
const auto& targetNode = targetConfig.targetNode;
|
|
|
|
|
|
|
|
|
|
if (!targetNode["physicalInterface"]) {
|
2022-03-19 13:26:04 +00:00
|
|
|
throw InvalidConfig("Missing physical interface config parameter for AVR8 target.");
|
|
|
|
|
}
|
|
|
|
|
|
2022-07-23 15:37:22 +01:00
|
|
|
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-03-19 13:26:04 +00:00
|
|
|
|
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. "
|
2022-12-26 21:47:09 +00:00
|
|
|
"See " + Services::PathService::homeDomainName() + "/docs/configuration/avr8-physical-interfaces for valid physical "
|
2022-08-04 21:08:41 +01:00
|
|
|
"interface configuration values."
|
|
|
|
|
);
|
2022-03-19 13:26:04 +00:00
|
|
|
}
|
|
|
|
|
|
2022-12-03 22:16:21 +00:00
|
|
|
this->physicalInterface = physicalInterfaceIt->second;
|
2022-03-19 13:26:04 +00:00
|
|
|
|
2022-09-18 13:02:33 +01:00
|
|
|
// The 'manageDwenFuseBit' param used to be 'updateDwenFuseBit' - we still support the old, for now.
|
2022-07-23 15:37:22 +01:00
|
|
|
if (targetNode["updateDwenFuseBit"]) {
|
2022-09-18 13:02:33 +01:00
|
|
|
this->manageDwenFuseBit = targetNode["updateDwenFuseBit"].as<bool>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (targetNode["manageDwenFuseBit"]) {
|
|
|
|
|
this->manageDwenFuseBit = targetNode["manageDwenFuseBit"].as<bool>();
|
2022-03-19 13:26:04 +00:00
|
|
|
}
|
|
|
|
|
|
2022-07-23 15:37:22 +01:00
|
|
|
if (targetNode["cycleTargetPowerPostDwenUpdate"]) {
|
|
|
|
|
this->cycleTargetPowerPostDwenUpdate = targetNode["cycleTargetPowerPostDwenUpdate"].as<bool>();
|
2022-03-19 13:26:04 +00:00
|
|
|
}
|
|
|
|
|
|
2022-07-23 15:37:22 +01:00
|
|
|
if (targetNode["disableDebugWirePreDisconnect"]) {
|
|
|
|
|
this->disableDebugWireOnDeactivate = targetNode["disableDebugWirePreDisconnect"].as<bool>();
|
2022-03-19 13:26:04 +00:00
|
|
|
}
|
2022-03-21 13:04:12 +00:00
|
|
|
|
2022-07-23 15:37:22 +01:00
|
|
|
if (targetNode["targetPowerCycleDelay"]) {
|
|
|
|
|
this->targetPowerCycleDelay = std::chrono::milliseconds(targetNode["targetPowerCycleDelay"].as<int>());
|
2022-03-21 13:04:12 +00:00
|
|
|
}
|
2022-03-19 13:26:04 +00:00
|
|
|
}
|
|
|
|
|
}
|