Files
BloomPatched/src/DebugToolDrivers/Microchip/Protocols/EDBG/AVR/AvrCommand.cpp
Nav 55d3fe76e0 Moved EDBG protocol code to more appropriate directory.
Updated necessary namespaces.
Other bits of tidying.
2023-11-17 22:20:39 +00:00

28 lines
898 B
C++

#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());
}
}
}