From 9e223f9f9ff26a90d6a590256c8dda921c761fb9 Mon Sep 17 00:00:00 2001 From: Nav Date: Tue, 21 Nov 2023 22:04:27 +0000 Subject: [PATCH] Updated `DebugTool` interface and implemented `getRiscVDebugInterface()` for WCH-Link debug tools --- src/DebugToolDrivers/DebugTool.hpp | 20 ++++++++++++++++++-- src/DebugToolDrivers/WCH/WchLinkBase.hpp | 4 ++++ 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/DebugToolDrivers/DebugTool.hpp b/src/DebugToolDrivers/DebugTool.hpp index cc3c0dd9..221f7c39 100644 --- a/src/DebugToolDrivers/DebugTool.hpp +++ b/src/DebugToolDrivers/DebugTool.hpp @@ -3,12 +3,14 @@ #include "TargetInterfaces/TargetPowerManagementInterface.hpp" #include "TargetInterfaces/Microchip/AVR/AVR8/Avr8DebugInterface.hpp" +#include "TargetInterfaces/Microchip/AVR/AvrIspInterface.hpp" #include "src/Targets/Microchip/AVR/AVR8/Avr8TargetConfig.hpp" #include "src/Targets/Microchip/AVR/AVR8/Family.hpp" #include "src/Targets/Microchip/AVR/AVR8/TargetParameters.hpp" -#include "src/Targets/TargetRegister.hpp" -#include "TargetInterfaces/Microchip/AVR/AvrIspInterface.hpp" +#include "TargetInterfaces/RiscV/RiscVDebugInterface.hpp" + +#include "src/Targets/TargetRegister.hpp" /** * A debug tool can be any device that provides access to the connected target. Debug tools are usually connected @@ -97,6 +99,20 @@ public: return nullptr; } + /** + * All debug tools that support interfacing with RISC-V targets must provide an implementation of the + * RiscVDebugInterface class, via this function. + * + * For debug tools that do not support this interface, a nullptr should be returned. + * + * Note: the caller of this function will not manage the lifetime of the returned instance. + * + * @return + */ + virtual DebugToolDrivers::TargetInterfaces::RiscV::RiscVDebugInterface* getRiscVDebugInterface() { + return nullptr; + } + [[nodiscard]] bool isInitialised() const { return this->initialised; } diff --git a/src/DebugToolDrivers/WCH/WchLinkBase.hpp b/src/DebugToolDrivers/WCH/WchLinkBase.hpp index 472c7621..c0d280b8 100644 --- a/src/DebugToolDrivers/WCH/WchLinkBase.hpp +++ b/src/DebugToolDrivers/WCH/WchLinkBase.hpp @@ -32,6 +32,10 @@ namespace DebugToolDrivers::Wch std::string getFirmwareVersionString() override; + DebugToolDrivers::TargetInterfaces::RiscV::RiscVDebugInterface* getRiscVDebugInterface() override { + return this->wchLinkInterface.get(); + } + protected: WchLinkVariant variant;