From 419fcbb2f0400dd68be33302aa5998a3937d860a Mon Sep 17 00:00:00 2001 From: Nav Date: Sun, 27 Jun 2021 21:33:08 +0100 Subject: [PATCH] Tidying --- src/Targets/Microchip/AVR/AVR8/Avr8.cpp | 92 ++++++++++++------------- 1 file changed, 46 insertions(+), 46 deletions(-) diff --git a/src/Targets/Microchip/AVR/AVR8/Avr8.cpp b/src/Targets/Microchip/AVR/AVR8/Avr8.cpp index 4154adc5..53e37fbf 100644 --- a/src/Targets/Microchip/AVR/AVR8/Avr8.cpp +++ b/src/Targets/Microchip/AVR/AVR8/Avr8.cpp @@ -24,50 +24,6 @@ using namespace Bloom::Targets::Microchip::Avr; using namespace Bloom::Targets::Microchip::Avr::Avr8Bit; using namespace Exceptions; -void Avr8::preActivationConfigure(const TargetConfig& targetConfig) { - Target::preActivationConfigure(targetConfig); - - if (this->family.has_value()) { - this->avr8Interface->setFamily(this->family.value()); - } - - this->avr8Interface->configure(targetConfig); -} - -void Avr8::postActivationConfigure() { - if (!this->targetDescriptionFile.has_value()) { - this->loadTargetDescriptionFile(); - this->initFromTargetDescriptionFile(); - } - - /* - * The signature obtained from the device should match what is in the target description file - * - * We don't use this->getId() here as that could return the ID that was extracted from the target description file - * (which it would, if the user specified the exact target name in their project config - see Avr8::getId() and - * TargetController::getSupportedTargets() for more). - */ - auto targetSignature = this->avr8Interface->getDeviceId(); - auto tdSignature = this->targetDescriptionFile->getTargetSignature(); - - if (targetSignature != tdSignature) { - throw Exception("Failed to validate connected target - target signature mismatch.\nThe target signature" - " (\"" + targetSignature.toHex() + "\") does not match the AVR8 target description signature (\"" - + tdSignature.toHex() + "\"). This will likely be due to an incorrect target name in the configuration file" - + " (bloom.json)." - ); - } -} - -void Avr8::postPromotionConfigure() { - if (!this->family.has_value()) { - throw Exception("Failed to resolve AVR8 family"); - } - - this->avr8Interface->setFamily(this->family.value()); - this->avr8Interface->setTargetParameters(this->targetParameters.value()); -} - void Avr8::loadTargetDescriptionFile() { this->targetDescriptionFile = TargetDescription::TargetDescriptionFile( this->getId(), @@ -151,8 +107,8 @@ void Avr8::loadTargetParameters() { if (stackPointerHighRegister.has_value()) { this->targetParameters->stackPointerRegisterSize = (this->targetParameters->stackPointerRegisterSize.has_value()) ? - this->targetParameters->stackPointerRegisterSize.value() + stackPointerHighRegister->size : - stackPointerHighRegister->size; + this->targetParameters->stackPointerRegisterSize.value() + stackPointerHighRegister->size : + stackPointerHighRegister->size; } } @@ -556,6 +512,50 @@ TargetSignature Avr8::getId() { return this->id.value(); } +void Avr8::preActivationConfigure(const TargetConfig& targetConfig) { + Target::preActivationConfigure(targetConfig); + + if (this->family.has_value()) { + this->avr8Interface->setFamily(this->family.value()); + } + + this->avr8Interface->configure(targetConfig); +} + +void Avr8::postActivationConfigure() { + if (!this->targetDescriptionFile.has_value()) { + this->loadTargetDescriptionFile(); + this->initFromTargetDescriptionFile(); + } + + /* + * The signature obtained from the device should match what is in the target description file + * + * We don't use this->getId() here as that could return the ID that was extracted from the target description file + * (which it would, if the user specified the exact target name in their project config - see Avr8::getId() and + * TargetController::getSupportedTargets() for more). + */ + auto targetSignature = this->avr8Interface->getDeviceId(); + auto tdSignature = this->targetDescriptionFile->getTargetSignature(); + + if (targetSignature != tdSignature) { + throw Exception("Failed to validate connected target - target signature mismatch.\nThe target signature" + " (\"" + targetSignature.toHex() + "\") does not match the AVR8 target description signature (\"" + + tdSignature.toHex() + "\"). This will likely be due to an incorrect target name in the configuration file" + + " (bloom.json)." + ); + } +} + +void Avr8::postPromotionConfigure() { + if (!this->family.has_value()) { + throw Exception("Failed to resolve AVR8 family"); + } + + this->avr8Interface->setFamily(this->family.value()); + this->avr8Interface->setTargetParameters(this->targetParameters.value()); +} + void Avr8::activate() { if (this->isActivated()) { return;