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>2018-04-29 00:52:40 +0300
committerDavid Crocker <dcrocker@eschertech.com>2018-04-29 00:59:17 +0300
commitc00658ef324db4f42e769f681239a3c409c5a8c0 (patch)
treef87ee7420f6a1b7b235e1e81be5fe95954b95b70 /src/Platform.cpp
parent5f8c50c7901b3ac60ecf88382f5d6f21c52a24a8 (diff)
Version 2.0beta3
New features: - Stepper driver mode can now be set via D parameter in M569 - Stepper driver chopper control register can now be set via C parameter in M569 - USE THIS ONLY IF YOIU KNOW WHAT YOU ARE DOING! - When Z probe type 0 is selected and DWC/PanelDue have prompted for manual jogging, axis movement before homing is allowed Bug fixes: - If a network password was set, DWC disconnected with a "Not authorised" message after a large file was uploaded - If MaxReps got too high then a watchdog reset occurred. MaxReps has been replaced by a hiccup count. - M122 reported some parts of network status twice on Duet 2 Ethernet and Duet 2 Maestro - If a PT1000 sensor was configured using M305 but a thermistor was plugged in instead, the firmware reported semi-random high temperatures instead of an error - If a PT1000 sensor was configured using M305 and then M305 was used to change it back to a thermistor, it remained configured as a PT1000 - The M105 response on a multi-tool system was not in the exact format that Octoprint wanted
Diffstat (limited to 'src/Platform.cpp')
-rw-r--r--src/Platform.cpp59
1 files changed, 46 insertions, 13 deletions
diff --git a/src/Platform.cpp b/src/Platform.cpp
index e8031e2c..4542e1a9 100644
--- a/src/Platform.cpp
+++ b/src/Platform.cpp
@@ -3002,7 +3002,7 @@ bool Platform::SetDriverMicrostepping(size_t driver, unsigned int microsteps, in
}
// Set the microstepping, returning true if successful. All drivers for the same axis must use the same microstepping.
-bool Platform::SetMicrostepping(size_t drive, int microsteps, int mode)
+bool Platform::SetMicrostepping(size_t drive, int microsteps, bool interp)
{
// Check that it is a valid microstepping number
const size_t numAxes = reprap.GetGCodes().GetTotalAxes();
@@ -3011,24 +3011,24 @@ bool Platform::SetMicrostepping(size_t drive, int microsteps, int mode)
bool ok = true;
for (size_t i = 0; i < axisDrivers[drive].numDrivers; ++i)
{
- ok = SetDriverMicrostepping(axisDrivers[drive].driverNumbers[i], microsteps, mode) && ok;
+ ok = SetDriverMicrostepping(axisDrivers[drive].driverNumbers[i], microsteps, interp) && ok;
}
return ok;
}
else if (drive < DRIVES)
{
- return SetDriverMicrostepping(extruderDrivers[drive - numAxes], microsteps, mode);
+ return SetDriverMicrostepping(extruderDrivers[drive - numAxes], microsteps, interp);
}
return false;
}
// Get the microstepping for a driver
-unsigned int Platform::GetDriverMicrostepping(size_t driver, int mode, bool& interpolation) const
+unsigned int Platform::GetDriverMicrostepping(size_t driver, bool& interpolation) const
{
#if HAS_SMART_DRIVERS
if (driver < numSmartDrivers)
{
- return SmartDrivers::GetMicrostepping(driver, mode, interpolation);
+ return SmartDrivers::GetMicrostepping(driver, interpolation);
}
// On-board drivers only support x16 microstepping without interpolation
interpolation = false;
@@ -3043,16 +3043,16 @@ unsigned int Platform::GetDriverMicrostepping(size_t driver, int mode, bool& int
}
// Get the microstepping for an axis or extruder
-unsigned int Platform::GetMicrostepping(size_t drive, int mode, bool& interpolation) const
+unsigned int Platform::GetMicrostepping(size_t drive, bool& interpolation) const
{
const size_t numAxes = reprap.GetGCodes().GetTotalAxes();
if (drive < numAxes)
{
- return GetDriverMicrostepping(axisDrivers[drive].driverNumbers[0], mode, interpolation);
+ return GetDriverMicrostepping(axisDrivers[drive].driverNumbers[0], interpolation);
}
else if (drive < DRIVES)
{
- return GetDriverMicrostepping(extruderDrivers[drive - numAxes], mode, interpolation);
+ return GetDriverMicrostepping(extruderDrivers[drive - numAxes], interpolation);
}
else
{
@@ -3348,7 +3348,7 @@ void Platform::RawMessage(MessageType type, const char *message)
}
else if ((type & LcdMessage) != 0)
{
- AppendAuxReply(message, (message[0] == '{') || (type & RawMessageFlag) != 0);
+ AppendAuxReply(message, message[0] == '{' || (type & RawMessageFlag) != 0);
}
if ((type & HttpMessage) != 0)
@@ -4419,18 +4419,51 @@ void STEP_TC_HANDLER()
{
const irqflags_t flags = cpu_irq_save();
const int32_t diff = (int32_t)(tim - GetInterruptClocksInterruptsDisabled()); // see how long we have to go
- if (diff < (int32_t)DDA::MinInterruptInterval) // if less than about 6us or already passed
+ if (diff < (int32_t)DDA::MinInterruptInterval) // if less than about 6us or already passed
{
cpu_irq_restore(flags);
- return true; // tell the caller to simulate an interrupt instead
+ return true; // tell the caller to simulate an interrupt instead
+ }
+
+ STEP_TC->TC_CHANNEL[STEP_TC_CHAN].TC_RA = tim; // set up the compare register
+
+ // We would like to clear any pending step interrupt. To do this, we must read the TC status register.
+ // Unfortunately, this would clear any other pending interrupts from the same TC.
+ // So we don't, and the step ISR must allow for getting called prematurely.
+ STEP_TC->TC_CHANNEL[STEP_TC_CHAN].TC_IER = TC_IER_CPAS; // enable the interrupt
+ cpu_irq_restore(flags);
+
+#ifdef MOVE_DEBUG
+ ++numInterruptsScheduled;
+ nextInterruptTime = tim;
+ nextInterruptScheduledAt = Platform::GetInterruptClocks();
+#endif
+ return false;
+}
+
+// Schedule an interrupt at the specified clock count, or return true if it has passed already
+// This version limits the time we can spend in the ISR
+/*static*/ bool Platform::ScheduleStepInterruptWithLimit(uint32_t tim, uint32_t isrStartTime)
+{
+ const irqflags_t flags = cpu_irq_save();
+ const uint32_t iClocks = GetInterruptClocksInterruptsDisabled();
+ if ((int32_t)(tim - iClocks) < (int32_t)DDA::MinInterruptInterval) // if less than about 6us to go or already passed
+ {
+ if (iClocks - isrStartTime < DDA::MaxStepInterruptTime) // if we haven't already spent too much time looping inside the ISR
+ {
+ cpu_irq_restore(flags);
+ return true; // tell the caller to simulate an interrupt instead
+ }
+ tim = iClocks + DDA::MinInterruptInterval; // delay the interrupt to avoid using all the CPU time
+ ++DDA::numHiccups;
}
- STEP_TC->TC_CHANNEL[STEP_TC_CHAN].TC_RA = tim; // set up the compare register
+ STEP_TC->TC_CHANNEL[STEP_TC_CHAN].TC_RA = tim; // set up the compare register
// We would like to clear any pending step interrupt. To do this, we must read the TC status register.
// Unfortunately, this would clear any other pending interrupts from the same TC.
// So we don't, and the step ISR must allow for getting called prematurely.
- STEP_TC->TC_CHANNEL[STEP_TC_CHAN].TC_IER = TC_IER_CPAS; // enable the interrupt
+ STEP_TC->TC_CHANNEL[STEP_TC_CHAN].TC_IER = TC_IER_CPAS; // enable the interrupt
cpu_irq_restore(flags);
#ifdef MOVE_DEBUG