Implemented programming mode functions in EdbgAvr8Interface implementation

This commit is contained in:
Nav
2022-05-15 17:40:56 +01:00
parent a582a963a8
commit 89e81129fe
4 changed files with 76 additions and 0 deletions

View File

@@ -0,0 +1,22 @@
#pragma once
#include "Avr8GenericCommandFrame.hpp"
namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames::Avr8Generic
{
class EnterProgrammingMode: public Avr8GenericCommandFrame<std::array<unsigned char, 2>>
{
public:
EnterProgrammingMode() {
/*
* The enter programming mode command consists of 2 bytes:
* 1. Command ID (0x15)
* 2. Version (0x00)
*/
this->payload = {
0x15,
0x00
};
}
};
}

View File

@@ -0,0 +1,22 @@
#pragma once
#include "Avr8GenericCommandFrame.hpp"
namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames::Avr8Generic
{
class LeaveProgrammingMode: public Avr8GenericCommandFrame<std::array<unsigned char, 2>>
{
public:
LeaveProgrammingMode() {
/*
* The leave programming mode command consists of 2 bytes:
* 1. Command ID (0x16)
* 2. Version (0x00)
*/
this->payload = {
0x16,
0x00
};
}
};
}

View File

@@ -34,6 +34,8 @@
#include "src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/SetXmegaSoftwareBreakpoint.hpp"
#include "src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/ClearAllSoftwareBreakpoints.hpp"
#include "src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/ClearSoftwareBreakpoints.hpp"
#include "src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/EnterProgrammingMode.hpp"
#include "src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/LeaveProgrammingMode.hpp"
// AVR events
#include "src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/Events/AVR8Generic/BreakEvent.hpp"
@@ -676,6 +678,26 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
return this->targetState;
}
void EdbgAvr8Interface::enableProgrammingMode() {
auto response = this->edbgInterface.sendAvrCommandFrameAndWaitForResponseFrame(
CommandFrames::Avr8Generic::EnterProgrammingMode()
);
if (response.getResponseId() == Avr8ResponseId::FAILED) {
throw Avr8CommandFailure("Failed to enter programming mode on EDBG debug tool", response);
}
}
void EdbgAvr8Interface::disableProgrammingMode() {
auto response = this->edbgInterface.sendAvrCommandFrameAndWaitForResponseFrame(
CommandFrames::Avr8Generic::LeaveProgrammingMode()
);
if (response.getResponseId() == Avr8ResponseId::FAILED) {
throw Avr8CommandFailure("Failed to leave programming mode on EDBG debug tool", response);
}
}
void EdbgAvr8Interface::setParameter(const Avr8EdbgParameter& parameter, const std::vector<unsigned char>& value) {
auto commandFrame = CommandFrames::Avr8Generic::SetParameter(parameter, value);

View File

@@ -250,6 +250,16 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
*/
Targets::TargetState getTargetState() override;
/**
* Enters programming mode on the EDBG debug tool.
*/
void enableProgrammingMode() override;
/**
* Leaves programming mode on the EDBG debug tool.
*/
void disableProgrammingMode() override;
private:
/**
* The AVR8 Generic protocol is a sub-protocol of the EDBG AVR protocol, which is served via CMSIS-DAP vendor