Moved EDBG protocol code to more appropriate directory.

Updated necessary namespaces.
Other bits of tidying.
This commit is contained in:
Nav
2023-11-17 22:20:39 +00:00
parent 3ec365290e
commit 55d3fe76e0
89 changed files with 223 additions and 223 deletions

View File

@@ -0,0 +1,27 @@
#include "AvrCommand.hpp"
namespace DebugToolDrivers::Microchip::Protocols::Edbg::Avr
{
AvrCommand::AvrCommand(
std::size_t fragmentCount,
std::size_t fragmentNumber,
const std::vector<unsigned char>& commandPacket
)
: Command(0x80)
{
const auto commandPacketSize = commandPacket.size();
this->data.reserve(commandPacketSize + 3);
// FragmentInfo byte
this->data.emplace_back(static_cast<unsigned char>((fragmentNumber << 4) | fragmentCount));
// Size byte
this->data.emplace_back(static_cast<unsigned char>(commandPacketSize >> 8));
this->data.emplace_back(static_cast<unsigned char>(commandPacketSize & 0xFF));
if (commandPacketSize > 0) {
// Packet data
this->data.insert(this->data.begin() + 3, commandPacket.begin(), commandPacket.end());
}
}
}