From d167af4c388df18601380a7edcd5bd6d221458c0 Mon Sep 17 00:00:00 2001 From: Tanguy Pruvot Date: Thu, 25 Feb 2021 11:35:18 +0100 Subject: [PATCH] Add BOARD_PREINIT (for Longer3D open drain pins) (#21159) --- Marlin/src/MarlinCore.cpp | 3 +++ Marlin/src/module/temperature.cpp | 6 +++--- Marlin/src/pins/stm32f1/pins_LONGER3D_LK.h | 13 +++++++++++-- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/Marlin/src/MarlinCore.cpp b/Marlin/src/MarlinCore.cpp index 8aa6cdd6c..d523882d4 100644 --- a/Marlin/src/MarlinCore.cpp +++ b/Marlin/src/MarlinCore.cpp @@ -870,6 +870,9 @@ inline void tmc_standby_setup() { * • Max7219 */ void setup() { + #ifdef BOARD_PREINIT + BOARD_PREINIT(); // Low-level init (before serial init) + #endif tmc_standby_setup(); // TMC Low Power Standby pins must be set early or they're not usable diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index 58b0a965c..a220386b9 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -1793,7 +1793,7 @@ void Temperature::updateTemperaturesFromRawValues() { #endif // Init fans according to whether they're native PWM or Software PWM -#ifdef ALFAWISE_UX0 +#ifdef BOARD_OPENDRAIN_MOSFETS #define _INIT_SOFT_FAN(P) OUT_WRITE_OD(P, FAN_INVERTING ? LOW : HIGH) #else #define _INIT_SOFT_FAN(P) OUT_WRITE(P, FAN_INVERTING ? LOW : HIGH) @@ -1886,7 +1886,7 @@ void Temperature::init() { #endif #if HAS_HEATER_0 - #ifdef ALFAWISE_UX0 + #ifdef BOARD_OPENDRAIN_MOSFETS OUT_WRITE_OD(HEATER_0_PIN, HEATER_0_INVERTING); #else OUT_WRITE(HEATER_0_PIN, HEATER_0_INVERTING); @@ -1916,7 +1916,7 @@ void Temperature::init() { #endif #if HAS_HEATED_BED - #ifdef ALFAWISE_UX0 + #ifdef BOARD_OPENDRAIN_MOSFETS OUT_WRITE_OD(HEATER_BED_PIN, HEATER_BED_INVERTING); #else OUT_WRITE(HEATER_BED_PIN, HEATER_BED_INVERTING); diff --git a/Marlin/src/pins/stm32f1/pins_LONGER3D_LK.h b/Marlin/src/pins/stm32f1/pins_LONGER3D_LK.h index 33f995dca..fa708b248 100644 --- a/Marlin/src/pins/stm32f1/pins_LONGER3D_LK.h +++ b/Marlin/src/pins/stm32f1/pins_LONGER3D_LK.h @@ -29,7 +29,6 @@ #endif #define BOARD_INFO_NAME "Longer3D" -#define ALFAWISE_UX0 // Common to all Longer3D STM32F1 boards (used for Open drain mosfets) #define BOARD_NO_NATIVE_USB @@ -92,10 +91,20 @@ #define FAN_MAX_PWM 255 //#define BEEPER_PIN PD13 // pin 60 (Servo PWM output 5V/GND on Board V0G+) made for BL-Touch sensor - // Can drive a PC Buzzer, if connected between PWM and 5V pins + // Can drive a PC Buzzer, if connected between PWM and 5V pins #define LED_PIN PC2 // pin 17 +// Longer3D board mosfets are passing by default +// Avoid nozzle heat and fan start before serial init +#define BOARD_OPENDRAIN_MOSFETS + +#define BOARD_PREINIT() { \ + OUT_WRITE_OD(HEATER_0_PIN, 0); \ + OUT_WRITE_OD(HEATER_BED_PIN, 0); \ + OUT_WRITE_OD(FAN_PIN, 0); \ +} + // // PWM for a servo probe // Other servo devices are not supported on this board!