Made physical interface enum more generic (moved out of AVR8-specific context)
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
|
||||
#include <map>
|
||||
|
||||
#include "src/Targets/Microchip/AVR/AVR8/PhysicalInterface.hpp"
|
||||
#include "src/Targets/TargetPhysicalInterface.hpp"
|
||||
|
||||
namespace DebugToolDrivers::Microchip::Protocols::Edbg::Avr
|
||||
{
|
||||
@@ -103,14 +103,14 @@ namespace DebugToolDrivers::Microchip::Protocols::Edbg::Avr
|
||||
DEBUGGING = 0x02,
|
||||
};
|
||||
|
||||
static inline auto getAvr8PhysicalInterfaceToIdMapping() {
|
||||
using Targets::Microchip::Avr::Avr8Bit::PhysicalInterface;
|
||||
static inline auto getPhysicalInterfaceToAvr8IdMapping() {
|
||||
using Targets::TargetPhysicalInterface;
|
||||
|
||||
return std::map<PhysicalInterface, unsigned char>({
|
||||
{PhysicalInterface::DEBUG_WIRE, 0x05},
|
||||
{PhysicalInterface::PDI, 0x06},
|
||||
{PhysicalInterface::JTAG, 0x04},
|
||||
{PhysicalInterface::UPDI, 0x08},
|
||||
return std::map<TargetPhysicalInterface, unsigned char>({
|
||||
{TargetPhysicalInterface::DEBUG_WIRE, 0x05},
|
||||
{TargetPhysicalInterface::PDI, 0x06},
|
||||
{TargetPhysicalInterface::JTAG, 0x04},
|
||||
{TargetPhysicalInterface::UPDI, 0x08},
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -76,6 +76,7 @@ namespace DebugToolDrivers::Microchip::Protocols::Edbg::Avr
|
||||
using CommandFrames::Avr8Generic::DisableDebugWire;
|
||||
|
||||
using Targets::TargetState;
|
||||
using Targets::TargetPhysicalInterface;
|
||||
using Targets::TargetMemoryType;
|
||||
using Targets::TargetMemoryBuffer;
|
||||
using Targets::TargetMemoryAddress;
|
||||
@@ -135,7 +136,7 @@ namespace DebugToolDrivers::Microchip::Protocols::Edbg::Avr
|
||||
|
||||
this->setParameter(
|
||||
Avr8EdbgParameters::PHYSICAL_INTERFACE,
|
||||
getAvr8PhysicalInterfaceToIdMapping().at(this->targetConfig.physicalInterface)
|
||||
getPhysicalInterfaceToAvr8IdMapping().at(this->targetConfig.physicalInterface)
|
||||
);
|
||||
|
||||
this->setTargetParameters();
|
||||
@@ -227,7 +228,7 @@ namespace DebugToolDrivers::Microchip::Protocols::Edbg::Avr
|
||||
|
||||
} catch (const Avr8CommandFailure& activationException) {
|
||||
if (
|
||||
this->targetConfig.physicalInterface == PhysicalInterface::DEBUG_WIRE
|
||||
this->targetConfig.physicalInterface == TargetPhysicalInterface::DEBUG_WIRE
|
||||
&& (
|
||||
activationException.code == Avr8CommandFailureCode::DEBUGWIRE_PHYSICAL_ERROR
|
||||
|| activationException.code == Avr8CommandFailureCode::FAILED_TO_ENABLE_OCD
|
||||
@@ -252,7 +253,7 @@ namespace DebugToolDrivers::Microchip::Protocols::Edbg::Avr
|
||||
void EdbgAvr8Interface::deactivate() {
|
||||
if (this->targetAttached) {
|
||||
if (
|
||||
this->targetConfig.physicalInterface == PhysicalInterface::DEBUG_WIRE
|
||||
this->targetConfig.physicalInterface == TargetPhysicalInterface::DEBUG_WIRE
|
||||
&& this->targetConfig.disableDebugWireOnDeactivate
|
||||
) {
|
||||
try {
|
||||
@@ -947,54 +948,54 @@ namespace DebugToolDrivers::Microchip::Protocols::Edbg::Avr
|
||||
}
|
||||
}
|
||||
|
||||
std::map<Family, std::map<PhysicalInterface, Avr8ConfigVariant>>
|
||||
std::map<Family, std::map<TargetPhysicalInterface, Avr8ConfigVariant>>
|
||||
EdbgAvr8Interface::getConfigVariantsByFamilyAndPhysicalInterface() {
|
||||
return std::map<Family, std::map<PhysicalInterface, Avr8ConfigVariant>>({
|
||||
return std::map<Family, std::map<TargetPhysicalInterface, Avr8ConfigVariant>>({
|
||||
{
|
||||
Family::MEGA,
|
||||
{
|
||||
{PhysicalInterface::JTAG, Avr8ConfigVariant::MEGAJTAG},
|
||||
{PhysicalInterface::DEBUG_WIRE, Avr8ConfigVariant::DEBUG_WIRE},
|
||||
{PhysicalInterface::UPDI, Avr8ConfigVariant::UPDI},
|
||||
{TargetPhysicalInterface::JTAG, Avr8ConfigVariant::MEGAJTAG},
|
||||
{TargetPhysicalInterface::DEBUG_WIRE, Avr8ConfigVariant::DEBUG_WIRE},
|
||||
{TargetPhysicalInterface::UPDI, Avr8ConfigVariant::UPDI},
|
||||
}
|
||||
},
|
||||
{
|
||||
Family::TINY,
|
||||
{
|
||||
{PhysicalInterface::JTAG, Avr8ConfigVariant::MEGAJTAG},
|
||||
{PhysicalInterface::DEBUG_WIRE, Avr8ConfigVariant::DEBUG_WIRE},
|
||||
{PhysicalInterface::UPDI, Avr8ConfigVariant::UPDI},
|
||||
{TargetPhysicalInterface::JTAG, Avr8ConfigVariant::MEGAJTAG},
|
||||
{TargetPhysicalInterface::DEBUG_WIRE, Avr8ConfigVariant::DEBUG_WIRE},
|
||||
{TargetPhysicalInterface::UPDI, Avr8ConfigVariant::UPDI},
|
||||
}
|
||||
},
|
||||
{
|
||||
Family::XMEGA,
|
||||
{
|
||||
{PhysicalInterface::JTAG, Avr8ConfigVariant::XMEGA},
|
||||
{PhysicalInterface::PDI, Avr8ConfigVariant::XMEGA},
|
||||
{TargetPhysicalInterface::JTAG, Avr8ConfigVariant::XMEGA},
|
||||
{TargetPhysicalInterface::PDI, Avr8ConfigVariant::XMEGA},
|
||||
}
|
||||
},
|
||||
{
|
||||
Family::DA,
|
||||
{
|
||||
{PhysicalInterface::UPDI, Avr8ConfigVariant::UPDI},
|
||||
{TargetPhysicalInterface::UPDI, Avr8ConfigVariant::UPDI},
|
||||
}
|
||||
},
|
||||
{
|
||||
Family::DB,
|
||||
{
|
||||
{PhysicalInterface::UPDI, Avr8ConfigVariant::UPDI},
|
||||
{TargetPhysicalInterface::UPDI, Avr8ConfigVariant::UPDI},
|
||||
}
|
||||
},
|
||||
{
|
||||
Family::DD,
|
||||
{
|
||||
{PhysicalInterface::UPDI, Avr8ConfigVariant::UPDI},
|
||||
{TargetPhysicalInterface::UPDI, Avr8ConfigVariant::UPDI},
|
||||
}
|
||||
},
|
||||
{
|
||||
Family::EA,
|
||||
{
|
||||
{PhysicalInterface::UPDI, Avr8ConfigVariant::UPDI},
|
||||
{TargetPhysicalInterface::UPDI, Avr8ConfigVariant::UPDI},
|
||||
}
|
||||
},
|
||||
});
|
||||
@@ -1002,7 +1003,7 @@ namespace DebugToolDrivers::Microchip::Protocols::Edbg::Avr
|
||||
|
||||
Avr8ConfigVariant EdbgAvr8Interface::resolveConfigVariant(
|
||||
Targets::Microchip::Avr::Avr8Bit::Family targetFamily,
|
||||
Targets::Microchip::Avr::Avr8Bit::PhysicalInterface physicalInterface
|
||||
TargetPhysicalInterface physicalInterface
|
||||
) {
|
||||
const auto configVariantsByFamily = EdbgAvr8Interface::getConfigVariantsByFamilyAndPhysicalInterface();
|
||||
const auto configVariantsByPhysicalInterfaceIt = configVariantsByFamily.find(targetFamily);
|
||||
|
||||
@@ -11,10 +11,10 @@
|
||||
|
||||
#include "Avr8Generic.hpp"
|
||||
|
||||
#include "src/Targets/TargetPhysicalInterface.hpp"
|
||||
#include "src/Targets/TargetMemory.hpp"
|
||||
#include "src/Targets/TargetRegister.hpp"
|
||||
#include "src/Targets/Microchip/AVR/AVR8/Family.hpp"
|
||||
#include "src/Targets/Microchip/AVR/AVR8/PhysicalInterface.hpp"
|
||||
#include "src/Targets/Microchip/AVR/AVR8/TargetParameters.hpp"
|
||||
|
||||
namespace DebugToolDrivers::Microchip::Protocols::Edbg::Avr
|
||||
@@ -384,7 +384,7 @@ namespace DebugToolDrivers::Microchip::Protocols::Edbg::Avr
|
||||
*/
|
||||
static std::map<
|
||||
Targets::Microchip::Avr::Avr8Bit::Family,
|
||||
std::map<Targets::Microchip::Avr::Avr8Bit::PhysicalInterface, Avr8ConfigVariant>
|
||||
std::map<Targets::TargetPhysicalInterface, Avr8ConfigVariant>
|
||||
> getConfigVariantsByFamilyAndPhysicalInterface();
|
||||
|
||||
/**
|
||||
@@ -394,7 +394,7 @@ namespace DebugToolDrivers::Microchip::Protocols::Edbg::Avr
|
||||
*/
|
||||
static Avr8ConfigVariant resolveConfigVariant(
|
||||
Targets::Microchip::Avr::Avr8Bit::Family targetFamily,
|
||||
Targets::Microchip::Avr::Avr8Bit::PhysicalInterface physicalInterface
|
||||
Targets::TargetPhysicalInterface physicalInterface
|
||||
);
|
||||
|
||||
/**
|
||||
|
||||
@@ -7,27 +7,27 @@ namespace DebugToolDrivers::Microchip::Protocols::Edbg::Avr::ResponseFrames::Avr
|
||||
{}
|
||||
|
||||
Targets::Microchip::Avr::TargetSignature GetDeviceId::extractSignature(
|
||||
Targets::Microchip::Avr::Avr8Bit::PhysicalInterface physicalInterface
|
||||
Targets::TargetPhysicalInterface physicalInterface
|
||||
) const {
|
||||
using Targets::Microchip::Avr::Avr8Bit::PhysicalInterface;
|
||||
using Targets::TargetPhysicalInterface;
|
||||
const auto payloadData = this->getPayloadData();
|
||||
|
||||
switch (physicalInterface) {
|
||||
case PhysicalInterface::DEBUG_WIRE: {
|
||||
case TargetPhysicalInterface::DEBUG_WIRE: {
|
||||
/*
|
||||
* When using the DebugWire physical interface, the get device ID command will return
|
||||
* four bytes, where the first can be ignored.
|
||||
*/
|
||||
return Targets::Microchip::Avr::TargetSignature(payloadData[1], payloadData[2], payloadData[3]);
|
||||
}
|
||||
case PhysicalInterface::PDI:
|
||||
case PhysicalInterface::UPDI: {
|
||||
case TargetPhysicalInterface::PDI:
|
||||
case TargetPhysicalInterface::UPDI: {
|
||||
/*
|
||||
* When using the PDI physical interface, the signature is returned in LSB format.
|
||||
*/
|
||||
return Targets::Microchip::Avr::TargetSignature(payloadData[3], payloadData[2], payloadData[1]);
|
||||
}
|
||||
case PhysicalInterface::JTAG: {
|
||||
case TargetPhysicalInterface::JTAG: {
|
||||
/*
|
||||
* When using the JTAG interface, the get device ID command returns a 32 bit JTAG ID. This takes
|
||||
* the following form:
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#include "Avr8GenericResponseFrame.hpp"
|
||||
|
||||
#include "src/Targets/Microchip/AVR/TargetSignature.hpp"
|
||||
#include "src/Targets/Microchip/AVR/AVR8/PhysicalInterface.hpp"
|
||||
#include "src/Targets/TargetPhysicalInterface.hpp"
|
||||
|
||||
namespace DebugToolDrivers::Microchip::Protocols::Edbg::Avr::ResponseFrames::Avr8Generic
|
||||
{
|
||||
@@ -13,7 +13,7 @@ namespace DebugToolDrivers::Microchip::Protocols::Edbg::Avr::ResponseFrames::Avr
|
||||
explicit GetDeviceId(const std::vector<AvrResponse>& AvrResponses);
|
||||
|
||||
Targets::Microchip::Avr::TargetSignature extractSignature(
|
||||
Targets::Microchip::Avr::Avr8Bit::PhysicalInterface physicalInterface
|
||||
Targets::TargetPhysicalInterface physicalInterface
|
||||
) const;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
|
||||
#include "src/Targets/Microchip/AVR/TargetSignature.hpp"
|
||||
#include "src/Targets/Microchip/AVR/AVR8/Family.hpp"
|
||||
#include "src/Targets/Microchip/AVR/AVR8/PhysicalInterface.hpp"
|
||||
#include "src/Targets/Microchip/AVR/AVR8/ProgramMemorySection.hpp"
|
||||
#include "src/Targets/Microchip/AVR/AVR8/TargetParameters.hpp"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user