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-16 18:51:42 +0300
committerDavid Crocker <dcrocker@eschertech.com>2021-10-16 18:51:42 +0300
commitd5086b46ba31e0ae2fa1f78430ba5a59aa8b5758 (patch)
tree9d5ca39e7fc85eefada33efb070fb63a403e906a /src/Movement
parentd173861af0d5e91470520f24faf95542de0afc95 (diff)
Changed definition of StandardDriverStatus
Diffstat (limited to 'src/Movement')
-rw-r--r--src/Movement/StepperDrivers/TMC22xx.cpp7
-rw-r--r--src/Movement/StepperDrivers/TMC22xx.h29
-rw-r--r--src/Movement/StepperDrivers/TMC51xx.cpp4
-rw-r--r--src/Movement/StepperDrivers/TMC51xx.h19
4 files changed, 31 insertions, 28 deletions
diff --git a/src/Movement/StepperDrivers/TMC22xx.cpp b/src/Movement/StepperDrivers/TMC22xx.cpp
index f991c75a..db463770 100644
--- a/src/Movement/StepperDrivers/TMC22xx.cpp
+++ b/src/Movement/StepperDrivers/TMC22xx.cpp
@@ -2242,11 +2242,8 @@ StandardDriverStatus SmartDrivers::GetStandardDriverStatus(size_t driver) noexce
const uint32_t status = driverStates[driver].ReadLiveStatus();
// The lowest 8 bits of StandardDriverStatus have the same meanings as for the TMC2209 status
rslt.all = status & 0x000000FF;
- rslt.all |= (status >> (31 - 10)) & (1u << 10); // put the standstill bit in the right place
- if (status & TMC_RR_SG)
- {
- rslt.stall = true;
- }
+ rslt.all |= ((status >> TMC_RR_STST_BIT_POS) & 1u) << StandardDriverStatus::StandstillBitPos; // put the standstill bit in the right place
+ rslt.all |= ((status >> TMC_RR_SG_BIT_POS) & 1u) << StandardDriverStatus::StallBitPos; // put the stall bit in the right place
}
else
{
diff --git a/src/Movement/StepperDrivers/TMC22xx.h b/src/Movement/StepperDrivers/TMC22xx.h
index 9a26608c..b41e2976 100644
--- a/src/Movement/StepperDrivers/TMC22xx.h
+++ b/src/Movement/StepperDrivers/TMC22xx.h
@@ -16,20 +16,23 @@
#include <GCodes/GCodeResult.h>
// TMC22xx DRV_STATUS register bit assignments
-const uint32_t TMC_RR_OT = 1u << 1; // over temperature shutdown
-const uint32_t TMC_RR_OTPW = 1u << 0; // over temperature warning
-const uint32_t TMC_RR_S2G = 15u << 2; // short to ground counter (4 bits)
-const uint32_t TMC_RR_OLA = 1u << 6; // open load A
-const uint32_t TMC_RR_OLB = 1u << 7; // open load B
-const uint32_t TMC_RR_STST = 1u << 31; // standstill detected
-const uint32_t TMC_RR_OPW_120 = 1u << 8; // temperature threshold exceeded
-const uint32_t TMC_RR_OPW_143 = 1u << 9; // temperature threshold exceeded
-const uint32_t TMC_RR_OPW_150 = 1u << 10; // temperature threshold exceeded
-const uint32_t TMC_RR_OPW_157 = 1u << 11; // temperature threshold exceeded
-const uint32_t TMC_RR_TEMPBITS = 15u << 8; // all temperature threshold bits
+constexpr uint32_t TMC_RR_OT = 1u << 1; // over temperature shutdown
+constexpr uint32_t TMC_RR_OTPW = 1u << 0; // over temperature warning
+constexpr uint32_t TMC_RR_S2G = 15u << 2; // short to ground counter (4 bits)
+constexpr uint32_t TMC_RR_OLA = 1u << 6; // open load A
+constexpr uint32_t TMC_RR_OLB = 1u << 7; // open load B
+constexpr uint32_t TMC_RR_STST = 1u << 31; // standstill detected
+constexpr uint32_t TMC_RR_OPW_120 = 1u << 8; // temperature threshold exceeded
+constexpr uint32_t TMC_RR_OPW_143 = 1u << 9; // temperature threshold exceeded
+constexpr uint32_t TMC_RR_OPW_150 = 1u << 10; // temperature threshold exceeded
+constexpr uint32_t TMC_RR_OPW_157 = 1u << 11; // temperature threshold exceeded
+constexpr uint32_t TMC_RR_TEMPBITS = 15u << 8; // all temperature threshold bits
-const uint32_t TMC_RR_RESERVED = (15u << 12) | (0x01FF << 21); // reserved bits
-const uint32_t TMC_RR_SG = 1u << 12; // this is a reserved bit, which we use to signal a stall
+constexpr uint32_t TMC_RR_RESERVED = (15u << 12) | (0x01FF << 21); // reserved bits
+constexpr uint32_t TMC_RR_SG = 1u << 12; // this is a reserved bit, which we use to signal a stall
+
+constexpr unsigned int TMC_RR_STST_BIT_POS = 31;
+constexpr unsigned int TMC_RR_SG_BIT_POS = 12;
namespace SmartDrivers
{
diff --git a/src/Movement/StepperDrivers/TMC51xx.cpp b/src/Movement/StepperDrivers/TMC51xx.cpp
index acd0c34f..27227916 100644
--- a/src/Movement/StepperDrivers/TMC51xx.cpp
+++ b/src/Movement/StepperDrivers/TMC51xx.cpp
@@ -1612,8 +1612,8 @@ StandardDriverStatus SmartDrivers::GetStandardDriverStatus(size_t driver) noexce
rslt.all = (status >> (25 - 0)) & (0x0F << 0); // this puts the it, otpw, s2ga and s2gb bits in the right place
rslt.all |= (status >> (12 - 4)) & (3u << 4); // put s2vsa and s2vsb in the right place
rslt.all |= (status >> (29 - 6)) & (3u << 6); // put ola and olb in the right place
- rslt.all |= (status >> (24 - 9)) & (1u << 9); // put the stall bit in the right place
- rslt.all |= (status >> (31 - 10)) & (1u << 10); // put the standstill bit in the right place
+ rslt.all |= ((status >> TMC_RR_STST_BIT_POS) & 1u) << StandardDriverStatus::StandstillBitPos; // put the standstill bit in the right place
+ rslt.all |= ((status >> TMC_RR_SG_BIT_POS) & 1u) << StandardDriverStatus::StallBitPos; // put the stall bit in the right place
}
else
{
diff --git a/src/Movement/StepperDrivers/TMC51xx.h b/src/Movement/StepperDrivers/TMC51xx.h
index 34c7c6dd..90fc0f76 100644
--- a/src/Movement/StepperDrivers/TMC51xx.h
+++ b/src/Movement/StepperDrivers/TMC51xx.h
@@ -16,14 +16,17 @@
#include "DriverMode.h"
// TMC51xx DRV_STATUS register bit assignments
-const uint32_t TMC_RR_SG = 1 << 24; // stall detected
-const uint32_t TMC_RR_OT = 1 << 25; // over temperature shutdown
-const uint32_t TMC_RR_OTPW = 1 << 26; // over temperature warning
-const uint32_t TMC_RR_S2G = (3 << 27) | (3 << 12); // short to ground indicator (1 bit for each phase) + short to VS indicator
-const uint32_t TMC_RR_OLA = 1 << 29; // open load A
-const uint32_t TMC_RR_OLB = 1 << 30; // open load B
-const uint32_t TMC_RR_STST = 1 << 31; // standstill detected
-const uint32_t TMC_RR_SGRESULT = 0x3FF; // 10-bit stallGuard2 result
+constexpr uint32_t TMC_RR_SG = 1 << 24; // stall detected
+constexpr uint32_t TMC_RR_OT = 1 << 25; // over temperature shutdown
+constexpr uint32_t TMC_RR_OTPW = 1 << 26; // over temperature warning
+constexpr uint32_t TMC_RR_S2G = (3 << 27) | (3 << 12); // short to ground indicator (1 bit for each phase) + short to VS indicator
+constexpr uint32_t TMC_RR_OLA = 1 << 29; // open load A
+constexpr uint32_t TMC_RR_OLB = 1 << 30; // open load B
+constexpr uint32_t TMC_RR_STST = 1 << 31; // standstill detected
+constexpr uint32_t TMC_RR_SGRESULT = 0x3FF; // 10-bit stallGuard2 result
+
+constexpr unsigned int TMC_RR_STST_BIT_POS = 31;
+constexpr unsigned int TMC_RR_SG_BIT_POS = 24;
namespace SmartDrivers
{