Some tidying and more TDF corrections

This commit is contained in:
Nav
2021-06-11 23:59:17 +01:00
parent 01ce8dd5a4
commit a550d2c3a1
9 changed files with 90 additions and 31 deletions

View File

@@ -22,13 +22,13 @@ void AtmelIce::init() {
usbHidInterface.init();
}
/**
/*
* The Atmel-ICE EDBG/CMSIS-DAP interface doesn't operate properly when sending commands too quickly.
*
* Because of this, we have to enforce a minimum time gap between commands. See comment
* in CmsisDapInterface class declaration for more info.
*/
this->getEdbgInterface().setMinimumCommandTimeGap(35);
this->getEdbgInterface().setMinimumCommandTimeGap(std::chrono::milliseconds(35));
// We don't need to claim the CMSISDAP interface here as the HIDAPI will have already done so.
if (!this->sessionStarted) {

View File

@@ -20,7 +20,7 @@ void MplabSnap::init() {
usbHidInterface.init();
}
this->getEdbgInterface().setMinimumCommandTimeGap(35);
this->getEdbgInterface().setMinimumCommandTimeGap(std::chrono::milliseconds(35));
// We don't need to claim the CMSISDAP interface here as the HIDAPI will have already done so.
if (!this->sessionStarted) {

View File

@@ -22,13 +22,13 @@ void PowerDebugger::init() {
usbHidInterface.init();
}
/**
/*
* The Power Debugger EDBG/CMSIS-DAP interface doesn't operate properly when sending commands too quickly.
*
* Because of this, we have to enforce a minimum time gap between commands. See comment in
* CmsisDapInterface class declaration for more info.
*/
this->getEdbgInterface().setMinimumCommandTimeGap(35);
this->getEdbgInterface().setMinimumCommandTimeGap(std::chrono::milliseconds(35));
// We don't need to claim the CMSISDAP interface here as the HIDAPI will have already done so.
if (!this->sessionStarted) {

View File

@@ -11,13 +11,13 @@ using namespace Bloom::DebugToolDrivers::Protocols::CmsisDap;
using namespace Bloom::Exceptions;
void CmsisDapInterface::sendCommand(const Command& cmsisDapCommand) {
if (this->msSendCommandDelay > 0) {
if (this->msSendCommandDelay.count() > 0) {
using namespace std::chrono;
long now = duration_cast<milliseconds>(high_resolution_clock::now().time_since_epoch()).count();
long difference = (now - this->lastCommandSentTimeStamp);
if (difference < this->msSendCommandDelay) {
std::this_thread::sleep_for(milliseconds(this->msSendCommandDelay - difference));
if (difference < this->msSendCommandDelay.count()) {
std::this_thread::sleep_for(milliseconds(this->msSendCommandDelay.count() - difference));
}
this->lastCommandSentTimeStamp = now;

View File

@@ -35,8 +35,8 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap
* Setting msSendCommandDelay to any value above 0 will enforce an x millisecond gap between each command
* being sent, where x is the value of msSendCommandDelay.
*/
int msSendCommandDelay = 0;
long lastCommandSentTimeStamp;
std::chrono::milliseconds msSendCommandDelay = std::chrono::milliseconds(0);
long lastCommandSentTimeStamp = 0;
public:
explicit CmsisDapInterface() = default;
@@ -45,16 +45,12 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap
return this->usbHidInterface;
}
void setUsbHidInterface(Usb::HidInterface& usbHidInterface) {
this->usbHidInterface = usbHidInterface;
}
size_t getUsbHidInputReportSize() {
return this->usbHidInterface.getInputReportSize();
}
void setMinimumCommandTimeGap(int millisecondTimeGap) {
this->msSendCommandDelay = millisecondTimeGap;
void setMinimumCommandTimeGap(std::chrono::milliseconds commandTimeGap) {
this->msSendCommandDelay = commandTimeGap;
}
/**

View File

@@ -94,8 +94,8 @@ namespace Bloom::DebugToolDrivers::TargetInterfaces::Microchip::Avr::Avr8
/**
* Should retrieve the AVR8 target signature of the AVR8 target.
*
* This method may invoke stop(), as some interfaces are known to require the target to be in a stopped
* state before the signature can be read.
* This method may invoke stop(), as the target may be required to be in a halted state before the signature
* can be read.
*
* @return
*/