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>2022-09-16 16:35:59 +0300
committerDavid Crocker <dcrocker@eschertech.com>2022-09-16 16:35:59 +0300
commitc73ba74cc8310ffe70f918e3be2b540c1beb78be (patch)
tree445db2f2114bc6fd07c4af700fc3a312975a6233
parent45f0aa6dd284d3e54bc83fa54134b9e5a4e203bd (diff)
Fixed Status and Activity LEDs on Duet 3 MB6HC v1.02
-rw-r--r--src/CAN/CanInterface.cpp4
-rw-r--r--src/Config/Pins_Duet3_MB6HC.h17
-rw-r--r--src/Hardware/SAME70/Devices.cpp6
-rw-r--r--src/Platform/Platform.cpp58
-rw-r--r--src/Platform/Platform.h15
-rw-r--r--src/Platform/Tasks.cpp13
6 files changed, 89 insertions, 24 deletions
diff --git a/src/CAN/CanInterface.cpp b/src/CAN/CanInterface.cpp
index 6bcdb362..2ddde129 100644
--- a/src/CAN/CanInterface.cpp
+++ b/src/CAN/CanInterface.cpp
@@ -239,14 +239,14 @@ static inline void UpdateLed(uint32_t stepClocks) noexcept
else
{
// Blink the LED fast. This function gets called every 200ms, so that's the fastest we can blink it without having another task do it.
- digitalWrite(DiagPin, !digitalRead(DiagPin));
+ reprap.GetPlatform().InvertDiagLed();
return;
}
}
#endif
// Blink the LED at about 1Hz. Duet 3 expansion boards will blink in sync when they have established clock sync with us.
- digitalWrite(DiagPin, XNor(DiagOnPolarity, (stepClocks & (1u << 19)) != 0));
+ reprap.GetPlatform().SetDiagLed((stepClocks & (1u << 19)) != 0);
}
static void InitReceiveFilters() noexcept
diff --git a/src/Config/Pins_Duet3_MB6HC.h b/src/Config/Pins_Duet3_MB6HC.h
index 0a66ad79..c773d284 100644
--- a/src/Config/Pins_Duet3_MB6HC.h
+++ b/src/Config/Pins_Duet3_MB6HC.h
@@ -153,11 +153,20 @@ constexpr float PowerMonitorVoltageRange_v101 = (60.4 + 4.7)/4.7 * 3.3; // volt
constexpr float V12MonitorVoltageRange = (60.4 + 4.7)/4.7 * 3.3; // voltage divider ratio times the reference voltage
// 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 Pin DiagPinPre102 = PortCPin(20);
+constexpr bool DiagOnPolarityPre102 = true;
+constexpr Pin ActLedPinPre102 = NoPin;
+
+constexpr Pin DiagPin102 = PortBPin(6);
+constexpr bool DiagOnPolarity102 = false;
+constexpr Pin ActLedPin102 = PortBPin(7);
constexpr bool ActOnPolarity = false;
+// MB6HC 1.02 USB control
+constexpr Pin UsbPowerSwitchPin = PortCPin(6);
+constexpr Pin UsbModePin = PortCPin(20);
+constexpr Pin UsbDetectPin = PortCPin(19);
+
// SD cards
constexpr size_t NumSdCards = 2; // we now allow one SPI-connected SD card to be configured at boot time
constexpr Pin SdCardDetectPins[NumSdCards] = { PortAPin(29), NoPin }; // the CD pin for the second SD card is allocated using M950
@@ -176,7 +185,7 @@ constexpr uint32_t DotStarClockId = ID_QSPI;
constexpr IRQn DotStarIRQn = QSPI_IRQn;
// Ethernet
-constexpr Pin EthernetPhyInterruptPin = PortCPin(6);
+constexpr Pin EthernetPhyInterruptPinPre102 = PortCPin(6);
constexpr Pin EthernetPhyResetPin = PortDPin(11);
constexpr Pin EthernetPhyOtherPins[] = {
PortDPin(0), PortDPin(1), PortDPin(2), PortDPin(3), PortDPin(4),
diff --git a/src/Hardware/SAME70/Devices.cpp b/src/Hardware/SAME70/Devices.cpp
index 19f14226..2af3ed6a 100644
--- a/src/Hardware/SAME70/Devices.cpp
+++ b/src/Hardware/SAME70/Devices.cpp
@@ -62,7 +62,6 @@ void SdhcInit() noexcept
void EthernetInit() noexcept
{
// Initialize Ethernet pins
- pinMode(EthernetPhyInterruptPin, INPUT_PULLUP);
for (Pin p : EthernetPhyOtherPins)
{
SetPinFunction(p, EthernetPhyOtherPinsFunction);
@@ -78,10 +77,7 @@ void DeviceInit() noexcept
SdhcInit();
EthernetInit();
-#if defined(DUET3_MB6HC)
- // Set up PB4..PB5 as normal I/O, not JTAG
- matrix_set_system_io(CCFG_SYSIO_SYSIO4 | CCFG_SYSIO_SYSIO5);
-#elif defined(DUET3_MB6XD)
+#if defined(DUET3_MB6HC) || defined(DUET3_MB6XD)
# ifdef DEBUG
// Set up PB4..PB5 as normal I/O, not JTAG. Leave PB6/7 pins as SWD. STATUS and ACT LEDs will not work.
matrix_set_system_io(CCFG_SYSIO_SYSIO4 | CCFG_SYSIO_SYSIO5);
diff --git a/src/Platform/Platform.cpp b/src/Platform/Platform.cpp
index 08489c13..e82780c4 100644
--- a/src/Platform/Platform.cpp
+++ b/src/Platform/Platform.cpp
@@ -3761,6 +3761,29 @@ void Platform::ResetChannel(size_t chan) noexcept
#endif
}
+#if defined(DUET3_MB6HC)
+
+// this is safe to call before Platform has been created
+/*static*/ BoardType Platform::GetMB6HCBoardType() noexcept
+{
+ // Driver 0 direction has a pulldown resistor on v0.6 and v1.0 boards, but not on v1.01 or v1.02 boards
+ // Driver 1 has a pulldown resistor on v0.1 and v1.0 boards, however we don't support v0.1 and we don't care about the difference between v0.6 and v1.0, so we don't need to read it
+ // Driver 2 has a pulldown resistor on v1.02 only
+ pinMode(DIRECTION_PINS[2], INPUT_PULLUP);
+ pinMode(DIRECTION_PINS[0], INPUT_PULLUP);
+ delayMicroseconds(20); // give the pullup resistor time to work
+ if (digitalRead(DIRECTION_PINS[2]))
+ {
+ return (digitalRead(DIRECTION_PINS[0])) ? BoardType::Duet3_6HC_v101 : BoardType::Duet3_6HC_v06_100;
+ }
+ else
+ {
+ return BoardType::Duet3_6HC_v102;
+ }
+}
+
+#endif
+
// Set the board type. This must be called quite early, because for some builds it relies on pins not having been programmed for their intended use yet.
void Platform::SetBoardType(BoardType bt) noexcept
{
@@ -3774,21 +3797,20 @@ void Platform::SetBoardType(BoardType bt) noexcept
? BoardType::Duet3Mini_WiFi
: BoardType::Duet3Mini_Ethernet;
#elif defined(DUET3_MB6HC)
- // Driver 0 direction has a pulldown resistor on v0.6 and v1.0 boards, but not on v1.01 or v1.02 boards
- // Driver 1 has a pulldown resistor on v0.1 and v1.0 boards, however we don't support v0.1 and we don't care about the difference between v0.6 and v1.0, so we don't need to read it
- // Driver 2 has a pulldown resistor on v1.02 only
- pinMode(DIRECTION_PINS[2], INPUT_PULLUP);
- pinMode(DIRECTION_PINS[0], INPUT_PULLUP);
- delayMicroseconds(20); // give the pullup resistor time to work
- if (digitalRead(DIRECTION_PINS[2]))
+ board = GetMB6HCBoardType();
+ if (board == BoardType::Duet3_6HC_v102)
{
- board = (digitalRead(DIRECTION_PINS[0])) ? BoardType::Duet3_6HC_v101 : BoardType::Duet3_6HC_v06_100;
- powerMonitorVoltageRange = PowerMonitorVoltageRange_v101;
+ powerMonitorVoltageRange = PowerMonitorVoltageRange_v102;
+ DiagPin = DiagPin102;
+ ActLedPin = ActLedPin102;
+ DiagOnPolarity = DiagOnPolarity102;
}
else
{
- board = BoardType::Duet3_6HC_v102;
- powerMonitorVoltageRange = PowerMonitorVoltageRange_v102;
+ powerMonitorVoltageRange = PowerMonitorVoltageRange_v101;
+ DiagPin = DiagPinPre102;
+ ActLedPin = ActLedPinPre102;
+ DiagOnPolarity = DiagOnPolarityPre102;
}
driverPowerOnAdcReading = PowerVoltageToAdcReading(10.0);
driverPowerOffAdcReading = PowerVoltageToAdcReading(9.5);
@@ -4646,6 +4668,20 @@ uint32_t Platform::Random() noexcept
#endif
+void Platform::SetDiagLed(bool on) const noexcept
+{
+ digitalWrite(DiagPin, XNor(DiagOnPolarity, on));
+}
+
+#if SUPPORT_MULTICAST_DISCOVERY
+
+void Platform::InvertDiagLed() const noexcept
+{
+ digitalWrite(DiagPin, !digitalRead(DiagPin));
+}
+
+#endif
+
#if HAS_CPU_TEMP_SENSOR && SAME5x
void Platform::TemperatureCalibrationInit() noexcept
diff --git a/src/Platform/Platform.h b/src/Platform/Platform.h
index 1ed5186b..22735a98 100644
--- a/src/Platform/Platform.h
+++ b/src/Platform/Platform.h
@@ -672,7 +672,17 @@ public:
#endif
#if SUPPORT_CAN_EXPANSION
- void OnProcessingCanMessage() noexcept; // called when we start processing any CAN message except for regular messages e.g. time sync
+ void OnProcessingCanMessage() noexcept; // called when we start processing any CAN message except for regular messages e.g. time sync
+#endif
+
+#if defined(DUET3_MB6HC)
+ static BoardType GetMB6HCBoardType() noexcept; // this is safe to call before Platform has been created
+#endif
+
+ void SetDiagLed(bool on) const noexcept;
+
+#if SUPPORT_MULTICAST_DISCOVERY
+ void InvertDiagLed() const noexcept;
#endif
protected:
@@ -894,6 +904,9 @@ private:
float powerMonitorVoltageRange;
uint16_t driverPowerOnAdcReading;
uint16_t driverPowerOffAdcReading;
+ Pin DiagPin;
+ Pin ActLedPin;
+ bool DiagOnPolarity;
#endif
bool autoSaveEnabled;
diff --git a/src/Platform/Tasks.cpp b/src/Platform/Tasks.cpp
index 7d7c39e8..4d42d332 100644
--- a/src/Platform/Tasks.cpp
+++ b/src/Platform/Tasks.cpp
@@ -128,8 +128,19 @@ void *Tasks::GetNVMBuffer(const uint32_t *_ecv_array null stk) noexcept
// Application entry point
[[noreturn]] void AppMain() noexcept
{
+#if defined(DUET3_MB6HC) // for MB6HC the Status and Activity pins and polarity depend on the board version
+ const BoardType bt = Platform::GetMB6HCBoardType();
+ const Pin DiagPin = (bt == BoardType::Duet3_6HC_v102) ? DiagPin102 : DiagPinPre102;
+ const Pin ActLedPin = (bt == BoardType::Duet3_6HC_v102) ? ActLedPin102 : ActLedPinPre102;
+ const bool DiagOnPolarity = (bt == BoardType::Duet3_6HC_v102) ? DiagOnPolarity102 : DiagOnPolarityPre102;
+ if (bt == BoardType::Duet3_6HC_v102)
+ {
+ pinMode(UsbPowerSwitchPin, OUTPUT_LOW); // turn USB power off
+ pinMode(UsbModePin, OUTPUT_LOW); // USB mode = device/UFP
+ }
+#endif
pinMode(DiagPin, (DiagOnPolarity) ? OUTPUT_LOW : OUTPUT_HIGH); // set up status LED for debugging and turn it off
-#if defined(DUET3MINI) || defined(DUET3_MB6XD)
+#if defined(DUET3MINI) || defined(DUET3_MB6HC) || defined(DUET3_MB6XD)
pinMode(ActLedPin, (ActOnPolarity) ? OUTPUT_LOW : OUTPUT_HIGH); // set up activity LED and turn it off
#endif