From baa20d9ea2a3894d171531445fa279bc83f69390 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Wed, 22 Oct 2025 15:04:42 -0500 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=A8=20Misc.=20HAL=20types,=20planner?= =?UTF-8?q?=20sq,=20etc.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/HAL/GD32_MFL/HAL.cpp | 9 ++++-- Marlin/src/HAL/RP2040/HAL.cpp | 2 +- Marlin/src/HAL/STM32/HAL.cpp | 2 +- .../src/HAL/STM32F1/eeprom/eeprom_flash.cpp | 14 +++++----- Marlin/src/core/types.h | 2 +- Marlin/src/feature/babystep.cpp | 2 +- Marlin/src/feature/mmu3/mmu3_marlin1.cpp | 28 ++++--------------- Marlin/src/module/planner.cpp | 2 +- 8 files changed, 24 insertions(+), 37 deletions(-) diff --git a/Marlin/src/HAL/GD32_MFL/HAL.cpp b/Marlin/src/HAL/GD32_MFL/HAL.cpp index 460ed52297..9ba20784f0 100644 --- a/Marlin/src/HAL/GD32_MFL/HAL.cpp +++ b/Marlin/src/HAL/GD32_MFL/HAL.cpp @@ -53,12 +53,15 @@ uint16_t MarlinHAL::adc_result; // Initializes the Marlin HAL void MarlinHAL::init() { + // Ensure F_CPU is a constant expression. + // If the compiler breaks here, it means that delay code that should compute at compile time will not work. + // So better safe than sorry here. constexpr unsigned int cpuFreq = F_CPU; UNUSED(cpuFreq); -#if PIN_EXISTS(LED) - OUT_WRITE(LED_PIN, LOW); -#endif + #if PIN_EXISTS(LED) + OUT_WRITE(LED_PIN, LOW); + #endif SetTimerInterruptPriorities(); diff --git a/Marlin/src/HAL/RP2040/HAL.cpp b/Marlin/src/HAL/RP2040/HAL.cpp index 1b519e4004..e8d0eea7cd 100644 --- a/Marlin/src/HAL/RP2040/HAL.cpp +++ b/Marlin/src/HAL/RP2040/HAL.cpp @@ -56,7 +56,7 @@ void MarlinHAL::init() { // Ensure F_CPU is a constant expression. // If the compiler breaks here, it means that delay code that should compute at compile time will not work. // So better safe than sorry here. - constexpr int cpuFreq = F_CPU; + constexpr unsigned int cpuFreq = F_CPU; UNUSED(cpuFreq); #if HAS_MEDIA && DISABLED(ONBOARD_SDIO) && PIN_EXISTS(SD_SS) diff --git a/Marlin/src/HAL/STM32/HAL.cpp b/Marlin/src/HAL/STM32/HAL.cpp index bdccdd546d..b2ae10d0f1 100644 --- a/Marlin/src/HAL/STM32/HAL.cpp +++ b/Marlin/src/HAL/STM32/HAL.cpp @@ -66,7 +66,7 @@ void MarlinHAL::init() { // Ensure F_CPU is a constant expression. // If the compiler breaks here, it means that delay code that should compute at compile time will not work. // So better safe than sorry here. - constexpr int cpuFreq = F_CPU; + constexpr unsigned int cpuFreq = F_CPU; UNUSED(cpuFreq); #if HAS_MEDIA && DISABLED(ONBOARD_SDIO) && PIN_EXISTS(SD_SS) diff --git a/Marlin/src/HAL/STM32F1/eeprom/eeprom_flash.cpp b/Marlin/src/HAL/STM32F1/eeprom/eeprom_flash.cpp index 03326db80e..2292c02203 100644 --- a/Marlin/src/HAL/STM32F1/eeprom/eeprom_flash.cpp +++ b/Marlin/src/HAL/STM32F1/eeprom/eeprom_flash.cpp @@ -47,14 +47,14 @@ static uint8_t ram_eeprom[MARLIN_EEPROM_SIZE] __attribute__((aligned(4))) = {0}; static bool eeprom_dirty = false; bool PersistentStore::access_start() { - const uint32_t *source = reinterpret_cast(EEPROM_PAGE0_BASE); - uint32_t *destination = reinterpret_cast(ram_eeprom); + const uint32_t *src = reinterpret_cast(EEPROM_PAGE0_BASE); + uint32_t *dst = reinterpret_cast(ram_eeprom); static_assert(0 == (MARLIN_EEPROM_SIZE) % 4, "MARLIN_EEPROM_SIZE is corrupted. (Must be a multiple of 4.)"); // Ensure copying as uint32_t is safe constexpr size_t eeprom_size_u32 = (MARLIN_EEPROM_SIZE) / 4; - for (size_t i = 0; i < eeprom_size_u32; ++i, ++destination, ++source) - *destination = *source; + for (size_t i = 0; i < eeprom_size_u32; ++i, ++dst, ++src) + *dst = *src; eeprom_dirty = false; return true; @@ -80,9 +80,9 @@ bool PersistentStore::access_finish() { status = FLASH_ErasePage(EEPROM_PAGE1_BASE); if (status != FLASH_COMPLETE) ACCESS_FINISHED(true); - const uint16_t *source = reinterpret_cast(ram_eeprom); - for (size_t i = 0; i < long(MARLIN_EEPROM_SIZE); i += 2, ++source) { - if (FLASH_ProgramHalfWord(EEPROM_PAGE0_BASE + i, *source) != FLASH_COMPLETE) + const uint16_t *src = reinterpret_cast(ram_eeprom); + for (size_t i = 0; i < long(MARLIN_EEPROM_SIZE); i += 2, ++src) { + if (FLASH_ProgramHalfWord(EEPROM_PAGE0_BASE + i, *src) != FLASH_COMPLETE) ACCESS_FINISHED(false); } diff --git a/Marlin/src/core/types.h b/Marlin/src/core/types.h index fab32dea9b..ab3820273a 100644 --- a/Marlin/src/core/types.h +++ b/Marlin/src/core/types.h @@ -492,7 +492,7 @@ typedef ab_float_t ab_pos_t; typedef abc_float_t abc_pos_t; typedef abce_float_t abce_pos_t; -// External conversion methods +// External conversion methods (motion.h) void toLogical(xy_pos_t &raw); void toLogical(xyz_pos_t &raw); void toLogical(xyze_pos_t &raw); diff --git a/Marlin/src/feature/babystep.cpp b/Marlin/src/feature/babystep.cpp index 91b3c7f403..bceb73ec78 100644 --- a/Marlin/src/feature/babystep.cpp +++ b/Marlin/src/feature/babystep.cpp @@ -26,7 +26,7 @@ #include "babystep.h" #include "../MarlinCore.h" -#include "../module/motion.h" // for axes_should_home(), BABYSTEP_ALLOWED +#include "../module/motion.h" // for axis_should_home(), BABYSTEP_ALLOWED #include "../module/planner.h" // for axis_steps_per_mm[] #include "../module/stepper.h" diff --git a/Marlin/src/feature/mmu3/mmu3_marlin1.cpp b/Marlin/src/feature/mmu3/mmu3_marlin1.cpp index 6365481248..2c4effe106 100644 --- a/Marlin/src/feature/mmu3/mmu3_marlin1.cpp +++ b/Marlin/src/feature/mmu3/mmu3_marlin1.cpp @@ -151,34 +151,18 @@ namespace MMU3 { #endif } - int16_t thermal_degTargetHotend() { - return thermalManager.degTargetHotend(0); - } - - int16_t thermal_degHotend() { - return thermalManager.degHotend(0); - } - - void thermal_setExtrudeMintemp(int16_t t) { - thermalManager.extrude_min_temp = t; - } - - void thermal_setTargetHotend(int16_t t) { - thermalManager.setTargetHotend(t, 0); - } + int16_t thermal_degTargetHotend() { return thermalManager.degTargetHotend(0); } + int16_t thermal_degHotend() { return thermalManager.degHotend(0); } + void thermal_setExtrudeMintemp(int16_t t) { thermalManager.extrude_min_temp = t; } + void thermal_setTargetHotend(int16_t t) { thermalManager.setTargetHotend(t, 0); } void safe_delay_keep_alive(uint16_t t) { idle(true); safe_delay(t); } - void Enable_E0() { - stepper.enable_extruder(TERN_(HAS_EXTRUDERS, 0)); - } - - void Disable_E0() { - stepper.disable_extruder(TERN_(HAS_EXTRUDERS, 0)); - } + void Enable_E0() { stepper.enable_extruder(TERN_(HAS_EXTRUDERS, 0)); } + void Disable_E0() { stepper.disable_extruder(TERN_(HAS_EXTRUDERS, 0)); } bool xy_are_trusted() { return axis_is_trusted(X_AXIS) && axis_is_trusted(Y_AXIS); diff --git a/Marlin/src/module/planner.cpp b/Marlin/src/module/planner.cpp index 99df08205d..6acd2a0251 100644 --- a/Marlin/src/module/planner.cpp +++ b/Marlin/src/module/planner.cpp @@ -3262,7 +3262,7 @@ void Planner::refresh_positioning() { #if ENABLED(EDITABLE_STEPS_PER_UNIT) LOOP_DISTINCT_AXES(i) mm_per_step[i] = 1.0f / settings.axis_steps_per_mm[i]; #if ALL(NONLINEAR_EXTRUSION, SMOOTH_LIN_ADVANCE) - stepper.ne.q30.A = _BV32(30) * (stepper.ne.settings.coeff.A * mm_per_step[E_AXIS_N(0)] * mm_per_step[E_AXIS_N(0)]); + stepper.ne.q30.A = _BV32(30) * (stepper.ne.settings.coeff.A * sq(mm_per_step[E_AXIS_N(0)])); stepper.ne.q30.B = _BV32(30) * (stepper.ne.settings.coeff.B * mm_per_step[E_AXIS_N(0)]); #endif #endif