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-20 17:20:19 +0300
committerDavid Crocker <dcrocker@eschertech.com>2021-10-20 17:20:19 +0300
commit2cc54a41449563382c88f1428ba61de07b1787f4 (patch)
treef873ec63ad5f525f5c78e34d90e87cd24215ce9b /src/Platform
parentd871030b229dc7da69e0a3ff7b22c76d1e1360c7 (diff)
Finished refactoring smart driver status
Diffstat (limited to 'src/Platform')
-rw-r--r--src/Platform/Event.cpp2
-rw-r--r--src/Platform/EventManager.cpp14
-rw-r--r--src/Platform/EventManager.h23
-rw-r--r--src/Platform/Platform.cpp36
-rw-r--r--src/Platform/Platform.h6
5 files changed, 59 insertions, 22 deletions
diff --git a/src/Platform/Event.cpp b/src/Platform/Event.cpp
index a78fe7a3..ddc17eb6 100644
--- a/src/Platform/Event.cpp
+++ b/src/Platform/Event.cpp
@@ -48,7 +48,7 @@ void Event::AppendText(const StringRef &str) const noexcept
break;
case EventType::Trigger:
- str.catf(" %u", deviceNumber);
+ str.catf(" %u activated", deviceNumber);
break;
case EventType::Mcu_temperature_warning:
diff --git a/src/Platform/EventManager.cpp b/src/Platform/EventManager.cpp
new file mode 100644
index 00000000..e0d4c3f5
--- /dev/null
+++ b/src/Platform/EventManager.cpp
@@ -0,0 +1,14 @@
+/*
+ * EventManager.cpp
+ *
+ * Created on: 19 Oct 2021
+ * Author: David
+ */
+
+#include "EventManager.h"
+
+EventManager::EventManager() : eventsPending(nullptr), lastWarningMillis(0)
+{
+}
+
+// End
diff --git a/src/Platform/EventManager.h b/src/Platform/EventManager.h
new file mode 100644
index 00000000..8f3d23c9
--- /dev/null
+++ b/src/Platform/EventManager.h
@@ -0,0 +1,23 @@
+/*
+ * EventManager.h
+ *
+ * Created on: 19 Oct 2021
+ * Author: David
+ */
+
+#ifndef SRC_PLATFORM_EVENTMANAGER_H_
+#define SRC_PLATFORM_EVENTMANAGER_H_
+
+#include "Event.h"
+
+class EventManager
+{
+public:
+ EventManager();
+
+private:
+ Event *eventsPending; // linked list of pending events
+ uint32_t lastWarningMillis; // when we last sent a warning message
+};
+
+#endif /* SRC_PLATFORM_EVENTMANAGER_H_ */
diff --git a/src/Platform/Platform.cpp b/src/Platform/Platform.cpp
index c83724f7..5be4b3c9 100644
--- a/src/Platform/Platform.cpp
+++ b/src/Platform/Platform.cpp
@@ -417,7 +417,7 @@ Platform::Platform() noexcept :
sysDir(nullptr),
#endif
tickState(0), debugCode(0),
- eventsPending(nullptr), lastWarningMillis(0),
+ lastDriverPollMillis(0),
#ifdef DUET3MINI
whenLastCanMessageProcessed(0),
#endif
@@ -1058,7 +1058,7 @@ void Platform::Spin() noexcept
}
// Check whether the TMC drivers need to be initialised.
- // The tick ISR also looks for over-voltage events, but it just disables the driver without changing driversPowerd or numVinOverVoltageEvents
+ // The tick ISR also looks for over-voltage events, but it just disables the drivers without changing driversPowered or numVinOverVoltageEvents
if (driversPowered)
{
#if HAS_VOLTAGE_MONITOR
@@ -1094,19 +1094,19 @@ void Platform::Spin() noexcept
{
#if HAS_SMART_DRIVERS
// Check one TMC2660 or TMC2224 for temperature warning or temperature shutdown
- if (enableValues[nextDriveToPoll] >= 0) // don't poll driver if it is flagged "no poll"
+ if (enableValues[nextDriveToPoll] >= 0) // don't poll driver if it is flagged "no poll"
{
- const uint32_t stat = SmartDrivers::GetAccumulatedStatus(nextDriveToPoll, 0);
+ const StandardDriverStatus stat = SmartDrivers::GetStatus(nextDriveToPoll, true, true);
const DriversBitmap mask = DriversBitmap::MakeFromBits(nextDriveToPoll);
- if (stat & TMC_RR_OT)
+ if (stat.ot)
{
temperatureShutdownDrivers |= mask;
}
- else if (stat & TMC_RR_OTPW)
+ else if (stat.otpw)
{
temperatureWarningDrivers |= mask;
}
- if (stat & TMC_RR_S2G)
+ if (stat.s2ga || stat.s2gb || stat.s2vsa || stat.s2vsb)
{
shortToGroundDrivers |= mask;
}
@@ -1117,7 +1117,7 @@ void Platform::Spin() noexcept
// The driver often produces a transient open-load error, especially in stealthchop mode, so we require the condition to persist before we report it.
// Also, false open load indications persist when in standstill, if the phase has zero current in that position
- if ((stat & TMC_RR_OLA) != 0)
+ if (stat.ola)
{
if (!openLoadATimer.IsRunning())
{
@@ -1136,7 +1136,7 @@ void Platform::Spin() noexcept
}
}
- if ((stat & TMC_RR_OLB) != 0)
+ if (stat.olb)
{
if (!openLoadBTimer.IsRunning())
{
@@ -1156,7 +1156,7 @@ void Platform::Spin() noexcept
}
# if HAS_STALL_DETECT
- if ((stat & TMC_RR_SG) != 0)
+ if (stat.stall)
{
if (stalledDrivers.Disjoint(mask))
{
@@ -1268,7 +1268,7 @@ void Platform::Spin() noexcept
}
// Check whether it is time to report any faults (do this after checking fans in case driver cooling fans are turned on)
- if (now - lastWarningMillis > MinimumWarningInterval)
+ if (now - lastDriverPollMillis > MinimumWarningInterval)
{
bool reported = false;
#if HAS_SMART_DRIVERS
@@ -1374,7 +1374,7 @@ void Platform::Spin() noexcept
#endif
if (reported)
{
- lastWarningMillis = now;
+ lastDriverPollMillis = now;
}
}
}
@@ -1420,7 +1420,7 @@ void Platform::Spin() noexcept
#endif
#if HAS_MASS_STORAGE
- // Flush the log file it it is time. This may take some time, so do it last.
+ // Flush the log file if it is time. This may take some time, so do it last.
if (logger != nullptr)
{
logger->Flush(false);
@@ -1801,7 +1801,7 @@ void Platform::Diagnostics(MessageType mtype) noexcept
if (drive < numSmartDrivers)
{
driverStatus.cat(", ");
- const StandardDriverStatus status = SmartDrivers::GetStandardDriverStatus(drive);
+ const StandardDriverStatus status = SmartDrivers::GetStatus(drive);
status.AppendText(driverStatus.GetRef(), 0);
if (!status.notPresent)
{
@@ -1982,13 +1982,13 @@ GCodeResult Platform::DiagnosticTest(GCodeBuffer& gb, const StringRef& reply, Ou
bool driversOK = true;
for (size_t driver = 0; driver < numSmartDrivers; ++driver)
{
- const uint32_t stat = SmartDrivers::GetAccumulatedStatus(driver, 0xFFFFFFFF);
- if ((stat & (TMC_RR_OT || TMC_RR_OTPW)) != 0)
+ const StandardDriverStatus stat = SmartDrivers::GetStatus(driver, true, false);
+ if (stat.ot || stat.otpw)
{
buf->lcatf("Driver %u reports over temperature", driver);
driversOK = false;
}
- if ((stat & TMC_RR_S2G) != 0)
+ if (stat.s2ga || stat.s2gb || stat.s2vsa || stat.s2vsb)
{
buf->lcatf("Driver %u reports short-to-ground", driver);
driversOK = false;
@@ -5086,7 +5086,7 @@ void Platform::SendDriversStatus(CanMessageBuffer& buf) noexcept
msg->SetStandardFields(MaxSmartDrivers);
for (size_t driver = 0; driver < MaxSmartDrivers; ++driver)
{
- msg->data[driver] = SmartDrivers::GetStandardDriverStatus(driver);
+ msg->data[driver] = SmartDrivers::GetStatus(driver);
}
# else
msg->SetStandardFields(NumDrivers);
diff --git a/src/Platform/Platform.h b/src/Platform/Platform.h
index 88816f5a..b6383a8b 100644
--- a/src/Platform/Platform.h
+++ b/src/Platform/Platform.h
@@ -31,7 +31,7 @@ Licence: GPL
#include <Heating/TemperatureError.h>
#include "OutputMemory.h"
#include "UniqueId.h"
-#include "Event.h"
+#include "EventManager.h"
#include <Storage/FileStore.h>
#include <Storage/FileData.h>
#include <Storage/MassStorage.h> // must be after Pins.h because it needs NumSdCards defined
@@ -861,8 +861,8 @@ private:
#endif
// Event handling
- Event *eventsPending; // linked list of unhandled events
- uint32_t lastWarningMillis; // When we last sent a warning message
+ EventManager eventManager;
+ uint32_t lastDriverPollMillis; // when we last checked the drivers and voltage monitoring
#ifdef DUET3MINI
uint32_t whenLastCanMessageProcessed;