Implemented eraseMemory() member function in AVR8 class

This commit is contained in:
Nav
2022-12-11 18:18:39 +00:00
parent 190d734ca3
commit 83c273a22b
3 changed files with 36 additions and 1 deletions

View File

@@ -374,6 +374,29 @@ namespace Bloom::Targets::Microchip::Avr::Avr8Bit
this->avr8DebugInterface->writeMemory(memoryType, startAddress, buffer); this->avr8DebugInterface->writeMemory(memoryType, startAddress, buffer);
} }
void Avr8::eraseMemory(TargetMemoryType memoryType) {
if (memoryType == TargetMemoryType::FLASH) {
return this->avr8DebugInterface->eraseProgramMemory();
}
/*
* Debug tools do not have to support the erasing of RAM or EEPROM memory. We just implement this as a
* write operation.
*/
this->writeMemory(
memoryType,
memoryType == TargetMemoryType::RAM
? this->targetParameters->ramStartAddress.value()
: this->targetParameters->eepromStartAddress.value(),
TargetMemoryBuffer(
memoryType == TargetMemoryType::RAM
? this->targetParameters->ramSize.value()
: this->targetParameters->eepromSize.value(),
0xFF
)
);
}
TargetState Avr8::getState() { TargetState Avr8::getState() {
return this->avr8DebugInterface->getTargetState(); return this->avr8DebugInterface->getTargetState();
} }

View File

@@ -111,6 +111,7 @@ namespace Bloom::Targets::Microchip::Avr::Avr8Bit
TargetMemoryAddress startAddress, TargetMemoryAddress startAddress,
const TargetMemoryBuffer& buffer const TargetMemoryBuffer& buffer
) override; ) override;
void eraseMemory(TargetMemoryType memoryType) override;
TargetState getState() override; TargetState getState() override;

View File

@@ -258,7 +258,18 @@ namespace Bloom::Targets
* @param startAddress * @param startAddress
* @param buffer * @param buffer
*/ */
virtual void writeMemory(TargetMemoryType memoryType, TargetMemoryAddress startAddress, const TargetMemoryBuffer& buffer) = 0; virtual void writeMemory(
TargetMemoryType memoryType,
TargetMemoryAddress startAddress,
const TargetMemoryBuffer& buffer
) = 0;
/**
* Should erase the entire address range of a given memory type.
*
* @param memoryType
*/
virtual void eraseMemory(TargetMemoryType memoryType) = 0;
/** /**
* Should return the current state of the target. * Should return the current state of the target.