diff --git a/src/EventManager/Events/Event.hpp b/src/EventManager/Events/Event.hpp index 5151abcb..1136b7bb 100644 --- a/src/EventManager/Events/Event.hpp +++ b/src/EventManager/Events/Event.hpp @@ -51,7 +51,6 @@ namespace Bloom::Events RETRIEVE_TARGET_PIN_STATES, TARGET_PIN_STATES_RETRIEVED, SET_TARGET_PIN_STATE, - TARGET_IO_PORTS_UPDATED, }; class Event diff --git a/src/EventManager/Events/Events.hpp b/src/EventManager/Events/Events.hpp index e0f7a748..0e236a42 100644 --- a/src/EventManager/Events/Events.hpp +++ b/src/EventManager/Events/Events.hpp @@ -39,7 +39,6 @@ #include "RetrieveTargetPinStates.hpp" #include "TargetPinStatesRetrieved.hpp" #include "SetTargetPinState.hpp" -#include "TargetIoPortsUpdated.hpp" namespace Bloom::Events { diff --git a/src/EventManager/Events/TargetIoPortsUpdated.hpp b/src/EventManager/Events/TargetIoPortsUpdated.hpp deleted file mode 100644 index a90c719b..00000000 --- a/src/EventManager/Events/TargetIoPortsUpdated.hpp +++ /dev/null @@ -1,23 +0,0 @@ -#pragma once - -#include - -#include "Event.hpp" - -namespace Bloom::Events -{ - class TargetIoPortsUpdated: public Event - { - public: - static inline EventType type = EventType::TARGET_IO_PORTS_UPDATED; - static inline const std::string name = "TargetIoPortsUpdated"; - - [[nodiscard]] EventType getType() const override { - return TargetIoPortsUpdated::type; - } - - [[nodiscard]] std::string getName() const override { - return TargetIoPortsUpdated::name; - } - }; -} diff --git a/src/Insight/Insight.cpp b/src/Insight/Insight.cpp index 1a41e539..75d73e0f 100644 --- a/src/Insight/Insight.cpp +++ b/src/Insight/Insight.cpp @@ -75,7 +75,6 @@ void Insight::startup() { this->connect(this->insightWorker, &InsightWorker::targetControllerResumed, this->mainWindow, &InsightWindow::onTargetControllerResumed); this->connect(this->insightWorker, &InsightWorker::targetStateUpdated, this->mainWindow, &InsightWindow::onTargetStateUpdate); this->connect(this->insightWorker, &InsightWorker::targetProgramCounterUpdated, this->mainWindow, &InsightWindow::onTargetProgramCounterUpdate); - this->connect(this->insightWorker, &InsightWorker::targetIoPortsUpdated, this->mainWindow, &InsightWindow::onTargetIoPortsUpdate); this->connect(this->mainWindow, &InsightWindow::refreshTargetPinStates, this->insightWorker, &InsightWorker::requestPinStates); this->mainWindow->setInsightConfig(this->insightConfig); diff --git a/src/Insight/InsightWorker/InsightWorker.cpp b/src/Insight/InsightWorker/InsightWorker.cpp index 5b447cb4..68693533 100644 --- a/src/Insight/InsightWorker/InsightWorker.cpp +++ b/src/Insight/InsightWorker/InsightWorker.cpp @@ -28,10 +28,6 @@ void InsightWorker::startup() { std::bind(&InsightWorker::onTargetResumedEvent, this, std::placeholders::_1) ); - this->eventListener->registerCallbackForEventType( - std::bind(&InsightWorker::onTargetIoPortsUpdatedEvent, this, std::placeholders::_1) - ); - this->eventListener->registerCallbackForEventType( std::bind(&InsightWorker::onTargetRegistersWrittenEvent, this, std::placeholders::_1) ); @@ -117,10 +113,6 @@ void InsightWorker::onTargetResumedEvent(const Events::TargetExecutionResumed& e emit this->targetStateUpdated(TargetState::RUNNING); } -void InsightWorker::onTargetIoPortsUpdatedEvent(const Events::TargetIoPortsUpdated& event) { - emit this->targetIoPortsUpdated(); -} - void InsightWorker::onTargetRegistersWrittenEvent(const Events::RegistersWrittenToTarget& event) { emit this->targetRegistersWritten(event.registers); } diff --git a/src/Insight/InsightWorker/InsightWorker.hpp b/src/Insight/InsightWorker/InsightWorker.hpp index 99ac7b44..40ab42cc 100644 --- a/src/Insight/InsightWorker/InsightWorker.hpp +++ b/src/Insight/InsightWorker/InsightWorker.hpp @@ -39,7 +39,6 @@ namespace Bloom void onTargetStoppedEvent(const Events::TargetExecutionStopped& event); void onTargetResumedEvent(const Events::TargetExecutionResumed& event); - void onTargetIoPortsUpdatedEvent(const Events::TargetIoPortsUpdated& event); void onTargetRegistersWrittenEvent(const Events::RegistersWrittenToTarget& event); void onTargetControllerStateReportedEvent(const Events::TargetControllerStateReported& event); @@ -63,7 +62,6 @@ namespace Bloom void taskQueued(); void targetStateUpdated(Bloom::Targets::TargetState newState); void targetProgramCounterUpdated(quint32 programCounter); - void targetIoPortsUpdated(); void targetControllerSuspended(); void targetControllerResumed(const Bloom::Targets::TargetDescriptor& targetDescriptor); void targetRegistersWritten(const Bloom::Targets::TargetRegisters& targetRegisters); diff --git a/src/Insight/UserInterfaces/InsightWindow/InsightWindow.cpp b/src/Insight/UserInterfaces/InsightWindow/InsightWindow.cpp index 734e9d73..252466c6 100644 --- a/src/Insight/UserInterfaces/InsightWindow/InsightWindow.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/InsightWindow.cpp @@ -482,12 +482,6 @@ void InsightWindow::onTargetProgramCounterUpdate(quint32 programCounter) { ); } -void InsightWindow::onTargetIoPortsUpdate() { - if (this->targetState == TargetState::STOPPED && this->selectedVariant != nullptr) { - emit this->refreshTargetPinStates(this->selectedVariant->id); - } -} - void InsightWindow::toggleTargetRegistersPane() { if (this->targetRegistersSidePane->activated) { this->targetRegistersSidePane->deactivate(); diff --git a/src/Insight/UserInterfaces/InsightWindow/InsightWindow.hpp b/src/Insight/UserInterfaces/InsightWindow/InsightWindow.hpp index dac7f7b7..c7b5b61c 100644 --- a/src/Insight/UserInterfaces/InsightWindow/InsightWindow.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/InsightWindow.hpp @@ -90,7 +90,6 @@ namespace Bloom void onTargetControllerResumed(const Bloom::Targets::TargetDescriptor& targetDescriptor); void onTargetStateUpdate(Targets::TargetState newState); void onTargetProgramCounterUpdate(quint32 programCounter); - void onTargetIoPortsUpdate(); void close(); void openReportIssuesUrl(); void openGettingStartedUrl(); diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/TargetPackageWidget.cpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/TargetPackageWidget.cpp index 1cfce8ec..c7fc87b0 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/TargetPackageWidget.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/TargetPackageWidget.cpp @@ -23,13 +23,9 @@ TargetPackageWidget::TargetPackageWidget( this->connect( &(this->insightWorker), - &InsightWorker::targetIoPortsUpdated, + &InsightWorker::targetRegistersWritten, this, - [this] { - if (this->targetState == TargetState::STOPPED) { - this->refreshPinStates(); - } - } + &TargetPackageWidget::onRegistersWritten ); this->setDisabled(true); @@ -81,3 +77,17 @@ void TargetPackageWidget::onTargetStateChanged(TargetState newState) { }); } } + +void TargetPackageWidget::onRegistersWritten(Targets::TargetRegisters targetRegisters) { + if (this->targetState != TargetState::STOPPED) { + return; + } + + // If a PORT register was just updated, refresh pin states. + for (const auto& targetRegister : targetRegisters) { + if (targetRegister.descriptor.type == Targets::TargetRegisterType::PORT_REGISTER) { + this->refreshPinStates(); + return; + } + } +} diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/TargetPackageWidget.hpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/TargetPackageWidget.hpp index c99f0366..643c5fec 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/TargetPackageWidget.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/TargetPackageWidget.hpp @@ -29,6 +29,7 @@ namespace Bloom::Widgets::InsightTargetWidgets protected slots: virtual void updatePinStates(const Targets::TargetPinStateMappingType& pinStatesByNumber); void onTargetStateChanged(Targets::TargetState newState); + void onRegistersWritten(Targets::TargetRegisters targetRegisters); public: TargetPackageWidget(Targets::TargetVariant targetVariant, InsightWorker& insightWorker, QWidget* parent); diff --git a/src/TargetController/TargetController.cpp b/src/TargetController/TargetController.cpp index 161e6e18..e3354e69 100644 --- a/src/TargetController/TargetController.cpp +++ b/src/TargetController/TargetController.cpp @@ -652,16 +652,6 @@ void TargetController::onWriteMemoryEvent(const Events::WriteMemoryToTarget& eve } } - // TODO: REMOVE THIS - if (this->target->memoryAddressRangeClashesWithIoPortRegisters( - event.memoryType, - event.startAddress, - static_cast(event.startAddress + (event.buffer.size() - 1)) - )) { - // This memory write has affected the target's IO port values - this->eventManager.triggerEvent(std::make_shared()); - } - } catch (const TargetOperationFailure& exception) { Logger::error("Failed to write memory to target - " + exception.getMessage()); this->emitErrorEvent(event.id); diff --git a/src/Targets/Microchip/AVR/AVR8/Avr8.cpp b/src/Targets/Microchip/AVR/AVR8/Avr8.cpp index cc2137ff..18fbf3d4 100644 --- a/src/Targets/Microchip/AVR/AVR8/Avr8.cpp +++ b/src/Targets/Microchip/AVR/AVR8/Avr8.cpp @@ -559,22 +559,3 @@ void Avr8::setPinState(const TargetPinDescriptor& pinDescriptor, const TargetPin } } } - -bool Avr8::memoryAddressRangeClashesWithIoPortRegisters( - TargetMemoryType memoryType, - std::uint32_t startAddress, - std::uint32_t endAddress -) { - auto& targetParameters = this->targetParameters.value(); - if (targetParameters.mappedIoSegmentStartAddress.has_value() && targetParameters.mappedIoSegmentSize.has_value()) { - auto mappedIoSegmentStart = targetParameters.mappedIoSegmentStartAddress.value(); - auto mappedIoSegmentEnd = mappedIoSegmentStart + targetParameters.mappedIoSegmentSize.value(); - - return (startAddress >= mappedIoSegmentStart && startAddress <= mappedIoSegmentEnd) - || (endAddress >= mappedIoSegmentStart && endAddress <= mappedIoSegmentEnd) - || (startAddress <= mappedIoSegmentStart && endAddress >= mappedIoSegmentStart) - ; - } - - return false; -} diff --git a/src/Targets/Microchip/AVR/AVR8/Avr8.hpp b/src/Targets/Microchip/AVR/AVR8/Avr8.hpp index 41c2b704..d503e877 100644 --- a/src/Targets/Microchip/AVR/AVR8/Avr8.hpp +++ b/src/Targets/Microchip/AVR/AVR8/Avr8.hpp @@ -149,11 +149,5 @@ namespace Bloom::Targets::Microchip::Avr::Avr8Bit const TargetPinDescriptor& pinDescriptor, const TargetPinState& state ) override; - - bool memoryAddressRangeClashesWithIoPortRegisters( - TargetMemoryType memoryType, - std::uint32_t startAddress, - std::uint32_t endAddress - ) override; }; } diff --git a/src/Targets/Target.hpp b/src/Targets/Target.hpp index bab07726..eb3fe408 100644 --- a/src/Targets/Target.hpp +++ b/src/Targets/Target.hpp @@ -300,23 +300,6 @@ namespace Bloom::Targets const TargetPinState& state ) = 0; - /** - * Should determine whether writing to a certain memory type and address range will affect the target's pin - * states. This is used by Insight to kick off a pin state update if some other component may have updated the - * pin states via a memory write to IO port register addresses. - * - * @param memoryType - * @param startAddress - * @param endAddress - * - * @return - */ - virtual bool memoryAddressRangeClashesWithIoPortRegisters( - TargetMemoryType memoryType, - std::uint32_t startAddress, - std::uint32_t endAddress - ) = 0; - virtual ~Target() = default; }; }