From 0c72dc376ca78c5354054d6c9b80a286e7d2ffa5 Mon Sep 17 00:00:00 2001 From: B Date: Sat, 3 May 2025 13:20:29 -0700 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A8=20Creality=20V4.2.7=20(GD32)=20(#2?= =?UTF-8?q?7796)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/HAL/GD32_MFL/timers.cpp | 9 +++- Marlin/src/core/boards.h | 3 +- .../pins/gd32f3/pins_CREALITY_V422_GD32_MFL.h | 8 +--- .../pins/gd32f3/pins_CREALITY_V427_GD32_MFL.h | 48 +++++++++++++++++++ Marlin/src/pins/pins.h | 2 + 5 files changed, 62 insertions(+), 8 deletions(-) create mode 100644 Marlin/src/pins/gd32f3/pins_CREALITY_V427_GD32_MFL.h diff --git a/Marlin/src/HAL/GD32_MFL/timers.cpp b/Marlin/src/HAL/GD32_MFL/timers.cpp index 5b2c2de7ef..632499742c 100644 --- a/Marlin/src/HAL/GD32_MFL/timers.cpp +++ b/Marlin/src/HAL/GD32_MFL/timers.cpp @@ -92,7 +92,9 @@ bool is_temp_timer_initialized = false; // Retrieves the clock frequency of the stepper timer uint32_t GetStepperTimerClkFreq() { - return Step_Timer.getTimerClockFrequency(); + // Cache result + static uint32_t clkFreq = Step_Timer.getTimerClockFrequency(); + return clkFreq; } /** @@ -191,10 +193,12 @@ void SetTimerInterruptPriorities() { // Detect timer conflicts // ------------------------ +TERN_(HAS_TMC_SW_SERIAL, static constexpr timer::TIMER_Base timer_serial[] = {static_cast(TIMER_SERIAL)}); TERN_(SPEAKER, static constexpr timer::TIMER_Base timer_tone[] = {static_cast(TIMER_TONE)}); TERN_(HAS_SERVOS, static constexpr timer::TIMER_Base timer_servo[] = {static_cast(TIMER_SERVO)}); enum TimerPurpose { + PURPOSE_SERIAL, PURPOSE_TONE, PURPOSE_SERVO, PURPOSE_STEP, @@ -205,6 +209,9 @@ enum TimerPurpose { // Includes the timer purpose to ease debugging when evaluating at build-time // This cannot yet account for timers used for PWM output, such as for fans static constexpr struct { TimerPurpose p; int t; } timers_in_use[] = { + #if HAS_TMC_SW_SERIAL + { PURPOSE_SERIAL, timer_base_to_index(timer_serial[0]) }, // Set in variant.h + #endif #if ENABLED(SPEAKER) { PURPOSE_TONE, timer_base_to_index(timer_tone[0]) }, // Set in variant.h #endif diff --git a/Marlin/src/core/boards.h b/Marlin/src/core/boards.h index e7851d001a..32ee85daab 100644 --- a/Marlin/src/core/boards.h +++ b/Marlin/src/core/boards.h @@ -386,7 +386,7 @@ #define BOARD_CREALITY_V422 5039 // Creality v4.2.2 (STM32F103RC / STM32F103RE) ... GD32 Variant Below! #define BOARD_CREALITY_V423 5040 // Creality v4.2.3 (STM32F103RC / STM32F103RE) #define BOARD_CREALITY_V425 5041 // Creality v4.2.5 (STM32F103RC / STM32F103RE) -#define BOARD_CREALITY_V427 5042 // Creality v4.2.7 (STM32F103RC / STM32F103RE) +#define BOARD_CREALITY_V427 5042 // Creality v4.2.7 (STM32F103RC / STM32F103RE) ... GD32 Variant Below! #define BOARD_CREALITY_V4210 5043 // Creality v4.2.10 (STM32F103RC / STM32F103RE) as found in the CR-30 #define BOARD_CREALITY_V431 5044 // Creality v4.3.1 (STM32F103RC / STM32F103RE) #define BOARD_CREALITY_V431_A 5045 // Creality v4.3.1a (STM32F103RC / STM32F103RE) @@ -563,6 +563,7 @@ // #define BOARD_CREALITY_V422_GD32_MFL 7400 // Creality V4.2.2 MFL (GD32F303RE) ... STM32 Variant Above! +#define BOARD_CREALITY_V427_GD32_MFL 7401 // Creality V4.2.7 MFL (GD32F303RE) ... STM32 Variant Above! // // Raspberry Pi diff --git a/Marlin/src/pins/gd32f3/pins_CREALITY_V422_GD32_MFL.h b/Marlin/src/pins/gd32f3/pins_CREALITY_V422_GD32_MFL.h index 70b171eef9..8b5cd90b15 100644 --- a/Marlin/src/pins/gd32f3/pins_CREALITY_V422_GD32_MFL.h +++ b/Marlin/src/pins/gd32f3/pins_CREALITY_V422_GD32_MFL.h @@ -27,11 +27,7 @@ #define ALLOW_GD32F3 -#ifndef BOARD_INFO_NAME - #define BOARD_INFO_NAME "Creality V4.2.2 MFL" -#endif -#ifndef DEFAULT_MACHINE_NAME - #define DEFAULT_MACHINE_NAME "Ender-3 MFL" -#endif +#define BOARD_INFO_NAME "Creality V4.2.2 MFL" +#define DEFAULT_MACHINE_NAME "Ender-3 MFL" #include "../stm32f1/pins_CREALITY_V4.h" diff --git a/Marlin/src/pins/gd32f3/pins_CREALITY_V427_GD32_MFL.h b/Marlin/src/pins/gd32f3/pins_CREALITY_V427_GD32_MFL.h new file mode 100644 index 0000000000..afa1b0620f --- /dev/null +++ b/Marlin/src/pins/gd32f3/pins_CREALITY_V427_GD32_MFL.h @@ -0,0 +1,48 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2025 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#pragma once + +/** + * Creality MFL GD32 V4.2.7 (GD32F303RE) board pin assignments + */ + +#define ALLOW_GD32F3 + +#define BOARD_INFO_NAME "Creality V4.2.7 MFL" +#define DEFAULT_MACHINE_NAME "Creality3D MFL" + +// +// Steppers +// +#define X_STEP_PIN PB9 +#define X_DIR_PIN PC2 + +#define Y_STEP_PIN PB7 +#define Y_DIR_PIN PB8 + +#define Z_STEP_PIN PB5 +#define Z_DIR_PIN PB6 + +#define E0_STEP_PIN PB3 +#define E0_DIR_PIN PB4 + +#include "../stm32f1/pins_CREALITY_V4.h" diff --git a/Marlin/src/pins/pins.h b/Marlin/src/pins/pins.h index 8c974cce48..7b2daae1ea 100644 --- a/Marlin/src/pins/pins.h +++ b/Marlin/src/pins/pins.h @@ -977,6 +977,8 @@ #elif MB(CREALITY_V422_GD32_MFL) #include "gd32f3/pins_CREALITY_V422_GD32_MFL.h" // GD32F303RE env:GD32F303RE_creality_mfl +#elif MB(CREALITY_V427_GD32_MFL) + #include "gd32f3/pins_CREALITY_V427_GD32_MFL.h" // GD32F303RE env:GD32F303RE_creality_mfl // // Raspberry Pi RP2040