Replaced TargetIoPortsUpdated event with RegistersWrittenToTarget event
This commit is contained in:
@@ -51,7 +51,6 @@ namespace Bloom::Events
|
|||||||
RETRIEVE_TARGET_PIN_STATES,
|
RETRIEVE_TARGET_PIN_STATES,
|
||||||
TARGET_PIN_STATES_RETRIEVED,
|
TARGET_PIN_STATES_RETRIEVED,
|
||||||
SET_TARGET_PIN_STATE,
|
SET_TARGET_PIN_STATE,
|
||||||
TARGET_IO_PORTS_UPDATED,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class Event
|
class Event
|
||||||
|
|||||||
@@ -39,7 +39,6 @@
|
|||||||
#include "RetrieveTargetPinStates.hpp"
|
#include "RetrieveTargetPinStates.hpp"
|
||||||
#include "TargetPinStatesRetrieved.hpp"
|
#include "TargetPinStatesRetrieved.hpp"
|
||||||
#include "SetTargetPinState.hpp"
|
#include "SetTargetPinState.hpp"
|
||||||
#include "TargetIoPortsUpdated.hpp"
|
|
||||||
|
|
||||||
namespace Bloom::Events
|
namespace Bloom::Events
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,23 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
#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;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
@@ -75,7 +75,6 @@ void Insight::startup() {
|
|||||||
this->connect(this->insightWorker, &InsightWorker::targetControllerResumed, this->mainWindow, &InsightWindow::onTargetControllerResumed);
|
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::targetStateUpdated, this->mainWindow, &InsightWindow::onTargetStateUpdate);
|
||||||
this->connect(this->insightWorker, &InsightWorker::targetProgramCounterUpdated, this->mainWindow, &InsightWindow::onTargetProgramCounterUpdate);
|
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->connect(this->mainWindow, &InsightWindow::refreshTargetPinStates, this->insightWorker, &InsightWorker::requestPinStates);
|
||||||
|
|
||||||
this->mainWindow->setInsightConfig(this->insightConfig);
|
this->mainWindow->setInsightConfig(this->insightConfig);
|
||||||
|
|||||||
@@ -28,10 +28,6 @@ void InsightWorker::startup() {
|
|||||||
std::bind(&InsightWorker::onTargetResumedEvent, this, std::placeholders::_1)
|
std::bind(&InsightWorker::onTargetResumedEvent, this, std::placeholders::_1)
|
||||||
);
|
);
|
||||||
|
|
||||||
this->eventListener->registerCallbackForEventType<Events::TargetIoPortsUpdated>(
|
|
||||||
std::bind(&InsightWorker::onTargetIoPortsUpdatedEvent, this, std::placeholders::_1)
|
|
||||||
);
|
|
||||||
|
|
||||||
this->eventListener->registerCallbackForEventType<Events::RegistersWrittenToTarget>(
|
this->eventListener->registerCallbackForEventType<Events::RegistersWrittenToTarget>(
|
||||||
std::bind(&InsightWorker::onTargetRegistersWrittenEvent, this, std::placeholders::_1)
|
std::bind(&InsightWorker::onTargetRegistersWrittenEvent, this, std::placeholders::_1)
|
||||||
);
|
);
|
||||||
@@ -117,10 +113,6 @@ void InsightWorker::onTargetResumedEvent(const Events::TargetExecutionResumed& e
|
|||||||
emit this->targetStateUpdated(TargetState::RUNNING);
|
emit this->targetStateUpdated(TargetState::RUNNING);
|
||||||
}
|
}
|
||||||
|
|
||||||
void InsightWorker::onTargetIoPortsUpdatedEvent(const Events::TargetIoPortsUpdated& event) {
|
|
||||||
emit this->targetIoPortsUpdated();
|
|
||||||
}
|
|
||||||
|
|
||||||
void InsightWorker::onTargetRegistersWrittenEvent(const Events::RegistersWrittenToTarget& event) {
|
void InsightWorker::onTargetRegistersWrittenEvent(const Events::RegistersWrittenToTarget& event) {
|
||||||
emit this->targetRegistersWritten(event.registers);
|
emit this->targetRegistersWritten(event.registers);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,7 +39,6 @@ namespace Bloom
|
|||||||
|
|
||||||
void onTargetStoppedEvent(const Events::TargetExecutionStopped& event);
|
void onTargetStoppedEvent(const Events::TargetExecutionStopped& event);
|
||||||
void onTargetResumedEvent(const Events::TargetExecutionResumed& event);
|
void onTargetResumedEvent(const Events::TargetExecutionResumed& event);
|
||||||
void onTargetIoPortsUpdatedEvent(const Events::TargetIoPortsUpdated& event);
|
|
||||||
void onTargetRegistersWrittenEvent(const Events::RegistersWrittenToTarget& event);
|
void onTargetRegistersWrittenEvent(const Events::RegistersWrittenToTarget& event);
|
||||||
void onTargetControllerStateReportedEvent(const Events::TargetControllerStateReported& event);
|
void onTargetControllerStateReportedEvent(const Events::TargetControllerStateReported& event);
|
||||||
|
|
||||||
@@ -63,7 +62,6 @@ namespace Bloom
|
|||||||
void taskQueued();
|
void taskQueued();
|
||||||
void targetStateUpdated(Bloom::Targets::TargetState newState);
|
void targetStateUpdated(Bloom::Targets::TargetState newState);
|
||||||
void targetProgramCounterUpdated(quint32 programCounter);
|
void targetProgramCounterUpdated(quint32 programCounter);
|
||||||
void targetIoPortsUpdated();
|
|
||||||
void targetControllerSuspended();
|
void targetControllerSuspended();
|
||||||
void targetControllerResumed(const Bloom::Targets::TargetDescriptor& targetDescriptor);
|
void targetControllerResumed(const Bloom::Targets::TargetDescriptor& targetDescriptor);
|
||||||
void targetRegistersWritten(const Bloom::Targets::TargetRegisters& targetRegisters);
|
void targetRegistersWritten(const Bloom::Targets::TargetRegisters& targetRegisters);
|
||||||
|
|||||||
@@ -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() {
|
void InsightWindow::toggleTargetRegistersPane() {
|
||||||
if (this->targetRegistersSidePane->activated) {
|
if (this->targetRegistersSidePane->activated) {
|
||||||
this->targetRegistersSidePane->deactivate();
|
this->targetRegistersSidePane->deactivate();
|
||||||
|
|||||||
@@ -90,7 +90,6 @@ namespace Bloom
|
|||||||
void onTargetControllerResumed(const Bloom::Targets::TargetDescriptor& targetDescriptor);
|
void onTargetControllerResumed(const Bloom::Targets::TargetDescriptor& targetDescriptor);
|
||||||
void onTargetStateUpdate(Targets::TargetState newState);
|
void onTargetStateUpdate(Targets::TargetState newState);
|
||||||
void onTargetProgramCounterUpdate(quint32 programCounter);
|
void onTargetProgramCounterUpdate(quint32 programCounter);
|
||||||
void onTargetIoPortsUpdate();
|
|
||||||
void close();
|
void close();
|
||||||
void openReportIssuesUrl();
|
void openReportIssuesUrl();
|
||||||
void openGettingStartedUrl();
|
void openGettingStartedUrl();
|
||||||
|
|||||||
@@ -23,13 +23,9 @@ TargetPackageWidget::TargetPackageWidget(
|
|||||||
|
|
||||||
this->connect(
|
this->connect(
|
||||||
&(this->insightWorker),
|
&(this->insightWorker),
|
||||||
&InsightWorker::targetIoPortsUpdated,
|
&InsightWorker::targetRegistersWritten,
|
||||||
this,
|
this,
|
||||||
[this] {
|
&TargetPackageWidget::onRegistersWritten
|
||||||
if (this->targetState == TargetState::STOPPED) {
|
|
||||||
this->refreshPinStates();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
);
|
||||||
|
|
||||||
this->setDisabled(true);
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ namespace Bloom::Widgets::InsightTargetWidgets
|
|||||||
protected slots:
|
protected slots:
|
||||||
virtual void updatePinStates(const Targets::TargetPinStateMappingType& pinStatesByNumber);
|
virtual void updatePinStates(const Targets::TargetPinStateMappingType& pinStatesByNumber);
|
||||||
void onTargetStateChanged(Targets::TargetState newState);
|
void onTargetStateChanged(Targets::TargetState newState);
|
||||||
|
void onRegistersWritten(Targets::TargetRegisters targetRegisters);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
TargetPackageWidget(Targets::TargetVariant targetVariant, InsightWorker& insightWorker, QWidget* parent);
|
TargetPackageWidget(Targets::TargetVariant targetVariant, InsightWorker& insightWorker, QWidget* parent);
|
||||||
|
|||||||
@@ -652,16 +652,6 @@ void TargetController::onWriteMemoryEvent(const Events::WriteMemoryToTarget& eve
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: REMOVE THIS
|
|
||||||
if (this->target->memoryAddressRangeClashesWithIoPortRegisters(
|
|
||||||
event.memoryType,
|
|
||||||
event.startAddress,
|
|
||||||
static_cast<std::uint32_t>(event.startAddress + (event.buffer.size() - 1))
|
|
||||||
)) {
|
|
||||||
// This memory write has affected the target's IO port values
|
|
||||||
this->eventManager.triggerEvent(std::make_shared<Events::TargetIoPortsUpdated>());
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (const TargetOperationFailure& exception) {
|
} catch (const TargetOperationFailure& exception) {
|
||||||
Logger::error("Failed to write memory to target - " + exception.getMessage());
|
Logger::error("Failed to write memory to target - " + exception.getMessage());
|
||||||
this->emitErrorEvent(event.id);
|
this->emitErrorEvent(event.id);
|
||||||
|
|||||||
@@ -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;
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -149,11 +149,5 @@ namespace Bloom::Targets::Microchip::Avr::Avr8Bit
|
|||||||
const TargetPinDescriptor& pinDescriptor,
|
const TargetPinDescriptor& pinDescriptor,
|
||||||
const TargetPinState& state
|
const TargetPinState& state
|
||||||
) override;
|
) override;
|
||||||
|
|
||||||
bool memoryAddressRangeClashesWithIoPortRegisters(
|
|
||||||
TargetMemoryType memoryType,
|
|
||||||
std::uint32_t startAddress,
|
|
||||||
std::uint32_t endAddress
|
|
||||||
) override;
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -300,23 +300,6 @@ namespace Bloom::Targets
|
|||||||
const TargetPinState& state
|
const TargetPinState& state
|
||||||
) = 0;
|
) = 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;
|
virtual ~Target() = default;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user