Tidying EDBG driver code:

- Binned a lot of pointless code
- Simplified many EDBG data structure implementations
- Const-correctness
- Many other bits of tidying
This commit is contained in:
Nav
2022-10-01 20:42:37 +01:00
parent a5b0097036
commit 2c6fd25ae4
91 changed files with 591 additions and 689 deletions

View File

@@ -50,9 +50,10 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap
*/
using ExpectedResponseType = Response;
explicit Command(unsigned char commandId): commandId(commandId) {};
unsigned char commandId;
std::vector<unsigned char> data;
Command() = default;
explicit Command(unsigned char commandId);
virtual ~Command() = default;
Command(const Command& other) = default;
@@ -61,29 +62,13 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap
Command& operator = (const Command& other) = default;
Command& operator = (Command&& other) = default;
[[nodiscard]] unsigned char getCommandId() const {
return this->commandId;
}
void setCommandId(unsigned char commandId) {
this->commandId = commandId;
}
[[nodiscard]] virtual std::vector<unsigned char> getData() const {
return this->data;
}
void setData(const std::vector<unsigned char>& data) {
this->data = data;
}
[[nodiscard]] int getCommandSize() const {
// +1 for the command ID
return static_cast<int>(1 + this->getData().size());
return static_cast<int>(1 + this->data.size());
}
[[nodiscard]] std::uint16_t getDataSize() const {
return static_cast<std::uint16_t>(this->getData().size());
return static_cast<std::uint16_t>(this->data.size());
}
/**
@@ -93,9 +78,5 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap
* @return
*/
explicit virtual operator std::vector<unsigned char>() const;
private:
unsigned char commandId = 0x00;
std::vector<unsigned char> data;
};
}