Added config struct for RISC-V debug translator implementation, and WCH debug tools.
Also some tidying in the `DebugToolConfig` struct
This commit is contained in:
@@ -11,12 +11,14 @@ namespace DebugToolDrivers::Wch
|
||||
using Exceptions::DeviceInitializationFailure;
|
||||
|
||||
WchLinkBase::WchLinkBase(
|
||||
const DebugToolConfig& toolConfig,
|
||||
WchLinkVariant variant,
|
||||
std::uint16_t vendorId,
|
||||
std::uint16_t productId,
|
||||
std::uint8_t wchLinkUsbInterfaceNumber
|
||||
)
|
||||
: UsbDevice(vendorId, productId)
|
||||
, toolConfig(WchLinkToolConfig{toolConfig})
|
||||
, variant(variant)
|
||||
, wchLinkUsbInterfaceNumber(wchLinkUsbInterfaceNumber)
|
||||
{}
|
||||
@@ -77,6 +79,7 @@ namespace DebugToolDrivers::Wch
|
||||
if (!this->wchRiscVTranslator) {
|
||||
this->wchRiscVTranslator = std::make_unique<DebugTranslator>(
|
||||
*(this->wchLinkInterface.get()),
|
||||
this->toolConfig.riscVDebugTranslatorConfig,
|
||||
targetDescriptionFile,
|
||||
targetConfig
|
||||
);
|
||||
|
||||
@@ -8,6 +8,9 @@
|
||||
#include "src/DebugToolDrivers/USB/UsbDevice.hpp"
|
||||
#include "src/DebugToolDrivers/USB/UsbInterface.hpp"
|
||||
|
||||
#include "WchLinkToolConfig.hpp"
|
||||
#include "src/ProjectConfig.hpp"
|
||||
|
||||
#include "Protocols/WchLink/WchLinkInterface.hpp"
|
||||
#include "src/DebugToolDrivers/Protocols/RiscVDebugSpec/DebugTranslator.hpp"
|
||||
|
||||
@@ -20,6 +23,7 @@ namespace DebugToolDrivers::Wch
|
||||
{
|
||||
public:
|
||||
WchLinkBase(
|
||||
const DebugToolConfig& toolConfig,
|
||||
WchLinkVariant variant,
|
||||
std::uint16_t vendorId,
|
||||
std::uint16_t productId,
|
||||
@@ -64,6 +68,7 @@ namespace DebugToolDrivers::Wch
|
||||
) override;
|
||||
|
||||
protected:
|
||||
WchLinkToolConfig toolConfig;
|
||||
bool initialised = false;
|
||||
|
||||
WchLinkVariant variant;
|
||||
|
||||
@@ -2,8 +2,9 @@
|
||||
|
||||
namespace DebugToolDrivers::Wch
|
||||
{
|
||||
WchLinkE::WchLinkE()
|
||||
WchLinkE::WchLinkE(const DebugToolConfig& toolConfig)
|
||||
: WchLinkBase(
|
||||
toolConfig,
|
||||
WchLinkVariant::LINK_E_CH32V307,
|
||||
WchLinkE::USB_VENDOR_ID,
|
||||
WchLinkE::USB_PRODUCT_ID,
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
|
||||
#include "src/DebugToolDrivers/WCH/WchLinkBase.hpp"
|
||||
|
||||
#include "src/ProjectConfig.hpp"
|
||||
|
||||
namespace DebugToolDrivers::Wch
|
||||
{
|
||||
/**
|
||||
@@ -21,7 +23,7 @@ namespace DebugToolDrivers::Wch
|
||||
static const inline std::uint16_t USB_PRODUCT_ID = 0x8010;
|
||||
static const inline std::uint8_t WCH_LINK_INTERFACE_NUMBER = 0;
|
||||
|
||||
WchLinkE();
|
||||
WchLinkE(const DebugToolConfig& toolConfig);
|
||||
|
||||
std::string getName() override {
|
||||
return "WCH-LinkE";
|
||||
|
||||
16
src/DebugToolDrivers/WCH/WchLinkToolConfig.cpp
Normal file
16
src/DebugToolDrivers/WCH/WchLinkToolConfig.cpp
Normal file
@@ -0,0 +1,16 @@
|
||||
#include "WchLinkToolConfig.hpp"
|
||||
|
||||
namespace DebugToolDrivers::Wch
|
||||
{
|
||||
WchLinkToolConfig::WchLinkToolConfig(const DebugToolConfig& toolConfig)
|
||||
: DebugToolConfig(toolConfig)
|
||||
{
|
||||
const auto& toolNode = toolConfig.toolNode;
|
||||
|
||||
if (toolNode["riscVDebugTranslator"]) {
|
||||
this->riscVDebugTranslatorConfig = Protocols::RiscVDebugSpec::DebugTranslatorConfig{
|
||||
toolNode["riscVDebugTranslator"]
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
20
src/DebugToolDrivers/WCH/WchLinkToolConfig.hpp
Normal file
20
src/DebugToolDrivers/WCH/WchLinkToolConfig.hpp
Normal file
@@ -0,0 +1,20 @@
|
||||
#pragma once
|
||||
|
||||
#include <yaml-cpp/yaml.h>
|
||||
|
||||
#include "src/ProjectConfig.hpp"
|
||||
#include "src/DebugToolDrivers/Protocols/RiscVDebugSpec/DebugTranslatorConfig.hpp"
|
||||
|
||||
namespace DebugToolDrivers::Wch
|
||||
{
|
||||
/**
|
||||
* Extending the generic DebugToolConfig struct to accommodate WCH-Link configuration parameters.
|
||||
*/
|
||||
struct WchLinkToolConfig: public DebugToolConfig
|
||||
{
|
||||
public:
|
||||
Protocols::RiscVDebugSpec::DebugTranslatorConfig riscVDebugTranslatorConfig = {};
|
||||
|
||||
explicit WchLinkToolConfig(const DebugToolConfig& toolConfig);
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user