From 80e5678ddfa6a77f179434635f3e5f03789e0fe0 Mon Sep 17 00:00:00 2001 From: Nav Date: Wed, 16 Mar 2022 17:21:12 +0000 Subject: [PATCH] New "cycleTargetPowerPostDwenUpdate" target config param to control the automatic cycling of target power, after updating the target's DWEN fuse bit --- src/Targets/Microchip/AVR/AVR8/Avr8.cpp | 11 ++++++++++- src/Targets/Microchip/AVR/AVR8/Avr8.hpp | 1 + 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/Targets/Microchip/AVR/AVR8/Avr8.cpp b/src/Targets/Microchip/AVR/AVR8/Avr8.cpp index e72fa4d8..530909d3 100644 --- a/src/Targets/Microchip/AVR/AVR8/Avr8.cpp +++ b/src/Targets/Microchip/AVR/AVR8/Avr8.cpp @@ -81,6 +81,12 @@ namespace Bloom::Targets::Microchip::Avr::Avr8Bit } } + if (targetConfig.jsonObject.contains("cycleTargetPowerPostDwenUpdate")) { + this->cycleTargetPowerPostDwenUpdate = targetConfig.jsonObject.value( + "cycleTargetPowerPostDwenUpdate" + ).toBool(); + } + this->avr8DebugInterface->configure(targetConfig); if (this->avrIspInterface != nullptr) { @@ -154,12 +160,15 @@ namespace Bloom::Targets::Microchip::Avr::Avr8Bit this->writeDwenFuseBit(true); // If the debug tool provides a TargetPowerManagementInterface, attempt to cycle the target power - if (this->targetPowerManagementInterface != nullptr) { + if (this->targetPowerManagementInterface != nullptr && this->cycleTargetPowerPostDwenUpdate) { Logger::info("Cycling target power"); + 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("Enabling target power"); this->targetPowerManagementInterface->enableTargetPower(); } diff --git a/src/Targets/Microchip/AVR/AVR8/Avr8.hpp b/src/Targets/Microchip/AVR/AVR8/Avr8.hpp index 2d986630..4fa23cb1 100644 --- a/src/Targets/Microchip/AVR/AVR8/Avr8.hpp +++ b/src/Targets/Microchip/AVR/AVR8/Avr8.hpp @@ -139,6 +139,7 @@ namespace Bloom::Targets::Microchip::Avr::Avr8Bit std::map targetMemoryDescriptorsByType; bool updateDwenFuseBit = false; + bool cycleTargetPowerPostDwenUpdate = true; /** * Users are required to set their desired physical interface in their Bloom configuration. This would take