diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/ResponseFrames/EDBGControl/EdbgControlResponseFrame.cpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/ResponseFrames/EDBGControl/EdbgControlResponseFrame.cpp new file mode 100644 index 00000000..740d13c1 --- /dev/null +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/ResponseFrames/EDBGControl/EdbgControlResponseFrame.cpp @@ -0,0 +1,32 @@ +#include "EdbgControlResponseFrame.hpp" + +#include "src/Exceptions/Exception.hpp" + +namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::ResponseFrames::EdbgControl +{ + using namespace Bloom::Exceptions; + + EdbgControlResponseId EdbgControlResponseFrame::getResponseId() { + const auto& payload = this->getPayload(); + if (payload.empty()) { + throw Exception("Response ID missing from EDBG Control response frame payload."); + } + + return static_cast(payload[0]); + } + + std::vector EdbgControlResponseFrame::getPayloadData() { + const auto& payload = this->getPayload(); + + /* + * EDBG Control data payloads include two bytes before the data (response ID and version byte) as well as an + * additional byte after the data, known as the 'status code'. + */ + auto data = std::vector( + payload.begin() + 2, + payload.end() - 1 + ); + + return data; + } +} diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/ResponseFrames/EDBGControl/EdbgControlResponseFrame.hpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/ResponseFrames/EDBGControl/EdbgControlResponseFrame.hpp new file mode 100644 index 00000000..be4d94e5 --- /dev/null +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/ResponseFrames/EDBGControl/EdbgControlResponseFrame.hpp @@ -0,0 +1,25 @@ +#pragma once + +#include "src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/ResponseFrames/AvrResponseFrame.hpp" + +namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::ResponseFrames::EdbgControl +{ + enum class EdbgControlResponseId: unsigned char + { + OK = 0x80, + DATA = 0x84, + FAILED = 0xA0, + }; + + class EdbgControlResponseFrame: public AvrResponseFrame + { + public: + EdbgControlResponseFrame() = default; + explicit EdbgControlResponseFrame(const std::vector& avrResponses) + : AvrResponseFrame(avrResponses) {} + + [[nodiscard]] EdbgControlResponseId getResponseId(); + + [[nodiscard]] std::vector getPayloadData() override; + }; +}