diff options
author | David Crocker <dcrocker@eschertech.com> | 2022-07-13 11:16:14 +0300 |
---|---|---|
committer | David Crocker <dcrocker@eschertech.com> | 2022-07-13 11:16:14 +0300 |
commit | c358c80be54ad00bd2d0cd4de06a2b05b479dc8d (patch) | |
tree | 125764459be22ab1030663dab360c0bd62375415 | |
parent | 331487e11666d2a2095f04479e5ded559b8cc1c0 (diff) | |
parent | 4722b3af90f5c29fba30a493d84aadbca735c5b9 (diff) |
Merge branch '3.4-dev' into 3.4-multicast
-rw-r--r-- | src/CAN/CanInterface.cpp | 105 | ||||
-rw-r--r-- | src/Config/Pins_Duet3_MB6HC.h | 2 | ||||
-rw-r--r-- | src/Config/Pins_Duet3_MB6XD.h | 1 | ||||
-rw-r--r-- | src/Platform/Platform.cpp | 16 | ||||
-rw-r--r-- | src/Platform/Platform.h | 2 | ||||
-rw-r--r-- | src/Version.h | 2 |
6 files changed, 64 insertions, 64 deletions
diff --git a/src/CAN/CanInterface.cpp b/src/CAN/CanInterface.cpp index b7827e4d..4c3a6739 100644 --- a/src/CAN/CanInterface.cpp +++ b/src/CAN/CanInterface.cpp @@ -489,71 +489,76 @@ extern "C" [[noreturn]] void CanClockLoop(void *) noexcept for (;;) { -#if SUPPORT_REMOTE_COMMANDS - if (!inExpansionMode) -#endif - { - CanMessageTimeSync * const msg = buf.SetupBroadcastMessage<CanMessageTimeSync>(CanInterface::GetCanAddress()); - msg->lastTimeSent = lastTimeSent; - msg->lastTimeAcknowledgeDelay = 0; // assume we don't have the transmit delay available + CanMessageTimeSync * const msg = buf.SetupBroadcastMessage<CanMessageTimeSync>(CanInterface::GetCanAddress()); + msg->lastTimeSent = lastTimeSent; + msg->lastTimeAcknowledgeDelay = 0; // assume we don't have the transmit delay available - currentTimeSyncMarker = ((currentTimeSyncMarker + 1) & 0x0F) | 0xA0; - buf.marker = currentTimeSyncMarker; - buf.reportInFifo = 1; + currentTimeSyncMarker = ((currentTimeSyncMarker + 1) & 0x0F) | 0xA0; + buf.marker = currentTimeSyncMarker; + buf.reportInFifo = 1; - if (gotTimeSyncTxTimeStamp) - { + if (gotTimeSyncTxTimeStamp) + { # if SAME70 - // On the SAME70 the step clock is also the external time stamp counter - const uint32_t timeSyncTxDelay = (timeSyncTxTimeStamp - (uint16_t)lastTimeSent) & 0xFFFF; + // On the SAME70 the step clock is also the external time stamp counter + const uint32_t timeSyncTxDelay = (timeSyncTxTimeStamp - (uint16_t)lastTimeSent) & 0xFFFF; # else - // On the SAME5x the time stamp counter counts CAN bit times divided by 64 - const uint32_t timeSyncTxDelay = (((timeSyncTxTimeStamp - lastTimeSyncTxPreparedStamp) & 0xFFFF) * CanInterface::GetTimeStampPeriod()) >> 6; + // On the SAME5x the time stamp counter counts CAN bit times divided by 64 + const uint32_t timeSyncTxDelay = (((timeSyncTxTimeStamp - lastTimeSyncTxPreparedStamp) & 0xFFFF) * CanInterface::GetTimeStampPeriod()) >> 6; # endif - if (timeSyncTxDelay > peakTimeSyncTxDelay) - { - peakTimeSyncTxDelay = timeSyncTxDelay; - } - - // Occasionally on the SAME70 we get very large delays reported. These delays are not genuine. - if (timeSyncTxDelay < MaxTimeSyncDelay) - { - msg->lastTimeAcknowledgeDelay = timeSyncTxDelay; - } - gotTimeSyncTxTimeStamp = false; - } - - msg->isPrinting = reprap.GetGCodes().IsReallyPrinting(); - - // Send the real time just once a second - const uint32_t realTime = (uint32_t)reprap.GetPlatform().GetDateTime(); - if (realTime != lastRealTimeSent) + if (timeSyncTxDelay > peakTimeSyncTxDelay) { - msg->realTime = realTime; - lastRealTimeSent = realTime; + peakTimeSyncTxDelay = timeSyncTxDelay; } - else + + // Occasionally on the SAME70 we get very large delays reported. These delays are not genuine. + if (timeSyncTxDelay < MaxTimeSyncDelay) { - buf.dataLength = CanMessageTimeSync::SizeWithoutRealTime; // send a short message to save CAN bandwidth + msg->lastTimeAcknowledgeDelay = timeSyncTxDelay; } + gotTimeSyncTxTimeStamp = false; + } + + msg->isPrinting = reprap.GetGCodes().IsReallyPrinting(); + + // Send the real time just once a second + const uint32_t realTime = (uint32_t)reprap.GetPlatform().GetDateTime(); + if (realTime != lastRealTimeSent) + { + msg->realTime = realTime; + lastRealTimeSent = realTime; + } + else + { + buf.dataLength = CanMessageTimeSync::SizeWithoutRealTime; // send a short message to save CAN bandwidth + } #if SAME70 - lastTimeSent = StepTimer::GetTimerTicks(); + lastTimeSent = StepTimer::GetTimerTicks(); #else - { - AtomicCriticalSectionLocker lock; - lastTimeSent = StepTimer::GetTimerTicks(); - lastTimeSyncTxPreparedStamp = CanInterface::GetTimeStampCounter(); - } -#endif - msg->timeSent = lastTimeSent; - SendCanMessage(TxBufferIndexTimeSync, 0, &buf); - ++timeSyncMessagesSent; + { + AtomicCriticalSectionLocker lock; + lastTimeSent = StepTimer::GetTimerTicks(); + lastTimeSyncTxPreparedStamp = CanInterface::GetTimeStampCounter(); } +#endif + msg->timeSent = lastTimeSent; + SendCanMessage(TxBufferIndexTimeSync, 0, &buf); + ++timeSyncMessagesSent; + + // Blink the LED at about 2Hz. Duet 3 expansion boards will blink in sync when they have established clock sync with us. + digitalWrite(DiagPin, XNor(DiagOnPolarity, lastTimeSent & (1u << 19)) != 0); // Delay until it is time again vTaskDelayUntil(&lastWakeTime, CanClockIntervalMillis); +#if SUPPORT_REMOTE_COMMANDS + if (inExpansionMode) + { + vTaskDelete(nullptr); // once in expansion mode we can't revert to main board mode, so we don't need this task any more + } +#endif + // Check that the message was sent and get the time stamp if (can0dev->IsSpaceAvailable((CanDevice::TxBufferNumber)TxBufferIndexTimeSync, 0)) // if the buffer is free already then the message was sent { @@ -562,8 +567,8 @@ extern "C" [[noreturn]] void CanClockLoop(void *) noexcept else { (void)can0dev->IsSpaceAvailable((CanDevice::TxBufferNumber)TxBufferIndexTimeSync, MaxTimeSyncSendWait); // free the buffer - can0dev->PollTxEventFifo(TxCallback); // empty the fifo - gotTimeSyncTxTimeStamp = false; // ignore any values read from it + can0dev->PollTxEventFifo(TxCallback); // empty the fifo + gotTimeSyncTxTimeStamp = false; // ignore any values read from it } } } diff --git a/src/Config/Pins_Duet3_MB6HC.h b/src/Config/Pins_Duet3_MB6HC.h index ac1d82eb..d9076bed 100644 --- a/src/Config/Pins_Duet3_MB6HC.h +++ b/src/Config/Pins_Duet3_MB6HC.h @@ -153,6 +153,8 @@ constexpr float V12MonitorVoltageRange = (60.4 + 4.7)/4.7 * 3.3; // voltage di // Digital pin number to turn the IR LED on (high) or off (low), also controls the DIAG LED constexpr Pin DiagPin = PortCPin(20); constexpr bool DiagOnPolarity = true; +constexpr Pin ActLedPin = NoPin; +constexpr bool ActOnPolarity = false; // SD cards constexpr size_t NumSdCards = 2; // we now allow one SPI-connected SD card to be configured at boot time diff --git a/src/Config/Pins_Duet3_MB6XD.h b/src/Config/Pins_Duet3_MB6XD.h index 940bb93f..ac87e4dd 100644 --- a/src/Config/Pins_Duet3_MB6XD.h +++ b/src/Config/Pins_Duet3_MB6XD.h @@ -136,6 +136,7 @@ constexpr float V12MonitorVoltageRange = (60.4 + 4.7)/4.7 * 3.3; // voltage di constexpr Pin DiagPin = PortBPin(6); // diag/status LED constexpr Pin ActLedPin = PortBPin(7); // activityLED constexpr bool DiagOnPolarity = false; +constexpr bool ActOnPolarity = false; // SD cards constexpr size_t NumSdCards = 2; diff --git a/src/Platform/Platform.cpp b/src/Platform/Platform.cpp index 968ed426..5988dfd2 100644 --- a/src/Platform/Platform.cpp +++ b/src/Platform/Platform.cpp @@ -415,7 +415,7 @@ Platform::Platform() noexcept : #endif tickState(0), debugCode(0), lastDriverPollMillis(0), -#ifdef DUET3MINI +#if SUPPORT_CAN_EXPANSION whenLastCanMessageProcessed(0), #endif @@ -977,8 +977,7 @@ void Platform::Spin() noexcept return; } -#if defined(DUET3) || defined(DUET3MINI) || defined(__LPC17xx__) -# if SUPPORT_REMOTE_COMMANDS +#if SUPPORT_REMOTE_COMMANDS if (CanInterface::InExpansionMode()) { if (StepTimer::IsSynced()) @@ -990,21 +989,14 @@ void Platform::Spin() noexcept digitalWrite(DiagPin, XNor(DiagOnPolarity, StepTimer::GetTimerTicks() & (1u << 17)) != 0); } } - else -# endif - { - // Blink the LED at about 2Hz. Duet 3 expansion boards will blink in sync when they have established clock sync with us. - digitalWrite(DiagPin, XNor(DiagOnPolarity, StepTimer::GetTimerTicks() & (1u << 19)) != 0); - } #endif -#if defined(DUET3MINI) +#if SUPPORT_CAN_EXPANSION // Turn off the ACT LED if it is time to do so if (millis() - whenLastCanMessageProcessed > ActLedFlashTime) { digitalWrite(ActLedPin, !ActOnPolarity); } - #endif #if HAS_MASS_STORAGE || HAS_SBC_INTERFACE || HAS_EMBEDDED_FILES @@ -4552,7 +4544,7 @@ GCodeResult Platform::UpdateRemoteStepsPerMmAndMicrostepping(AxesBitmap axesAndE void Platform::OnProcessingCanMessage() noexcept { -#ifdef DUET3MINI // MB6HC doesn't yet have a ACT LED +#if SUPPORT_CAN_EXPANSION whenLastCanMessageProcessed = millis(); digitalWrite(ActLedPin, ActOnPolarity); // turn the ACT LED on #endif diff --git a/src/Platform/Platform.h b/src/Platform/Platform.h index a8ae2c27..b8eca7d9 100644 --- a/src/Platform/Platform.h +++ b/src/Platform/Platform.h @@ -912,7 +912,7 @@ private: // Event handling uint32_t lastDriverPollMillis; // when we last checked the drivers and voltage monitoring -#ifdef DUET3MINI +#if SUPPORT_CAN_EXPANSION uint32_t whenLastCanMessageProcessed; #endif diff --git a/src/Version.h b/src/Version.h index eca88cd1..711fda3f 100644 --- a/src/Version.h +++ b/src/Version.h @@ -10,7 +10,7 @@ #ifndef VERSION // Note: the complete VERSION string must be in standard version number format and must not contain spaces! This is so that DWC can parse it. -# define MAIN_VERSION "3.4.2rc1" +# define MAIN_VERSION "3.4.2rc1+" # ifdef USE_CAN0 # define VERSION_SUFFIX "(CAN0)" # else |