Skip to content

Commit

Permalink
feat: refactor and expand StUartProgrammer (#202)
Browse files Browse the repository at this point in the history
* Create StUartBootloaderCommandHandler

* Rename ReceiveRegularBufferAction to ReceiveBufferAction

* StUartBootloaderCommandHandler some refactoring

* Update services/st_util/CMakeLists.txt

* Update services/st_util/StUartBootloaderCommandHandler.cpp

* Apply suggestions from code review

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Resolve PR comments.

* Resolve PR comments.

* Resolve PR comments

* Process PR comments

* add ack to end of special command

* Process review comments

* Add ReceivePredefinedBuffer Action

* Process PR comments

* Process PR comments

* Update services/st_util/test/TestStUartBootloaderCommandHandler.cpp

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Process PR comments

* chore: rename to StBootloaderCommandHandlerUart

* chore: StBootloaderCommandHandlerUartTest ExpectReceiveData -> ReceiveData

* test: StBootloaderCommandHandlerUart extend test coverage

* chore: StBootloaderCommandHandler -> StBootloaderCommunicator

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
  • Loading branch information
EkelmansPh and github-actions[bot] authored Nov 6, 2023
1 parent 0069e53 commit 5c8c213
Show file tree
Hide file tree
Showing 6 changed files with 1,458 additions and 0 deletions.
7 changes: 7 additions & 0 deletions services/st_util/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,16 @@ target_sources(services.st_util PRIVATE
FlashOnStUartProgrammer.hpp
StUartProgrammer.cpp
StUartProgrammer.hpp
StBootloaderCommunicator.hpp
StBootloaderCommunicatorUart.cpp
StBootloaderCommunicatorUart.hpp
)

target_link_libraries(services.st_util PUBLIC
hal.interfaces
services.util
)

if (EMIL_BUILD_TESTS)
add_subdirectory(test)
endif()
40 changes: 40 additions & 0 deletions services/st_util/StBootloaderCommunicator.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#ifndef SERVICES_ST_UTIL_ST_BOOTLOADER_COMMAND_HANDLER_HPP
#define SERVICES_ST_UTIL_ST_BOOTLOADER_COMMAND_HANDLER_HPP

#include "infra/util//Function.hpp"
#include "infra/util/ByteRange.hpp"

namespace services
{
enum class MassEraseSubcommand
{
global = 0xffff,
bankOne = 0xfffE,
bankTwo = 0xfffD,
};

class StBootloaderCommunicator
{
protected:
StBootloaderCommunicator() = default;
StBootloaderCommunicator(const StBootloaderCommunicator& other) = delete;
StBootloaderCommunicator& operator=(const StBootloaderCommunicator& other) = delete;
~StBootloaderCommunicator() = default;

public:
virtual void GetCommand(infra::ByteRange& commands, const infra::Function<void(uint8_t major, uint8_t minor)>& onDone) = 0;
virtual void GetVersion(const infra::Function<void(uint8_t major, uint8_t minor)>& onDone) = 0;
virtual void GetId(const infra::Function<void(uint16_t id)>& onDone) = 0;
virtual void ReadMemory(uint32_t address, infra::ByteRange& data, const infra::Function<void()>& onDone) = 0;
virtual void Go(uint32_t address, const infra::Function<void()>& onDone) = 0;
virtual void WriteMemory(uint32_t address, infra::ConstByteRange data, const infra::Function<void()>& onDone) = 0;
virtual void MassErase(const infra::Function<void()>& onDone) = 0;
virtual void Erase(infra::ConstByteRange pages, const infra::Function<void()>& onDone) = 0;
virtual void ExtendedMassErase(MassEraseSubcommand subcommand, const infra::Function<void()>& onDone) = 0;
virtual void ExtendedErase(infra::ConstByteRange pages, const infra::Function<void()>& onDone) = 0;
virtual void Special(uint16_t subcommand, infra::ConstByteRange txData, infra::ByteRange& rxData, infra::ByteRange& rxStatus, const infra::Function<void()>& onDone) = 0;
virtual void ExtendedSpecial(uint16_t subcommand, infra::ConstByteRange txData1, infra::ConstByteRange txData2, infra::ByteRange& rxData, const infra::Function<void()>& onDone) = 0;
};
}

#endif
Loading

0 comments on commit 5c8c213

Please sign in to comment.