From 7b79f19574331bc8ad7a5a9dc7646794d77d82f1 Mon Sep 17 00:00:00 2001 From: Nav Date: Mon, 21 Mar 2022 13:04:12 +0000 Subject: [PATCH] New targetPowerCycleDelay target config param, for configuring the AVR8 target power cycle delay (after updating the DWEN fuse bit) --- src/Targets/Microchip/AVR/AVR8/Avr8.cpp | 8 ++++++-- src/Targets/Microchip/AVR/AVR8/Avr8TargetConfig.cpp | 6 ++++++ src/Targets/Microchip/AVR/AVR8/Avr8TargetConfig.hpp | 6 ++++++ 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/Targets/Microchip/AVR/AVR8/Avr8.cpp b/src/Targets/Microchip/AVR/AVR8/Avr8.cpp index 55d8594a..10cd8f23 100644 --- a/src/Targets/Microchip/AVR/AVR8/Avr8.cpp +++ b/src/Targets/Microchip/AVR/AVR8/Avr8.cpp @@ -143,8 +143,12 @@ namespace Bloom::Targets::Microchip::Avr::Avr8Bit Logger::debug("Disabling target power"); this->targetPowerManagementInterface->disableTargetPower(); - Logger::debug("Holding power off for ~250 ms"); - std::this_thread::sleep_for(std::chrono::milliseconds(250)); + Logger::debug( + "Holding power off for ~" + + std::to_string(this->targetConfig->targetPowerCycleDelay.count()) + + " ms" + ); + std::this_thread::sleep_for(this->targetConfig->targetPowerCycleDelay); Logger::debug("Enabling target power"); this->targetPowerManagementInterface->enableTargetPower(); diff --git a/src/Targets/Microchip/AVR/AVR8/Avr8TargetConfig.cpp b/src/Targets/Microchip/AVR/AVR8/Avr8TargetConfig.cpp index 763439b4..7c5b9a74 100644 --- a/src/Targets/Microchip/AVR/AVR8/Avr8TargetConfig.cpp +++ b/src/Targets/Microchip/AVR/AVR8/Avr8TargetConfig.cpp @@ -38,5 +38,11 @@ namespace Bloom::Targets::Microchip::Avr::Avr8Bit "disableDebugWirePreDisconnect" ).toBool(); } + + if (targetConfig.jsonObject.contains("targetPowerCycleDelay")) { + this->targetPowerCycleDelay = std::chrono::milliseconds(targetConfig.jsonObject.value( + "targetPowerCycleDelay" + ).toInt(static_cast(this->targetPowerCycleDelay.count()))); + } } } diff --git a/src/Targets/Microchip/AVR/AVR8/Avr8TargetConfig.hpp b/src/Targets/Microchip/AVR/AVR8/Avr8TargetConfig.hpp index d7a68e7e..2e1d91f7 100644 --- a/src/Targets/Microchip/AVR/AVR8/Avr8TargetConfig.hpp +++ b/src/Targets/Microchip/AVR/AVR8/Avr8TargetConfig.hpp @@ -1,5 +1,9 @@ #pragma once +#include +#include +#include + #include "src/ProjectConfig.hpp" #include "PhysicalInterface.hpp" @@ -55,6 +59,8 @@ namespace Bloom::Targets::Microchip::Avr::Avr8Bit */ bool cycleTargetPowerPostDwenUpdate = true; + std::chrono::milliseconds targetPowerCycleDelay = std::chrono::milliseconds(250); + explicit Avr8TargetConfig(const TargetConfig& targetConfig); private: