Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/Duet3D/RepRapFirmware.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Crocker <dcrocker@eschertech.com>2021-10-18 22:59:48 +0300
committerDavid Crocker <dcrocker@eschertech.com>2021-10-18 22:59:48 +0300
commit329865b3b09495a95255ab108d7cdc14c2348c37 (patch)
treec6db73d9d129be009ce39b6898cc65186e605252 /src/Movement
parentc0f47d671496f5ada26fc3094441ec2ff80a48ae (diff)
Refactored AppendDriverStatus and its calling code
Diffstat (limited to 'src/Movement')
-rw-r--r--src/Movement/StepperDrivers/TMC22xx.cpp69
-rw-r--r--src/Movement/StepperDrivers/TMC22xx.h1
-rw-r--r--src/Movement/StepperDrivers/TMC2660.cpp40
-rw-r--r--src/Movement/StepperDrivers/TMC2660.h1
-rw-r--r--src/Movement/StepperDrivers/TMC51xx.cpp39
-rw-r--r--src/Movement/StepperDrivers/TMC51xx.h1
6 files changed, 19 insertions, 132 deletions
diff --git a/src/Movement/StepperDrivers/TMC22xx.cpp b/src/Movement/StepperDrivers/TMC22xx.cpp
index 5bab7a0b..abbacc89 100644
--- a/src/Movement/StepperDrivers/TMC22xx.cpp
+++ b/src/Movement/StepperDrivers/TMC22xx.cpp
@@ -1253,51 +1253,9 @@ uint32_t TmcDriverState::ReadAccumulatedStatus(uint32_t bitsToKeep) noexcept
return status;
}
-// Append the driver status to a string, and reset the min/max load values
+// Append any additional driver status to a string, and reset the min/max load values
void TmcDriverState::AppendDriverStatus(const StringRef& reply) noexcept
{
- if (!DriverAssumedPresent())
- {
- reply.cat(" assumed not present");
- return;
- }
-
- const uint32_t lastReadStatus = readRegisters[ReadDrvStat];
- if (lastReadStatus & TMC_RR_OT)
- {
- reply.cat(" temperature-shutdown!");
- }
- else if (lastReadStatus & TMC_RR_OTPW)
- {
- reply.cat(" temperature-warning");
- }
- if (lastReadStatus & TMC_RR_S2G)
- {
- reply.cat(" short-to-ground");
- }
- if (lastReadStatus & TMC_RR_OLA)
- {
- reply.cat(" open-load-A");
- }
- if (lastReadStatus & TMC_RR_OLB)
- {
- reply.cat(" open-load-B");
- }
- if (lastReadStatus & TMC_RR_STST)
- {
- reply.cat(" standstill");
- }
-#if RESET_MICROSTEP_COUNTERS_AT_INIT
- if (hadStepFailure)
- {
- reply.cat(" stepFail");
- }
-#endif
- else if ((lastReadStatus & (TMC_RR_OT | TMC_RR_OTPW | TMC_RR_S2G | TMC_RR_OLA | TMC_RR_OLB | TMC_RR_STST)) == 0)
- {
- reply.cat( "ok");
- }
-
#if HAS_STALL_DETECT
if (minSgLoadRegister <= 1023)
{
@@ -1323,14 +1281,22 @@ void TmcDriverState::AppendDriverStatus(const StringRef& reply) noexcept
StandardDriverStatus TmcDriverState::GetStandardDriverStatus() const noexcept
{
StandardDriverStatus rslt;
- const uint32_t status = ReadLiveStatus();
- // The lowest 8 bits of StandardDriverStatus have the same meanings as for the TMC2209 status
- rslt.all = status & 0x000000FF;
- rslt.all |= ExtractBit(status, TMC_RR_STST_BIT_POS, StandardDriverStatus::StandstillBitPos); // put the standstill bit in the right place
- rslt.all |= ExtractBit(status, TMC_RR_SG_BIT_POS, StandardDriverStatus::StallBitPos); // put the stall bit in the right place
+ if (DriverAssumedPresent())
+ {
+ const uint32_t status = ReadLiveStatus();
+ // The lowest 8 bits of StandardDriverStatus have the same meanings as for the TMC2209 status
+ rslt.all = status & 0x000000FF;
+ rslt.all |= ExtractBit(status, TMC_RR_STST_BIT_POS, StandardDriverStatus::StandstillBitPos); // put the standstill bit in the right place
+ rslt.all |= ExtractBit(status, TMC_RR_SG_BIT_POS, StandardDriverStatus::StallBitPos); // put the stall bit in the right place
#if HAS_STALL_DETECT
- rslt.sgresultMin = minSgLoadRegister;
+ rslt.sgresultMin = minSgLoadRegister;
#endif
+ }
+ else
+ {
+ rslt.all = 0;
+ rslt.notPresent = true;
+ }
return rslt;
}
@@ -1980,11 +1946,6 @@ void SmartDrivers::EnableDrive(size_t drive, bool en) noexcept
}
}
-uint32_t SmartDrivers::GetLiveStatus(size_t drive) noexcept
-{
- return (drive < GetNumTmcDrivers()) ? driverStates[drive].ReadLiveStatus() : 0;
-}
-
uint32_t SmartDrivers::GetAccumulatedStatus(size_t drive, uint32_t bitsToKeep) noexcept
{
return (drive < GetNumTmcDrivers()) ? driverStates[drive].ReadAccumulatedStatus(bitsToKeep) : 0;
diff --git a/src/Movement/StepperDrivers/TMC22xx.h b/src/Movement/StepperDrivers/TMC22xx.h
index 02898616..15f75e97 100644
--- a/src/Movement/StepperDrivers/TMC22xx.h
+++ b/src/Movement/StepperDrivers/TMC22xx.h
@@ -48,7 +48,6 @@ namespace SmartDrivers
uint32_t GetAxisNumber(size_t drive) noexcept;
void SetCurrent(size_t drive, float current) noexcept;
void EnableDrive(size_t drive, bool en) noexcept;
- uint32_t GetLiveStatus(size_t drive) noexcept;
uint32_t GetAccumulatedStatus(size_t drive, uint32_t bitsToKeep) noexcept;
bool SetMicrostepping(size_t drive, unsigned int microsteps, bool interpolation) noexcept;
unsigned int GetMicrostepping(size_t drive, bool& interpolation) noexcept;
diff --git a/src/Movement/StepperDrivers/TMC2660.cpp b/src/Movement/StepperDrivers/TMC2660.cpp
index 44f18bd0..37032ea2 100644
--- a/src/Movement/StepperDrivers/TMC2660.cpp
+++ b/src/Movement/StepperDrivers/TMC2660.cpp
@@ -686,45 +686,16 @@ void TmcDriverState::AppendStallConfig(const StringRef& reply) const noexcept
threshold, ((filtered) ? "on" : "off"), fullstepsPerSecond, (double)speed, registers[SmartEnable] & 0xFFFF);
}
-// Append the driver status to a string, and reset the min/max load values
+// Append any additional driver status to a string, and reset the min/max load values
void TmcDriverState::AppendDriverStatus(const StringRef& reply) noexcept
{
- if (lastReadStatus & TMC_RR_OT)
- {
- reply.cat("temperature-shutdown! ");
- }
- else if (lastReadStatus & TMC_RR_OTPW)
- {
- reply.cat("temperature-warning, ");
- }
- if (lastReadStatus & TMC_RR_S2G)
- {
- reply.cat("short-to-ground, ");
- }
- if (lastReadStatus & TMC_RR_OLA)
- {
- reply.cat("open-load-A, ");
- }
- if (lastReadStatus & TMC_RR_OLB)
- {
- reply.cat("open-load-B, ");
- }
- if (lastReadStatus & TMC_RR_STST)
- {
- reply.cat("standstill, ");
- }
- else if ((lastReadStatus & (TMC_RR_OT | TMC_RR_OTPW | TMC_RR_S2G | TMC_RR_OLA | TMC_RR_OLB)) == 0)
- {
- reply.cat("ok, ");
- }
-
if (minSgLoadRegister <= 1023)
{
- reply.catf("SG min %u", minSgLoadRegister);
+ reply.catf(", SG min %u", minSgLoadRegister);
}
else
{
- reply.cat("SG min n/a");
+ reply.cat(", SG min n/a");
}
ResetLoadRegisters();
}
@@ -1009,11 +980,6 @@ void SmartDrivers::EnableDrive(size_t driver, bool en) noexcept
}
}
-uint32_t SmartDrivers::GetLiveStatus(size_t driver) noexcept
-{
- return (driver < numTmc2660Drivers) ? driverStates[driver].ReadLiveStatus() : 0;
-}
-
uint32_t SmartDrivers::GetAccumulatedStatus(size_t driver, uint32_t bitsToKeep) noexcept
{
return (driver < numTmc2660Drivers) ? driverStates[driver].ReadAccumulatedStatus(bitsToKeep) : 0;
diff --git a/src/Movement/StepperDrivers/TMC2660.h b/src/Movement/StepperDrivers/TMC2660.h
index 8bb8d97e..df12be5f 100644
--- a/src/Movement/StepperDrivers/TMC2660.h
+++ b/src/Movement/StepperDrivers/TMC2660.h
@@ -39,7 +39,6 @@ namespace SmartDrivers
void SetAxisNumber(size_t driver, uint32_t axisNumber) noexcept;
void SetCurrent(size_t driver, float current) noexcept;
void EnableDrive(size_t driver, bool en) noexcept;
- uint32_t GetLiveStatus(size_t driver) noexcept;
uint32_t GetAccumulatedStatus(size_t drive, uint32_t bitsToKeep) noexcept;
bool SetMicrostepping(size_t drive, unsigned int microsteps, bool interpolation) noexcept;
unsigned int GetMicrostepping(size_t drive, bool& interpolation) noexcept;
diff --git a/src/Movement/StepperDrivers/TMC51xx.cpp b/src/Movement/StepperDrivers/TMC51xx.cpp
index e105fe0b..eca0a573 100644
--- a/src/Movement/StepperDrivers/TMC51xx.cpp
+++ b/src/Movement/StepperDrivers/TMC51xx.cpp
@@ -760,39 +760,9 @@ uint32_t TmcDriverState::ReadAccumulatedStatus(uint32_t bitsToKeep) noexcept
return status & (TMC_RR_SG | TMC_RR_OT | TMC_RR_OTPW | TMC_RR_S2G | TMC_RR_OLA | TMC_RR_OLB | TMC_RR_STST);
}
-// Append the driver status to a string, and reset the min/max load values
+// Append any additional driver status to a string, and reset the min/max load values
void TmcDriverState::AppendDriverStatus(const StringRef& reply, bool clearGlobalStats) noexcept
{
- const uint32_t lastReadStatus = readRegisters[ReadDrvStat];
- if (lastReadStatus & TMC_RR_OT)
- {
- reply.cat(" temperature-shutdown!");
- }
- else if (lastReadStatus & TMC_RR_OTPW)
- {
- reply.cat(" temperature-warning");
- }
- if (lastReadStatus & TMC_RR_S2G)
- {
- reply.cat(" short-to-ground");
- }
- if ((lastReadStatus & TMC_RR_OLA) && !(lastReadStatus & TMC_RR_STST))
- {
- reply.cat(" open-load-A");
- }
- if ((lastReadStatus & TMC_RR_OLB) && !(lastReadStatus & TMC_RR_STST))
- {
- reply.cat(" open-load-B");
- }
- if (lastReadStatus & TMC_RR_STST)
- {
- reply.cat(" standstill");
- }
- else if ((lastReadStatus & (TMC_RR_OT | TMC_RR_OTPW | TMC_RR_S2G | TMC_RR_OLA | TMC_RR_OLB)) == 0)
- {
- reply.cat(" ok");
- }
-
if (minSgLoadRegister <= 1023)
{
reply.catf(", SG min %u", minSgLoadRegister);
@@ -802,14 +772,12 @@ void TmcDriverState::AppendDriverStatus(const StringRef& reply, bool clearGlobal
reply.cat(", SG min n/a");
}
ResetLoadRegisters();
-
reply.catf(", reads %u, writes %u timeouts %u", numReads, numWrites, numTimeouts);
numReads = numWrites = 0;
if (clearGlobalStats)
{
numTimeouts = 0;
}
-
}
StandardDriverStatus TmcDriverState::GetStandardDriverStatus() const noexcept
@@ -1443,11 +1411,6 @@ void SmartDrivers::EnableDrive(size_t driver, bool en) noexcept
}
}
-uint32_t SmartDrivers::GetLiveStatus(size_t driver) noexcept
-{
- return (driver < numTmc51xxDrivers) ? driverStates[driver].ReadLiveStatus() : 0;
-}
-
uint32_t SmartDrivers::GetAccumulatedStatus(size_t driver, uint32_t bitsToKeep) noexcept
{
return (driver < numTmc51xxDrivers) ? driverStates[driver].ReadAccumulatedStatus(bitsToKeep) : 0;
diff --git a/src/Movement/StepperDrivers/TMC51xx.h b/src/Movement/StepperDrivers/TMC51xx.h
index aa77821e..4066cf93 100644
--- a/src/Movement/StepperDrivers/TMC51xx.h
+++ b/src/Movement/StepperDrivers/TMC51xx.h
@@ -39,7 +39,6 @@ namespace SmartDrivers
uint32_t GetAxisNumber(size_t drive) noexcept;
void SetCurrent(size_t driver, float current) noexcept;
void EnableDrive(size_t driver, bool en) noexcept;
- uint32_t GetLiveStatus(size_t driver) noexcept;
uint32_t GetAccumulatedStatus(size_t drive, uint32_t bitsToKeep) noexcept;
bool SetMicrostepping(size_t drive, unsigned int microsteps, bool interpolation) noexcept;
unsigned int GetMicrostepping(size_t drive, bool& interpolation) noexcept;