diff --git a/Marlin/src/HAL/HAL_AVR/HAL.cpp b/Marlin/src/HAL/HAL_AVR/HAL.cpp
index 58ee84cbdf4e..e69455976167 100644
--- a/Marlin/src/HAL/HAL_AVR/HAL.cpp
+++ b/Marlin/src/HAL/HAL_AVR/HAL.cpp
@@ -20,13 +20,6 @@
****************************************************************************/
-/**
- * Description: HAL for AVR
- *
- * For __AVR__
- */
-
-
#ifdef __AVR__
// --------------------------------------------------------------------------
diff --git a/Marlin/src/HAL/HAL_AVR/HAL.h b/Marlin/src/HAL/HAL_AVR/HAL.h
index 37fe65ff8411..b887e6df27b0 100644
--- a/Marlin/src/HAL/HAL_AVR/HAL.h
+++ b/Marlin/src/HAL/HAL_AVR/HAL.h
@@ -19,13 +19,6 @@
along with this program. If not, see .
****************************************************************************/
-/**
- * Description: HAL for AVR
- *
- * For __AVR__
- */
-
-
#ifndef _HAL_AVR_H_
#define _HAL_AVR_H_
@@ -115,10 +108,6 @@ extern "C" {
int freeMemory(void);
}
-// eeprom
-//void eeprom_write_byte(unsigned char *pos, unsigned char value);
-//unsigned char eeprom_read_byte(unsigned char *pos);
-
// timers
#define HAL_TIMER_RATE ((F_CPU) / 8) // i.e., 2MHz or 2.5MHz
@@ -126,20 +115,15 @@ extern "C" {
#define TEMP_TIMER_NUM 0
#define PULSE_TIMER_NUM STEP_TIMER_NUM
-#define HAL_STEPPER_TIMER_RATE HAL_TIMER_RATE
-#define HAL_TICKS_PER_US ((HAL_STEPPER_TIMER_RATE) / 1000000) // Cannot be of type double
-#define STEPPER_TIMER_PRESCALE 8
-#define STEP_TIMER_MIN_INTERVAL 8 // minimum time in µs between stepper interrupts
-
#define TEMP_TIMER_FREQUENCY ((F_CPU) / 64.0 / 256.0)
-#define TIMER_OCR_1 OCR1A
-#define TIMER_COUNTER_1 TCNT1
-
-#define TIMER_OCR_0 OCR0A
-#define TIMER_COUNTER_0 TCNT0
+#define STEPPER_TIMER_RATE HAL_TIMER_RATE
+#define STEPPER_TIMER_PRESCALE 8
+#define STEPPER_TIMER_TICKS_PER_US ((STEPPER_TIMER_RATE) / 1000000) // Cannot be of type double
-#define PULSE_TIMER_PRESCALE STEPPER_TIMER_PRESCALE
+#define PULSE_TIMER_RATE STEPPER_TIMER_RATE // frequency of pulse timer
+#define PULSE_TIMER_PRESCALE STEPPER_TIMER_PRESCALE
+#define PULSE_TIMER_TICKS_PER_US STEPPER_TIMER_TICKS_PER_US
#define ENABLE_STEPPER_DRIVER_INTERRUPT() SBI(TIMSK1, OCIE1A)
#define DISABLE_STEPPER_DRIVER_INTERRUPT() CBI(TIMSK1, OCIE1A)
@@ -180,6 +164,12 @@ FORCE_INLINE void HAL_timer_start(const uint8_t timer_num, const uint32_t freque
}
}
+#define TIMER_OCR_1 OCR1A
+#define TIMER_COUNTER_1 TCNT1
+
+#define TIMER_OCR_0 OCR0A
+#define TIMER_COUNTER_0 TCNT0
+
#define _CAT(a, ...) a ## __VA_ARGS__
#define HAL_timer_set_compare(timer, compare) (_CAT(TIMER_OCR_, timer) = compare)
#define HAL_timer_restrain(timer, interval_ticks) NOLESS(_CAT(TIMER_OCR_, timer), _CAT(TIMER_COUNTER_, timer) + interval_ticks)
diff --git a/Marlin/src/HAL/HAL_DUE/HAL_timers_Due.h b/Marlin/src/HAL/HAL_DUE/HAL_timers_Due.h
index ca762f689d88..871ef995e6d4 100644
--- a/Marlin/src/HAL/HAL_DUE/HAL_timers_Due.h
+++ b/Marlin/src/HAL/HAL_DUE/HAL_timers_Due.h
@@ -43,21 +43,22 @@
typedef uint32_t hal_timer_t;
#define HAL_TIMER_TYPE_MAX 0xFFFFFFFF
+#define HAL_TIMER_RATE ((F_CPU) / 2) // frequency of timers peripherals
+
#define STEP_TIMER_NUM 3 // index of timer to use for stepper
#define TEMP_TIMER_NUM 4 // index of timer to use for temperature
+#define PULSE_TIMER_NUM STEP_TIMER_NUM
#define TONE_TIMER_NUM 6 // index of timer to use for beeper tones
-#define HAL_TIMER_RATE ((F_CPU) / 2) // frequency of timers peripherals
-
-#define HAL_STEPPER_TIMER_RATE HAL_TIMER_RATE // frequency of stepper timer (HAL_TIMER_RATE / STEPPER_TIMER_PRESCALE)
-#define HAL_TICKS_PER_US ((HAL_STEPPER_TIMER_RATE) / 1000000) // stepper timer ticks per µs
-#define STEPPER_TIMER_PRESCALE (CYCLES_PER_MICROSECOND / HAL_TICKS_PER_US)
-#define STEP_TIMER_MIN_INTERVAL 8 // minimum time in µs between stepper interrupts
-
#define TEMP_TIMER_FREQUENCY 1000 // temperature interrupt frequency
-#define PULSE_TIMER_NUM STEP_TIMER_NUM
-#define PULSE_TIMER_PRESCALE STEPPER_TIMER_PRESCALE
+#define STEPPER_TIMER_RATE HAL_TIMER_RATE // frequency of stepper timer (HAL_TIMER_RATE / STEPPER_TIMER_PRESCALE)
+#define STEPPER_TIMER_TICKS_PER_US ((STEPPER_TIMER_RATE) / 1000000) // stepper timer ticks per µs
+#define STEPPER_TIMER_PRESCALE (CYCLES_PER_MICROSECOND / STEPPER_TIMER_TICKS_PER_US)
+
+#define PULSE_TIMER_RATE STEPPER_TIMER_RATE // frequency of pulse timer
+#define PULSE_TIMER_PRESCALE STEPPER_TIMER_PRESCALE
+#define PULSE_TIMER_TICKS_PER_US STEPPER_TIMER_TICKS_PER_US
#define ENABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_enable_interrupt(STEP_TIMER_NUM)
#define DISABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_disable_interrupt(STEP_TIMER_NUM)
diff --git a/Marlin/src/HAL/HAL_LPC1768/HAL_timers.cpp b/Marlin/src/HAL/HAL_LPC1768/HAL_timers.cpp
index 5e437bbe8b96..3714fe1a3998 100644
--- a/Marlin/src/HAL/HAL_LPC1768/HAL_timers.cpp
+++ b/Marlin/src/HAL/HAL_LPC1768/HAL_timers.cpp
@@ -33,7 +33,7 @@
void HAL_timer_init(void) {
SBI(LPC_SC->PCONP, SBIT_TIMER0); // Power ON Timer 0
- LPC_TIM0->PR = (HAL_TIMER_RATE) / (HAL_STEPPER_TIMER_RATE) - 1; // Use prescaler to set frequency if needed
+ LPC_TIM0->PR = (HAL_TIMER_RATE) / (STEPPER_TIMER_RATE) - 1; // Use prescaler to set frequency if needed
SBI(LPC_SC->PCONP, SBIT_TIMER1); // Power ON Timer 1
LPC_TIM1->PR = (HAL_TIMER_RATE) / 1000000 - 1;
@@ -43,7 +43,7 @@ void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency) {
switch (timer_num) {
case 0:
LPC_TIM0->MCR = _BV(SBIT_MR0I) | _BV(SBIT_MR0R); // Match on MR0, reset on MR0, interrupts when NVIC enables them
- LPC_TIM0->MR0 = uint32_t(HAL_STEPPER_TIMER_RATE) / frequency; // Match value (period) to set frequency
+ LPC_TIM0->MR0 = uint32_t(STEPPER_TIMER_RATE) / frequency; // Match value (period) to set frequency
LPC_TIM0->TCR = _BV(SBIT_CNTEN); // Counter Enable
NVIC_SetPriority(TIMER0_IRQn, NVIC_EncodePriority(0, 1, 0));
@@ -52,7 +52,7 @@ void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency) {
case 1:
LPC_TIM1->MCR = _BV(SBIT_MR0I) | _BV(SBIT_MR0R); // Match on MR0, reset on MR0, interrupts when NVIC enables them
- LPC_TIM1->MR0 = uint32_t(HAL_TEMP_TIMER_RATE) / frequency;
+ LPC_TIM1->MR0 = uint32_t(TEMP_TIMER_RATE) / frequency;
LPC_TIM1->TCR = _BV(SBIT_CNTEN); // Counter Enable
NVIC_SetPriority(TIMER1_IRQn, NVIC_EncodePriority(0, 2, 0));
diff --git a/Marlin/src/HAL/HAL_LPC1768/HAL_timers.h b/Marlin/src/HAL/HAL_LPC1768/HAL_timers.h
index 72b19b9fa9a9..2113335385b9 100644
--- a/Marlin/src/HAL/HAL_LPC1768/HAL_timers.h
+++ b/Marlin/src/HAL/HAL_LPC1768/HAL_timers.h
@@ -66,22 +66,23 @@
typedef uint32_t hal_timer_t;
#define HAL_TIMER_TYPE_MAX 0xFFFFFFFF
+#define HAL_TIMER_RATE ((SystemCoreClock) / 4) // frequency of timers peripherals
+
#define STEP_TIMER_NUM 0 // Timer Index for Stepper
#define TEMP_TIMER_NUM 1 // Timer Index for Temperature
#define PULSE_TIMER_NUM STEP_TIMER_NUM
#define PWM_TIMER_NUM 3 // Timer Index for PWM
-#define HAL_TIMER_RATE ((SystemCoreClock) / 4) // frequency of timers peripherals
-#define HAL_STEPPER_TIMER_RATE HAL_TIMER_RATE // frequency of stepper timer (HAL_TIMER_RATE / STEPPER_TIMER_PRESCALE)
-#define HAL_TICKS_PER_US ((HAL_STEPPER_TIMER_RATE) / 1000000) // stepper timer ticks per µs
-#define STEPPER_TIMER_PRESCALE (CYCLES_PER_MICROSECOND / HAL_TICKS_PER_US)
-
-#define STEP_TIMER_MIN_INTERVAL 8 // minimum time in µs between stepper interrupts
-
-#define HAL_TEMP_TIMER_RATE 1000000
+#define TEMP_TIMER_RATE 1000000
#define TEMP_TIMER_FREQUENCY 1000 // temperature interrupt frequency
-#define PULSE_TIMER_PRESCALE STEPPER_TIMER_PRESCALE
+#define STEPPER_TIMER_RATE HAL_TIMER_RATE // frequency of stepper timer (HAL_TIMER_RATE / STEPPER_TIMER_PRESCALE)
+#define STEPPER_TIMER_TICKS_PER_US ((STEPPER_TIMER_RATE) / 1000000) // stepper timer ticks per µs
+#define STEPPER_TIMER_PRESCALE (CYCLES_PER_MICROSECOND / STEPPER_TIMER_TICKS_PER_US)
+
+#define PULSE_TIMER_RATE STEPPER_TIMER_RATE // frequency of pulse timer
+#define PULSE_TIMER_PRESCALE STEPPER_TIMER_PRESCALE
+#define PULSE_TIMER_TICKS_PER_US STEPPER_TIMER_TICKS_PER_US
#define ENABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_enable_interrupt(STEP_TIMER_NUM)
#define DISABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_disable_interrupt(STEP_TIMER_NUM)
diff --git a/Marlin/src/HAL/HAL_STM32F1/HAL_spi_Stm32f1.cpp b/Marlin/src/HAL/HAL_STM32F1/HAL_spi_Stm32f1.cpp
index 488773d9a4b4..59835829a783 100644
--- a/Marlin/src/HAL/HAL_STM32F1/HAL_spi_Stm32f1.cpp
+++ b/Marlin/src/HAL/HAL_STM32F1/HAL_spi_Stm32f1.cpp
@@ -54,6 +54,7 @@ static SPISettings spiConfig;
// --------------------------------------------------------------------------
#if ENABLED(SOFTWARE_SPI)
+
// --------------------------------------------------------------------------
// Software SPI
// --------------------------------------------------------------------------
@@ -95,14 +96,13 @@ void spiBegin() {
void spiInit(uint8_t spiRate) {
uint8_t clock;
switch (spiRate) {
- case SPI_FULL_SPEED: clock = SPI_CLOCK_DIV2 ; break;
- case SPI_HALF_SPEED: clock = SPI_CLOCK_DIV4 ; break;
- case SPI_QUARTER_SPEED: clock = SPI_CLOCK_DIV8 ; break;
- case SPI_EIGHTH_SPEED: clock = SPI_CLOCK_DIV16; break;
- case SPI_SPEED_5: clock = SPI_CLOCK_DIV32; break;
- case SPI_SPEED_6: clock = SPI_CLOCK_DIV64; break;
- default:
- clock = SPI_CLOCK_DIV2; // Default from the SPI library
+ case SPI_FULL_SPEED: clock = SPI_CLOCK_DIV2 ; break;
+ case SPI_HALF_SPEED: clock = SPI_CLOCK_DIV4 ; break;
+ case SPI_QUARTER_SPEED: clock = SPI_CLOCK_DIV8 ; break;
+ case SPI_EIGHTH_SPEED: clock = SPI_CLOCK_DIV16; break;
+ case SPI_SPEED_5: clock = SPI_CLOCK_DIV32; break;
+ case SPI_SPEED_6: clock = SPI_CLOCK_DIV64; break;
+ default: clock = SPI_CLOCK_DIV2; // Default from the SPI library
}
spiConfig = SPISettings(clock, MSBFIRST, SPI_MODE0);
SPI.begin();
@@ -168,7 +168,6 @@ void spiSendBlock(uint8_t token, const uint8_t* buf) {
/** Begin SPI transaction, set clock, bit order, data mode */
void spiBeginTransaction(uint32_t spiClock, uint8_t bitOrder, uint8_t dataMode) {
spiConfig = SPISettings(spiClock, (BitOrder)bitOrder, dataMode);
-
SPI.beginTransaction(spiConfig);
}
diff --git a/Marlin/src/HAL/HAL_STM32F1/HAL_timers_Stm32f1.cpp b/Marlin/src/HAL/HAL_STM32F1/HAL_timers_Stm32f1.cpp
index 41e4a6c3c76b..5c9f5e893e7d 100644
--- a/Marlin/src/HAL/HAL_STM32F1/HAL_timers_Stm32f1.cpp
+++ b/Marlin/src/HAL/HAL_STM32F1/HAL_timers_Stm32f1.cpp
@@ -121,7 +121,7 @@ void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency) {
timer_set_count(STEP_TIMER_DEV, 0);
timer_set_prescaler(STEP_TIMER_DEV, (uint16)(STEPPER_TIMER_PRESCALE - 1));
timer_set_reload(STEP_TIMER_DEV, 0xFFFF);
- timer_set_compare(STEP_TIMER_DEV, STEP_TIMER_CHAN, MIN(HAL_TIMER_TYPE_MAX, (HAL_STEPPER_TIMER_RATE / frequency)));
+ timer_set_compare(STEP_TIMER_DEV, STEP_TIMER_CHAN, MIN(HAL_TIMER_TYPE_MAX, (STEPPER_TIMER_RATE / frequency)));
timer_attach_interrupt(STEP_TIMER_DEV, STEP_TIMER_CHAN, stepTC_Handler);
nvic_irq_set_priority(irq_num, 1);
timer_generate_update(STEP_TIMER_DEV);
diff --git a/Marlin/src/HAL/HAL_STM32F1/HAL_timers_Stm32f1.h b/Marlin/src/HAL/HAL_STM32F1/HAL_timers_Stm32f1.h
index 34b32337bcc7..132cf4d22fb2 100644
--- a/Marlin/src/HAL/HAL_STM32F1/HAL_timers_Stm32f1.h
+++ b/Marlin/src/HAL/HAL_STM32F1/HAL_timers_Stm32f1.h
@@ -47,37 +47,34 @@
typedef uint16_t hal_timer_t;
#define HAL_TIMER_TYPE_MAX 0xFFFF
+#define HAL_TIMER_RATE (F_CPU) // frequency of timers peripherals
+
+#define STEP_TIMER_CHAN 1 // Channel of the timer to use for compare and interrupts
+#define TEMP_TIMER_CHAN 1 // Channel of the timer to use for compare and interrupts
+
#if defined(MCU_STM32F103CB) || defined(MCU_STM32F103C8)
#define STEP_TIMER_NUM 4 // For C8/CB boards, use timer 4
#else
#define STEP_TIMER_NUM 5 // for other boards, five is fine.
#endif
-
-#define STEP_TIMER_CHAN 1 // Channel of the timer to use for compare and interrupts
#define TEMP_TIMER_NUM 2 // index of timer to use for temperature
-#define TEMP_TIMER_CHAN 1 // Channel of the timer to use for compare and interrupts
#define PULSE_TIMER_NUM STEP_TIMER_NUM
-timer_dev* get_timer_dev(int number);
-
-#define TIMER_DEV(num) get_timer_dev(num)
-
-#define STEP_TIMER_DEV TIMER_DEV(STEP_TIMER_NUM)
-#define TEMP_TIMER_DEV TIMER_DEV(TEMP_TIMER_NUM)
-
-//STM32_HAVE_TIMER(n);
+#define TEMP_TIMER_PRESCALE 1000 // prescaler for setting Temp timer, 72Khz
+#define TEMP_TIMER_FREQUENCY 1000 // temperature interrupt frequency
-#define HAL_TIMER_RATE (F_CPU) // frequency of timers peripherals
#define STEPPER_TIMER_PRESCALE 18 // prescaler for setting stepper timer, 4Mhz
-#define HAL_STEPPER_TIMER_RATE (HAL_TIMER_RATE / STEPPER_TIMER_PRESCALE) // frequency of stepper timer
-#define HAL_TICKS_PER_US ((HAL_STEPPER_TIMER_RATE) / 1000000) // stepper timer ticks per µs
-
-#define PULSE_TIMER_PRESCALE STEPPER_TIMER_PRESCALE
+#define STEPPER_TIMER_RATE (HAL_TIMER_RATE / STEPPER_TIMER_PRESCALE) // frequency of stepper timer
+#define STEPPER_TIMER_TICKS_PER_US ((STEPPER_TIMER_RATE) / 1000000) // stepper timer ticks per µs
-#define TEMP_TIMER_PRESCALE 1000 // prescaler for setting Temp timer, 72Khz
-#define TEMP_TIMER_FREQUENCY 1000 // temperature interrupt frequency
+#define PULSE_TIMER_RATE STEPPER_TIMER_RATE // frequency of pulse timer
+#define PULSE_TIMER_PRESCALE STEPPER_TIMER_PRESCALE
+#define PULSE_TIMER_TICKS_PER_US STEPPER_TIMER_TICKS_PER_US
-#define STEP_TIMER_MIN_INTERVAL 8 // minimum time in µs between stepper interrupts
+timer_dev* get_timer_dev(int number);
+#define TIMER_DEV(num) get_timer_dev(num)
+#define STEP_TIMER_DEV TIMER_DEV(STEP_TIMER_NUM)
+#define TEMP_TIMER_DEV TIMER_DEV(TEMP_TIMER_NUM)
#define ENABLE_STEPPER_DRIVER_INTERRUPT() timer_enable_irq(STEP_TIMER_DEV, STEP_TIMER_CHAN)
#define DISABLE_STEPPER_DRIVER_INTERRUPT() timer_disable_irq(STEP_TIMER_DEV, STEP_TIMER_CHAN)
diff --git a/Marlin/src/HAL/HAL_STM32F1/endstop_interrupts.h b/Marlin/src/HAL/HAL_STM32F1/endstop_interrupts.h
index 3d64e541d082..c2a07a7cf1f2 100644
--- a/Marlin/src/HAL/HAL_STM32F1/endstop_interrupts.h
+++ b/Marlin/src/HAL/HAL_STM32F1/endstop_interrupts.h
@@ -57,39 +57,30 @@ void endstop_ISR(void) { endstops.check_possible_change(); }
void setup_endstop_interrupts(void) {
#if HAS_X_MAX
attachInterrupt(X_MAX_PIN, endstop_ISR, CHANGE); // assign it
- SET_INPUT(X_MAX_PIN);
#endif
#if HAS_X_MIN
attachInterrupt(X_MIN_PIN, endstop_ISR, CHANGE);
- SET_INPUT(X_MIN_PIN);
#endif
#if HAS_Y_MAX
attachInterrupt(Y_MAX_PIN, endstop_ISR, CHANGE);
- SET_INPUT(Y_MAX_PIN);
#endif
#if HAS_Y_MIN
attachInterrupt(Y_MIN_PIN, endstop_ISR, CHANGE);
- SET_INPUT(Y_MIN_PIN);
#endif
#if HAS_Z_MAX
attachInterrupt(Z_MAX_PIN, endstop_ISR, CHANGE);
- SET_INPUT(Z_MAX_PIN);
#endif
#if HAS_Z_MIN
attachInterrupt(Z_MIN_PIN, endstop_ISR, CHANGE);
- SET_INPUT(Z_MIN_PIN);
#endif
#if HAS_Z2_MAX
attachInterrupt(Z2_MAX_PIN, endstop_ISR, CHANGE);
- SET_INPUT(Z2_MAX_PIN);
#endif
#if HAS_Z2_MIN
attachInterrupt(Z2_MIN_PIN, endstop_ISR, CHANGE);
- SET_INPUT(Z2_MIN_PIN);
#endif
#if HAS_Z_MIN_PROBE_PIN
attachInterrupt(Z_MIN_PROBE_PIN, endstop_ISR, CHANGE);
- SET_INPUT(Z_MIN_PROBE_PIN);
#endif
}
diff --git a/Marlin/src/HAL/HAL_STM32F4/EEPROM_Emul/eeprom_emul.cpp b/Marlin/src/HAL/HAL_STM32F4/EEPROM_Emul/eeprom_emul.cpp
index 19d5eeaaed50..26ab2fc92c22 100644
--- a/Marlin/src/HAL/HAL_STM32F4/EEPROM_Emul/eeprom_emul.cpp
+++ b/Marlin/src/HAL/HAL_STM32F4/EEPROM_Emul/eeprom_emul.cpp
@@ -47,7 +47,7 @@
/** @addtogroup EEPROM_Emulation
* @{
*/
-#ifdef STM32F4
+#if defined(STM32F4) || defined(STM32F4xx)
/* Includes ------------------------------------------------------------------*/
#include "eeprom_emul.h"
@@ -562,7 +562,7 @@ static uint16_t EE_PageTransfer(uint16_t VirtAddress, uint16_t Data) {
return FlashStatus;
}
-#endif // STM32F4
+#endif // STM32F4 || STM32F4xx
/**
* @}
diff --git a/Marlin/src/HAL/HAL_STM32F4/EmulatedEeprom.cpp b/Marlin/src/HAL/HAL_STM32F4/EmulatedEeprom.cpp
index 667948a53b09..b76de3dbe81e 100644
--- a/Marlin/src/HAL/HAL_STM32F4/EmulatedEeprom.cpp
+++ b/Marlin/src/HAL/HAL_STM32F4/EmulatedEeprom.cpp
@@ -17,7 +17,7 @@
*
*/
-#ifdef STM32F4
+#if defined(STM32F4) || defined(STM32F4xx)
/**
* Description: functions for I2C connected external EEPROM.
@@ -139,5 +139,5 @@ void eeprom_update_block(const void *__src, void *__dst, size_t __n) {
}
#endif // ENABLED(EEPROM_SETTINGS) && DISABLED(I2C_EEPROM) && DISABLED(SPI_EEPROM)
-#endif // STM32F4
+#endif // STM32F4 || STM32F4xx
diff --git a/Marlin/src/HAL/HAL_STM32F4/HAL.cpp b/Marlin/src/HAL/HAL_STM32F4/HAL.cpp
index a7180d38c21c..c79af5859a0c 100644
--- a/Marlin/src/HAL/HAL_STM32F4/HAL.cpp
+++ b/Marlin/src/HAL/HAL_STM32F4/HAL.cpp
@@ -21,8 +21,7 @@
*
*/
-
-#ifdef STM32F4
+#if defined(STM32F4) || defined(STM32F4xx)
// --------------------------------------------------------------------------
// Includes
@@ -81,17 +80,11 @@ void sei(void) { interrupts(); }
void HAL_clear_reset_source(void) { __HAL_RCC_CLEAR_RESET_FLAGS(); }
uint8_t HAL_get_reset_source (void) {
- if (__HAL_RCC_GET_FLAG(RCC_FLAG_IWDGRST) != RESET)
- return RST_WATCHDOG;
-
- if (__HAL_RCC_GET_FLAG(RCC_FLAG_SFTRST) != RESET)
- return RST_SOFTWARE;
-
- if (__HAL_RCC_GET_FLAG(RCC_FLAG_PINRST) != RESET)
- return RST_EXTERNAL;
+ if (__HAL_RCC_GET_FLAG(RCC_FLAG_IWDGRST) != RESET) return RST_WATCHDOG;
- if (__HAL_RCC_GET_FLAG(RCC_FLAG_PORRST) != RESET)
- return RST_POWER_ON;
+ if (__HAL_RCC_GET_FLAG(RCC_FLAG_SFTRST) != RESET) return RST_SOFTWARE;
+ if (__HAL_RCC_GET_FLAG(RCC_FLAG_PINRST) != RESET) return RST_EXTERNAL;
+ if (__HAL_RCC_GET_FLAG(RCC_FLAG_PORRST) != RESET) return RST_POWER_ON;
return 0;
}
@@ -137,4 +130,4 @@ uint16_t HAL_adc_get_result(void) {
return HAL_adc_result;
}
-#endif // STM32F4
+#endif // STM32F4 || STM32F4xx
diff --git a/Marlin/src/HAL/HAL_STM32F4/HAL.h b/Marlin/src/HAL/HAL_STM32F4/HAL.h
index 53d3f1dd06e2..4eca97601e27 100644
--- a/Marlin/src/HAL/HAL_STM32F4/HAL.h
+++ b/Marlin/src/HAL/HAL_STM32F4/HAL.h
@@ -21,8 +21,6 @@
*
*/
-
-
#ifndef _HAL_STM32F4_H
#define _HAL_STM32F4_H
@@ -41,6 +39,10 @@
#include "Arduino.h"
+#ifdef USBCON
+ #include
+#endif
+
#include "../math_32bit.h"
#include "../HAL_SPI.h"
#include "fastio_STM32F4.h"
@@ -48,7 +50,6 @@
#include "HAL_timers_STM32F4.h"
-
// --------------------------------------------------------------------------
// Defines
// --------------------------------------------------------------------------
@@ -186,6 +187,7 @@ extern "C" {
*/
extern "C" char* _sbrk(int incr);
+
/*
static int freeMemory() {
volatile int top;
@@ -193,6 +195,7 @@ static int freeMemory() {
return top;
}
*/
+
static int freeMemory() {
volatile char top;
return &top - reinterpret_cast(_sbrk(0));
diff --git a/Marlin/src/HAL/HAL_STM32F4/HAL_Servo_STM32F4.cpp b/Marlin/src/HAL/HAL_STM32F4/HAL_Servo_STM32F4.cpp
index df5397685ad0..2877e88d54b7 100644
--- a/Marlin/src/HAL/HAL_STM32F4/HAL_Servo_STM32F4.cpp
+++ b/Marlin/src/HAL/HAL_STM32F4/HAL_Servo_STM32F4.cpp
@@ -21,7 +21,7 @@
*
*/
-#ifdef STM32F4
+#if defined(STM32F4) || defined(STM32F4xx)
#include "../../inc/MarlinConfig.h"
@@ -50,4 +50,4 @@ void libServo::move(const int value) {
}
#endif // HAS_SERVOS
-#endif // STM32F4
+#endif // STM32F4 || STM32F4xx
diff --git a/Marlin/src/HAL/HAL_STM32F4/HAL_spi_STM32F4.cpp b/Marlin/src/HAL/HAL_STM32F4/HAL_spi_STM32F4.cpp
index 4c7d6928807c..606d43f7f91e 100644
--- a/Marlin/src/HAL/HAL_STM32F4/HAL_spi_STM32F4.cpp
+++ b/Marlin/src/HAL/HAL_STM32F4/HAL_spi_STM32F4.cpp
@@ -30,7 +30,7 @@
* Adapted to the STM32F4 HAL
*/
-#ifdef STM32F4
+#if defined(STM32F4) || defined(STM32F4xx)
// --------------------------------------------------------------------------
// Includes
@@ -54,6 +54,7 @@ static SPISettings spiConfig;
// --------------------------------------------------------------------------
#if ENABLED(SOFTWARE_SPI)
+
// --------------------------------------------------------------------------
// Software SPI
// --------------------------------------------------------------------------
@@ -81,8 +82,7 @@ void spiBegin(void) {
#error SS_PIN not defined!
#endif
- SET_OUTPUT(SS_PIN);
- WRITE(SS_PIN, HIGH);
+ OUT_WRITE(SS_PIN, HIGH);
}
/** Configure SPI for specified SPI speed */
@@ -90,14 +90,13 @@ void spiInit(uint8_t spiRate) {
// Use datarates Marlin uses
uint32_t clock;
switch (spiRate) {
- case SPI_FULL_SPEED: clock = 20000000; break; // 13.9mhz=20000000 6.75mhz=10000000 3.38mhz=5000000 .833mhz=1000000
- case SPI_HALF_SPEED: clock = 5000000; break;
- case SPI_QUARTER_SPEED: clock = 2500000; break;
- case SPI_EIGHTH_SPEED: clock = 1250000; break;
- case SPI_SPEED_5: clock = 625000; break;
- case SPI_SPEED_6: clock = 300000; break;
- default:
- clock = 4000000; // Default from the SPI libarary
+ case SPI_FULL_SPEED: clock = 20000000; break; // 13.9mhz=20000000 6.75mhz=10000000 3.38mhz=5000000 .833mhz=1000000
+ case SPI_HALF_SPEED: clock = 5000000; break;
+ case SPI_QUARTER_SPEED: clock = 2500000; break;
+ case SPI_EIGHTH_SPEED: clock = 1250000; break;
+ case SPI_SPEED_5: clock = 625000; break;
+ case SPI_SPEED_6: clock = 300000; break;
+ default: clock = 4000000; // Default from the SPI libarary
}
spiConfig = SPISettings(clock, MSBFIRST, SPI_MODE0);
SPI.begin();
@@ -128,7 +127,13 @@ uint8_t spiRec(void) {
*/
void spiRead(uint8_t* buf, uint16_t nbyte) {
SPI.beginTransaction(spiConfig);
- SPI.dmaTransfer(0, const_cast(buf), nbyte);
+
+ #ifdef STM32GENERIC
+ SPI.dmaTransfer(0, const_cast(buf), nbyte);
+ #else
+ SPI.transfer((uint8_t*)buf, nbyte);
+ #endif
+
SPI.endTransaction();
}
@@ -156,10 +161,16 @@ void spiSend(uint8_t b) {
void spiSendBlock(uint8_t token, const uint8_t* buf) {
SPI.beginTransaction(spiConfig);
SPI.transfer(token);
- SPI.dmaSend(const_cast(buf), 512);
+
+ #ifdef STM32GENERIC
+ SPI.dmaSend(const_cast(buf), 512);
+ #else
+ SPI.transfer((uint8_t*)buf, (uint8_t*)0, 512);
+ #endif
+
SPI.endTransaction();
}
#endif // SOFTWARE_SPI
-#endif // STM32F4
+#endif // STM32F4 || STM32F4xx
diff --git a/Marlin/src/HAL/HAL_STM32F4/HAL_timers_STM32F4.cpp b/Marlin/src/HAL/HAL_STM32F4/HAL_timers_STM32F4.cpp
index 1c12f5f4e98e..d03bf4c09b54 100644
--- a/Marlin/src/HAL/HAL_STM32F4/HAL_timers_STM32F4.cpp
+++ b/Marlin/src/HAL/HAL_STM32F4/HAL_timers_STM32F4.cpp
@@ -20,7 +20,7 @@
*
*/
-#ifdef STM32F4
+#if defined(STM32F4) || defined(STM32F4xx)
// --------------------------------------------------------------------------
// Includes
@@ -39,6 +39,8 @@
// --------------------------------------------------------------------------
#define NUM_HARDWARE_TIMERS 2
+#define STEP_TIMER_IRQ_ID TIM5_IRQn
+#define TEMP_TIMER_IRQ_ID TIM7_IRQn
//#define PRESCALER 1
// --------------------------------------------------------------------------
@@ -53,7 +55,7 @@
// Private Variables
// --------------------------------------------------------------------------
-tTimerConfig timerConfig[NUM_HARDWARE_TIMERS];
+stm32f4_timer_t TimerHandle[NUM_HARDWARE_TIMERS];
// --------------------------------------------------------------------------
// Function prototypes
@@ -72,90 +74,86 @@ bool timers_initialised[NUM_HARDWARE_TIMERS] = {false};
void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency) {
if (!timers_initialised[timer_num]) {
+ constexpr uint32_t step_prescaler = STEPPER_TIMER_PRESCALE - 1,
+ temp_prescaler = TEMP_TIMER_PRESCALE - 1;
switch (timer_num) {
- case STEP_TIMER_NUM:
- //STEPPER TIMER TIM5 //use a 32bit timer
- __HAL_RCC_TIM5_CLK_ENABLE();
- timerConfig[0].timerdef.Instance = TIM5;
- timerConfig[0].timerdef.Init.Prescaler = (STEPPER_TIMER_PRESCALE);
- timerConfig[0].timerdef.Init.CounterMode = TIM_COUNTERMODE_UP;
- timerConfig[0].timerdef.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
- timerConfig[0].IRQ_Id = TIM5_IRQn;
- timerConfig[0].callback = (uint32_t)TC5_Handler;
- HAL_NVIC_SetPriority(timerConfig[0].IRQ_Id, 1, 0);
- break;
- case TEMP_TIMER_NUM:
- //TEMP TIMER TIM7 // any available 16bit Timer (1 already used for PWM)
- __HAL_RCC_TIM7_CLK_ENABLE();
- timerConfig[1].timerdef.Instance = TIM7;
- timerConfig[1].timerdef.Init.Prescaler = (TEMP_TIMER_PRESCALE);
- timerConfig[1].timerdef.Init.CounterMode = TIM_COUNTERMODE_UP;
- timerConfig[1].timerdef.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
- timerConfig[1].IRQ_Id = TIM7_IRQn;
- timerConfig[1].callback = (uint32_t)TC7_Handler;
- HAL_NVIC_SetPriority(timerConfig[1].IRQ_Id, 2, 0);
- break;
+ case STEP_TIMER_NUM:
+ // STEPPER TIMER TIM5 - use a 32bit timer
+ #ifdef STM32GENERIC
+ __HAL_RCC_TIM5_CLK_ENABLE();
+ TimerHandle[timer_num].handle.Instance = TIM5;
+ TimerHandle[timer_num].handle.Init.Prescaler = step_prescaler;
+ TimerHandle[timer_num].handle.Init.CounterMode = TIM_COUNTERMODE_UP;
+ TimerHandle[timer_num].handle.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
+ TimerHandle[timer_num].callback = (uint32_t)TC5_Handler;
+ #else
+ TimerHandle[timer_num].timer = TIM5;
+ TimerHandle[timer_num].irqHandle = TC5_Handler;
+ TimerHandleInit(&TimerHandle[timer_num], (((HAL_TIMER_RATE) / step_prescaler) / frequency) - 1, step_prescaler);
+ #endif
+ HAL_NVIC_SetPriority(STEP_TIMER_IRQ_ID, 6, 0);
+ break;
+
+ case TEMP_TIMER_NUM:
+ // TEMP TIMER TIM7 - any available 16bit Timer (1 already used for PWM)
+ #ifdef STM32GENERIC
+ __HAL_RCC_TIM7_CLK_ENABLE();
+ TimerHandle[timer_num].handle.Instance = TIM7;
+ TimerHandle[timer_num].handle.Init.Prescaler = temp_prescaler;
+ TimerHandle[timer_num].handle.Init.CounterMode = TIM_COUNTERMODE_UP;
+ TimerHandle[timer_num].handle.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
+ TimerHandle[timer_num].callback = (uint32_t)TC7_Handler;
+ #else
+ TimerHandle[timer_num].timer = TIM7;
+ TimerHandle[timer_num].irqHandle = TC7_Handler;
+ TimerHandleInit(&TimerHandle[timer_num], (((HAL_TIMER_RATE) / temp_prescaler) / frequency) - 1, temp_prescaler);
+ #endif
+ HAL_NVIC_SetPriority(TEMP_TIMER_IRQ_ID, 2, 0);
+ break;
}
timers_initialised[timer_num] = true;
}
- timerConfig[timer_num].timerdef.Init.Period = (((HAL_TIMER_RATE) / timerConfig[timer_num].timerdef.Init.Prescaler) / frequency) - 1;
-
- if (HAL_TIM_Base_Init(&timerConfig[timer_num].timerdef) == HAL_OK)
- HAL_TIM_Base_Start_IT(&timerConfig[timer_num].timerdef);
+ #ifdef STM32GENERIC
+ TimerHandle[timer_num].handle.Init.Period = (((HAL_TIMER_RATE) / TimerHandle[timer_num].handle.Init.Prescaler) / frequency) - 1;
+ if (HAL_TIM_Base_Init(&TimerHandle[timer_num].handle) == HAL_OK)
+ HAL_TIM_Base_Start_IT(&TimerHandle[timer_num].handle);
+ #endif
}
-//forward the interrupt
-extern "C" void TIM5_IRQHandler() {
- ((void(*)(void))timerConfig[0].callback)();
-}
-extern "C" void TIM7_IRQHandler() {
- ((void(*)(void))timerConfig[1].callback)();
-}
-
-void HAL_timer_set_compare(const uint8_t timer_num, const uint32_t compare) {
- __HAL_TIM_SetAutoreload(&timerConfig[timer_num].timerdef, compare);
-}
+#ifdef STM32GENERIC
+ extern "C" void TIM5_IRQHandler() {
+ ((void(*)(void))TimerHandle[0].callback)();
+ }
+ extern "C" void TIM7_IRQHandler() {
+ ((void(*)(void))TimerHandle[1].callback)();
+ }
+#endif
void HAL_timer_enable_interrupt(const uint8_t timer_num) {
- HAL_NVIC_EnableIRQ(timerConfig[timer_num].IRQ_Id);
+ switch (timer_num) {
+ case STEP_TIMER_NUM: HAL_NVIC_EnableIRQ(STEP_TIMER_IRQ_ID); break;
+ case TEMP_TIMER_NUM: HAL_NVIC_EnableIRQ(TEMP_TIMER_IRQ_ID); break;
+ }
}
void HAL_timer_disable_interrupt(const uint8_t timer_num) {
- HAL_NVIC_DisableIRQ(timerConfig[timer_num].IRQ_Id);
-
+ switch (timer_num) {
+ case STEP_TIMER_NUM: HAL_NVIC_DisableIRQ(STEP_TIMER_IRQ_ID); break;
+ case TEMP_TIMER_NUM: HAL_NVIC_DisableIRQ(TEMP_TIMER_IRQ_ID); break;
+ }
// We NEED memory barriers to ensure Interrupts are actually disabled!
// ( https://dzone.com/articles/nvic-disabling-interrupts-on-arm-cortex-m-and-the )
__DSB();
__ISB();
}
-hal_timer_t HAL_timer_get_compare(const uint8_t timer_num) {
- return __HAL_TIM_GetAutoreload(&timerConfig[timer_num].timerdef);
-}
-
-uint32_t HAL_timer_get_count(const uint8_t timer_num) {
- return __HAL_TIM_GetCounter(&timerConfig[timer_num].timerdef);
-}
-
-void HAL_timer_restrain(const uint8_t timer_num, const uint16_t interval_ticks) {
- const hal_timer_t mincmp = HAL_timer_get_count(timer_num) + interval_ticks;
- if (HAL_timer_get_compare(timer_num) < mincmp) HAL_timer_set_compare(timer_num, mincmp);
-}
-
-void HAL_timer_isr_prologue(const uint8_t timer_num) {
- if (__HAL_TIM_GET_FLAG(&timerConfig[timer_num].timerdef, TIM_FLAG_UPDATE) == SET) {
- __HAL_TIM_CLEAR_FLAG(&timerConfig[timer_num].timerdef, TIM_FLAG_UPDATE);
- }
-}
-
bool HAL_timer_interrupt_enabled(const uint8_t timer_num) {
- if (NVIC->ISER[(uint32_t)((int32_t)timerConfig[timer_num].IRQ_Id) >> 5] & (uint32_t)(1 << ((uint32_t)((int32_t)timerConfig[timer_num].IRQ_Id) & (uint32_t)0x1F))) {
- return true;
- }
- else {
- return false;
+ switch (timer_num) {
+ case STEP_TIMER_NUM: return NVIC->ISER[(uint32_t)((int32_t)STEP_TIMER_IRQ_ID) >> 5] & (uint32_t)(1 << ((uint32_t)((int32_t)STEP_TIMER_IRQ_ID) & (uint32_t)0x1F));
+ case TEMP_TIMER_NUM: return NVIC->ISER[(uint32_t)((int32_t)TEMP_TIMER_IRQ_ID) >> 5] & (uint32_t)(1 << ((uint32_t)((int32_t)TEMP_TIMER_IRQ_ID) & (uint32_t)0x1F));
}
+ return false;
}
-#endif // STM32F4
+#endif // STM32F4 || STM32F4xx
diff --git a/Marlin/src/HAL/HAL_STM32F4/HAL_timers_STM32F4.h b/Marlin/src/HAL/HAL_STM32F4/HAL_timers_STM32F4.h
index 0f26a3b9f3c7..943550d13fdc 100644
--- a/Marlin/src/HAL/HAL_STM32F4/HAL_timers_STM32F4.h
+++ b/Marlin/src/HAL/HAL_STM32F4/HAL_timers_STM32F4.h
@@ -38,21 +38,22 @@
#define hal_timer_t uint32_t // TODO: One is 16-bit, one 32-bit - does this need to be checked?
#define HAL_TIMER_TYPE_MAX 0xFFFF
-#define STEP_TIMER_NUM 0 // index of timer to use for stepper
-#define TEMP_TIMER_NUM 1 // index of timer to use for temperature
-
#define HAL_TIMER_RATE (HAL_RCC_GetSysClockFreq() / 2) // frequency of timer peripherals
-#define STEPPER_TIMER_PRESCALE 54 // was 40,prescaler for setting stepper timer, 2Mhz
-#define HAL_STEPPER_TIMER_RATE (HAL_TIMER_RATE / STEPPER_TIMER_PRESCALE) // frequency of stepper timer
-#define HAL_TICKS_PER_US ((HAL_STEPPER_TIMER_RATE) / 1000000) // stepper timer ticks per µs
+#define STEP_TIMER_NUM 0 // index of timer to use for stepper
+#define TEMP_TIMER_NUM 1 // index of timer to use for temperature
#define PULSE_TIMER_NUM STEP_TIMER_NUM
-#define PULSE_TIMER_PRESCALE STEPPER_TIMER_PRESCALE
#define TEMP_TIMER_PRESCALE 1000 // prescaler for setting Temp timer, 72Khz
#define TEMP_TIMER_FREQUENCY 1000 // temperature interrupt frequency
-#define STEP_TIMER_MIN_INTERVAL 8 // minimum time in µs between stepper interrupts
+#define STEPPER_TIMER_PRESCALE 54 // was 40,prescaler for setting stepper timer, 2Mhz
+#define STEPPER_TIMER_RATE (HAL_TIMER_RATE / STEPPER_TIMER_PRESCALE) // frequency of stepper timer
+#define STEPPER_TIMER_TICKS_PER_US ((STEPPER_TIMER_RATE) / 1000000) // stepper timer ticks per µs
+
+#define PULSE_TIMER_RATE STEPPER_TIMER_RATE // frequency of pulse timer
+#define PULSE_TIMER_PRESCALE STEPPER_TIMER_PRESCALE
+#define PULSE_TIMER_TICKS_PER_US STEPPER_TIMER_TICKS_PER_US
#define ENABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_enable_interrupt(STEP_TIMER_NUM)
#define DISABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_disable_interrupt(STEP_TIMER_NUM)
@@ -63,27 +64,38 @@
// TODO change this
+#ifdef STM32GENERIC
+ extern void TC5_Handler();
+ extern void TC7_Handler();
+ #define HAL_STEP_TIMER_ISR void TC5_Handler()
+ #define HAL_TEMP_TIMER_ISR void TC7_Handler()
+#else
+ extern void TC5_Handler(stimer_t *htim);
+ extern void TC7_Handler(stimer_t *htim);
+ #define HAL_STEP_TIMER_ISR void TC5_Handler(stimer_t *htim)
+ #define HAL_TEMP_TIMER_ISR void TC7_Handler(stimer_t *htim)
+#endif
-extern void TC5_Handler();
-extern void TC7_Handler();
-#define HAL_STEP_TIMER_ISR void TC5_Handler()
-#define HAL_TEMP_TIMER_ISR void TC7_Handler()
// --------------------------------------------------------------------------
// Types
// --------------------------------------------------------------------------
-typedef struct {
- TIM_HandleTypeDef timerdef;
- IRQn_Type IRQ_Id;
- uint32_t callback;
-} tTimerConfig;
+#ifdef STM32GENERIC
+ typedef struct {
+ TIM_HandleTypeDef handle;
+ uint32_t callback;
+ } tTimerConfig;
+ typedef tTimerConfig stm32f4_timer_t;
+#else
+ typedef stimer_t stm32f4_timer_t;
+#endif
// --------------------------------------------------------------------------
// Public Variables
// --------------------------------------------------------------------------
-//extern const tTimerConfig timerConfig[];
+extern stm32f4_timer_t TimerHandle[];
// --------------------------------------------------------------------------
// Public functions
@@ -94,12 +106,35 @@ void HAL_timer_enable_interrupt(const uint8_t timer_num);
void HAL_timer_disable_interrupt(const uint8_t timer_num);
bool HAL_timer_interrupt_enabled(const uint8_t timer_num);
-void HAL_timer_set_compare(const uint8_t timer_num, const uint32_t compare);
-hal_timer_t HAL_timer_get_compare(const uint8_t timer_num);
-uint32_t HAL_timer_get_count(const uint8_t timer_num);
-void HAL_timer_restrain(const uint8_t timer_num, const uint16_t interval_ticks);
+FORCE_INLINE static uint32_t HAL_timer_get_count(const uint8_t timer_num) {
+ return __HAL_TIM_GET_COUNTER(&TimerHandle[timer_num].handle);
+}
+
+FORCE_INLINE static void HAL_timer_set_compare(const uint8_t timer_num, const uint32_t compare) {
+ __HAL_TIM_SET_AUTORELOAD(&TimerHandle[timer_num].handle, compare);
+ if (HAL_timer_get_count(timer_num) >= compare)
+ TimerHandle[timer_num].handle.Instance->EGR |= TIM_EGR_UG; // Generate an immediate update interrupt
+}
+
+FORCE_INLINE static hal_timer_t HAL_timer_get_compare(const uint8_t timer_num) {
+ return __HAL_TIM_GET_AUTORELOAD(&TimerHandle[timer_num].handle);
+}
+
+FORCE_INLINE static void HAL_timer_restrain(const uint8_t timer_num, const uint16_t interval_ticks) {
+ const hal_timer_t mincmp = HAL_timer_get_count(timer_num) + interval_ticks;
+ if (HAL_timer_get_compare(timer_num) < mincmp)
+ HAL_timer_set_compare(timer_num, mincmp);
+}
+
+#ifdef STM32GENERIC
+ FORCE_INLINE static void HAL_timer_isr_prologue(const uint8_t timer_num) {
+ if (__HAL_TIM_GET_FLAG(&TimerHandle[timer_num].handle, TIM_FLAG_UPDATE) == SET)
+ __HAL_TIM_CLEAR_FLAG(&TimerHandle[timer_num].handle, TIM_FLAG_UPDATE);
+ }
+#else
+ #define HAL_timer_isr_prologue(TIMER_NUM)
+#endif
-void HAL_timer_isr_prologue(const uint8_t timer_num);
#define HAL_timer_isr_epilogue(TIMER_NUM)
#endif // _HAL_TIMERS_STM32F4_H
diff --git a/Marlin/src/HAL/HAL_STM32F4/endstop_interrupts.h b/Marlin/src/HAL/HAL_STM32F4/endstop_interrupts.h
index 64e67afc51ae..1b1cffc49f37 100644
--- a/Marlin/src/HAL/HAL_STM32F4/endstop_interrupts.h
+++ b/Marlin/src/HAL/HAL_STM32F4/endstop_interrupts.h
@@ -32,39 +32,30 @@ void endstop_ISR(void) { endstops.check_possible_change(); }
void setup_endstop_interrupts(void) {
#if HAS_X_MAX
attachInterrupt(X_MAX_PIN, endstop_ISR, CHANGE);
- SET_INPUT(X_MAX_PIN);
#endif
#if HAS_X_MIN
attachInterrupt(X_MIN_PIN, endstop_ISR, CHANGE);
- SET_INPUT(X_MIN_PIN);
#endif
#if HAS_Y_MAX
attachInterrupt(Y_MAX_PIN, endstop_ISR, CHANGE);
- SET_INPUT(Y_MAX_PIN);
#endif
#if HAS_Y_MIN
attachInterrupt(Y_MIN_PIN, endstop_ISR, CHANGE);
- SET_INPUT(Y_MIN_PIN);
#endif
#if HAS_Z_MAX
attachInterrupt(Z_MAX_PIN, endstop_ISR, CHANGE);
- SET_INPUT(Z_MAX_PIN);
#endif
#if HAS_Z_MIN
attachInterrupt(Z_MIN_PIN, endstop_ISR, CHANGE);
- SET_INPUT(Z_MIN_PIN);
#endif
#if HAS_Z2_MAX
attachInterrupt(Z2_MAX_PIN, endstop_ISR, CHANGE);
- SET_INPUT(Z2_MAX_PIN);
#endif
#if HAS_Z2_MIN
attachInterrupt(Z2_MIN_PIN, endstop_ISR, CHANGE);
- SET_INPUT(Z2_MIN_PIN);
#endif
#if HAS_Z_MIN_PROBE_PIN
attachInterrupt(Z_MIN_PROBE_PIN, endstop_ISR, CHANGE);
- SET_INPUT(Z_MIN_PROBE_PIN);
#endif
}
diff --git a/Marlin/src/HAL/HAL_STM32F4/persistent_store_impl.cpp b/Marlin/src/HAL/HAL_STM32F4/persistent_store_impl.cpp
index 018575983910..db292bbb5569 100644
--- a/Marlin/src/HAL/HAL_STM32F4/persistent_store_impl.cpp
+++ b/Marlin/src/HAL/HAL_STM32F4/persistent_store_impl.cpp
@@ -21,7 +21,7 @@
*
*/
-#ifdef STM32F4
+#if defined(STM32F4) || defined(STM32F4xx)
#include "../persistent_store_api.h"
@@ -72,4 +72,4 @@ bool read_data(int &pos, uint8_t* value, uint16_t size, uint16_t *crc, const boo
} // HAL
#endif // EEPROM_SETTINGS
-#endif // STM32F4
+#endif // STM32F4 || STM32F4xx
diff --git a/Marlin/src/HAL/HAL_STM32F4/watchdog_STM32F4.cpp b/Marlin/src/HAL/HAL_STM32F4/watchdog_STM32F4.cpp
index dfe597b23a30..f5dd6bdfae84 100644
--- a/Marlin/src/HAL/HAL_STM32F4/watchdog_STM32F4.cpp
+++ b/Marlin/src/HAL/HAL_STM32F4/watchdog_STM32F4.cpp
@@ -20,7 +20,7 @@
*
*/
-#ifdef STM32F4
+#if defined(STM32F4) || defined(STM32F4xx)
#include "../../inc/MarlinConfig.h"
@@ -54,4 +54,4 @@
#endif // USE_WATCHDOG
-#endif // STM32F4
+#endif // STM32F4 || STM32F4xx
diff --git a/Marlin/src/HAL/HAL_STM32F7/HAL_timers_STM32F7.h b/Marlin/src/HAL/HAL_STM32F7/HAL_timers_STM32F7.h
index b65ded90195e..a97bad75fba2 100644
--- a/Marlin/src/HAL/HAL_STM32F7/HAL_timers_STM32F7.h
+++ b/Marlin/src/HAL/HAL_STM32F7/HAL_timers_STM32F7.h
@@ -38,21 +38,22 @@
#define hal_timer_t uint32_t // TODO: One is 16-bit, one 32-bit - does this need to be checked?
#define HAL_TIMER_TYPE_MAX 0xFFFF
-#define STEP_TIMER_NUM 0 // index of timer to use for stepper
-#define TEMP_TIMER_NUM 1 // index of timer to use for temperature
-
#define HAL_TIMER_RATE (HAL_RCC_GetSysClockFreq() / 2) // frequency of timer peripherals
-#define STEPPER_TIMER_PRESCALE 54 // was 40,prescaler for setting stepper timer, 2Mhz
-#define HAL_STEPPER_TIMER_RATE (HAL_TIMER_RATE / STEPPER_TIMER_PRESCALE) // frequency of stepper timer
-#define HAL_TICKS_PER_US ((HAL_STEPPER_TIMER_RATE) / 1000000) // stepper timer ticks per µs
+#define STEP_TIMER_NUM 0 // index of timer to use for stepper
+#define TEMP_TIMER_NUM 1 // index of timer to use for temperature
#define PULSE_TIMER_NUM STEP_TIMER_NUM
-#define PULSE_TIMER_PRESCALE STEPPER_TIMER_PRESCALE
-#define TEMP_TIMER_PRESCALE 1000 // prescaler for setting Temp timer, 72Khz
#define TEMP_TIMER_FREQUENCY 1000 // temperature interrupt frequency
+#define TEMP_TIMER_PRESCALE 1000 // prescaler for setting Temp timer, 72Khz
+
+#define STEPPER_TIMER_PRESCALE 54 // was 40,prescaler for setting stepper timer, 2Mhz
+#define STEPPER_TIMER_RATE (HAL_TIMER_RATE / STEPPER_TIMER_PRESCALE) // frequency of stepper timer
+#define STEPPER_TIMER_TICKS_PER_US ((STEPPER_TIMER_RATE) / 1000000) // stepper timer ticks per µs
-#define STEP_TIMER_MIN_INTERVAL 8 // minimum time in µs between stepper interrupts
+#define PULSE_TIMER_RATE STEPPER_TIMER_RATE // frequency of pulse timer
+#define PULSE_TIMER_PRESCALE STEPPER_TIMER_PRESCALE
+#define PULSE_TIMER_TICKS_PER_US STEPPER_TIMER_TICKS_PER_US
#define ENABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_enable_interrupt(STEP_TIMER_NUM)
#define DISABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_disable_interrupt(STEP_TIMER_NUM)
diff --git a/Marlin/src/HAL/HAL_STM32F7/endstop_interrupts.h b/Marlin/src/HAL/HAL_STM32F7/endstop_interrupts.h
index de5641268f2e..5ae338d76adb 100644
--- a/Marlin/src/HAL/HAL_STM32F7/endstop_interrupts.h
+++ b/Marlin/src/HAL/HAL_STM32F7/endstop_interrupts.h
@@ -34,39 +34,30 @@ void endstop_ISR(void) { endstops.check_possible_change(); }
void setup_endstop_interrupts(void) {
#if HAS_X_MAX
attachInterrupt(X_MAX_PIN, endstop_ISR, CHANGE);
- SET_INPUT(X_MAX_PIN);
#endif
#if HAS_X_MIN
attachInterrupt(X_MIN_PIN, endstop_ISR, CHANGE);
- SET_INPUT(X_MIN_PIN);
#endif
#if HAS_Y_MAX
attachInterrupt(Y_MAX_PIN, endstop_ISR, CHANGE);
- SET_INPUT(Y_MAX_PIN);
#endif
#if HAS_Y_MIN
attachInterrupt(Y_MIN_PIN, endstop_ISR, CHANGE);
- SET_INPUT(Y_MIN_PIN);
#endif
#if HAS_Z_MAX
attachInterrupt(Z_MAX_PIN, endstop_ISR, CHANGE);
- SET_INPUT(Z_MAX_PIN);
#endif
#if HAS_Z_MIN
attachInterrupt(Z_MIN_PIN, endstop_ISR, CHANGE);
- SET_INPUT(Z_MIN_PIN);
#endif
#if HAS_Z2_MAX
attachInterrupt(Z2_MAX_PIN, endstop_ISR, CHANGE);
- SET_INPUT(Z2_MAX_PIN);
#endif
#if HAS_Z2_MIN
attachInterrupt(Z2_MIN_PIN, endstop_ISR, CHANGE);
- SET_INPUT(Z2_MIN_PIN);
#endif
#if HAS_Z_MIN_PROBE_PIN
attachInterrupt(Z_MIN_PROBE_PIN, endstop_ISR, CHANGE);
- SET_INPUT(Z_MIN_PROBE_PIN);
#endif
}
diff --git a/Marlin/src/HAL/HAL_TEENSY35_36/HAL_timers_Teensy.h b/Marlin/src/HAL/HAL_TEENSY35_36/HAL_timers_Teensy.h
index c350aa1124d8..5fed19e31380 100644
--- a/Marlin/src/HAL/HAL_TEENSY35_36/HAL_timers_Teensy.h
+++ b/Marlin/src/HAL/HAL_TEENSY35_36/HAL_timers_Teensy.h
@@ -43,10 +43,6 @@
typedef uint32_t hal_timer_t;
#define HAL_TIMER_TYPE_MAX 0xFFFFFFFF
-#define STEP_TIMER_NUM 0
-#define TEMP_TIMER_NUM 1
-#define PULSE_TIMER_NUM STEP_TIMER_NUM
-
#define FTM0_TIMER_PRESCALE 8
#define FTM1_TIMER_PRESCALE 4
#define FTM0_TIMER_PRESCALE_BITS 0b011
@@ -56,14 +52,20 @@ typedef uint32_t hal_timer_t;
#define FTM1_TIMER_RATE (F_BUS / FTM1_TIMER_PRESCALE) // 60MHz / 4 = 15MHz
#define HAL_TIMER_RATE (FTM0_TIMER_RATE)
-#define HAL_STEPPER_TIMER_RATE HAL_TIMER_RATE
-#define HAL_TICKS_PER_US ((HAL_STEPPER_TIMER_RATE) / 1000000)
-#define STEPPER_TIMER_PRESCALE (CYCLES_PER_MICROSECOND / HAL_TICKS_PER_US)
-#define STEP_TIMER_MIN_INTERVAL 8 // minimum time in µs between stepper interrupts
-#define TEMP_TIMER_FREQUENCY 1000
+#define STEP_TIMER_NUM 0
+#define TEMP_TIMER_NUM 1
+#define PULSE_TIMER_NUM STEP_TIMER_NUM
+
+#define TEMP_TIMER_FREQUENCY 1000
+
+#define STEPPER_TIMER_RATE HAL_TIMER_RATE
+#define STEPPER_TIMER_TICKS_PER_US ((STEPPER_TIMER_RATE) / 1000000)
+#define STEPPER_TIMER_PRESCALE (CYCLES_PER_MICROSECOND / STEPPER_TIMER_TICKS_PER_US)
-#define PULSE_TIMER_PRESCALE STEPPER_TIMER_PRESCALE
+#define PULSE_TIMER_RATE STEPPER_TIMER_RATE // frequency of pulse timer
+#define PULSE_TIMER_PRESCALE STEPPER_TIMER_PRESCALE
+#define PULSE_TIMER_TICKS_PER_US STEPPER_TIMER_TICKS_PER_US
#define ENABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_enable_interrupt(STEP_TIMER_NUM)
#define DISABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_disable_interrupt(STEP_TIMER_NUM)
diff --git a/Marlin/src/HAL/backtrace/unwmemaccess.cpp b/Marlin/src/HAL/backtrace/unwmemaccess.cpp
index 02b46519c523..b939be8803fa 100644
--- a/Marlin/src/HAL/backtrace/unwmemaccess.cpp
+++ b/Marlin/src/HAL/backtrace/unwmemaccess.cpp
@@ -62,7 +62,7 @@
#define END_FLASH_ADDR 0x00080000
#endif
-#ifdef STM32F4
+#if defined(STM32F4) || defined(STM32F4xx)
// For STM32F407VET
// SRAM (0x20000000 - 0x20030000) (192kb)
// FLASH (0x08000000 - 0x08080000) (512kb)
diff --git a/Marlin/src/HAL/platforms.h b/Marlin/src/HAL/platforms.h
index cf0a8cf9313d..6ef7835fec82 100644
--- a/Marlin/src/HAL/platforms.h
+++ b/Marlin/src/HAL/platforms.h
@@ -13,7 +13,7 @@
#define HAL_PLATFORM HAL_LPC1768
#elif defined(__STM32F1__) || defined(TARGET_STM32F1)
#define HAL_PLATFORM HAL_STM32F1
-#elif defined(STM32F4)
+#elif defined(STM32F4) || defined(STM32F4xx)
#define HAL_PLATFORM HAL_STM32F4
#elif defined(STM32F7)
#define HAL_PLATFORM HAL_STM32F7
diff --git a/Marlin/src/HAL/servo.cpp b/Marlin/src/HAL/servo.cpp
index 6bafb26dc4d3..a49aac0f998a 100644
--- a/Marlin/src/HAL/servo.cpp
+++ b/Marlin/src/HAL/servo.cpp
@@ -53,7 +53,7 @@
#include "../inc/MarlinConfig.h"
-#if HAS_SERVOS && !(IS_32BIT_TEENSY || defined(TARGET_LPC1768) || defined(STM32F4))
+#if HAS_SERVOS && !(IS_32BIT_TEENSY || defined(TARGET_LPC1768) || defined(STM32F4) || defined(STM32F4xx))
//#include
#include "servo.h"
diff --git a/Marlin/src/HAL/servo.h b/Marlin/src/HAL/servo.h
index 9f47dbede15d..5df396efd6fb 100644
--- a/Marlin/src/HAL/servo.h
+++ b/Marlin/src/HAL/servo.h
@@ -74,7 +74,7 @@
#elif defined(TARGET_LPC1768)
#include "HAL_LPC1768/LPC1768_Servo.h"
-#elif defined(STM32F4)
+#elif defined(STM32F4) || defined(STM32F4xx)
#include "HAL_STM32F4/HAL_Servo_STM32F4.h"
#else
#include
diff --git a/Marlin/src/feature/tmc_util.cpp b/Marlin/src/feature/tmc_util.cpp
index adfaccabbecc..a5dc428592ec 100644
--- a/Marlin/src/feature/tmc_util.cpp
+++ b/Marlin/src/feature/tmc_util.cpp
@@ -582,8 +582,8 @@ void _tmc_say_sgt(const TMC_AxisEnum axis, const int8_t sgt) {
#if ENABLED(SENSORLESS_HOMING)
void tmc_sensorless_homing(TMC2130Stepper &st, const bool enable/*=true*/) {
+ st.coolstep_min_speed(enable ? 1024UL * 1024UL - 1UL : 0);
#if ENABLED(STEALTHCHOP)
- st.coolstep_min_speed(enable ? 1024UL * 1024UL - 1UL : 0);
st.stealthChop(!enable);
#endif
st.diag1_stall(enable ? 1 : 0);
diff --git a/Marlin/src/gcode/calibrate/G28.cpp b/Marlin/src/gcode/calibrate/G28.cpp
index 2a57b52f340c..5f4ba64dc6f0 100644
--- a/Marlin/src/gcode/calibrate/G28.cpp
+++ b/Marlin/src/gcode/calibrate/G28.cpp
@@ -181,7 +181,7 @@ void GcodeSuite::G28(const bool always_home_all) {
#endif
return;
}
-
+
// Wait for planner moves to finish!
planner.synchronize();
@@ -203,7 +203,7 @@ void GcodeSuite::G28(const bool always_home_all) {
#endif
#if ENABLED(BLTOUCH)
- set_bltouch_deployed(false);
+ bltouch_command(BLTOUCH_RESET);
#endif
// Always home with tool 0 active
diff --git a/Marlin/src/inc/Conditionals_post.h b/Marlin/src/inc/Conditionals_post.h
index dd018a11544c..0f6feb1a9073 100644
--- a/Marlin/src/inc/Conditionals_post.h
+++ b/Marlin/src/inc/Conditionals_post.h
@@ -1444,149 +1444,4 @@
#define USE_EXECUTE_COMMANDS_IMMEDIATE
#endif
-// Calculate a default maximum stepper rate, if not supplied
-#ifndef MAXIMUM_STEPPER_RATE
- #if MINIMUM_STEPPER_PULSE
- #define MAXIMUM_STEPPER_RATE (1000000UL / (2UL * (MINIMUM_STEPPER_PULSE)))
- #else
- #define MAXIMUM_STEPPER_RATE 500000UL
- #endif
-#endif
-
-//
-// Estimate the amount of time the ISR will take to execute
-//
-#ifdef CPU_32_BIT
-
- // The base ISR takes 792 cycles
- #define ISR_BASE_CYCLES 792UL
-
- // Linear advance base time is 64 cycles
- #if ENABLED(LIN_ADVANCE)
- #define ISR_LA_BASE_CYCLES 64UL
- #else
- #define ISR_LA_BASE_CYCLES 0UL
- #endif
-
- // S curve interpolation adds 40 cycles
- #if ENABLED(S_CURVE_ACCELERATION)
- #define ISR_S_CURVE_CYCLES 40UL
- #else
- #define ISR_S_CURVE_CYCLES 0UL
- #endif
-
- // Stepper Loop base cycles
- #define ISR_LOOP_BASE_CYCLES 4UL
-
- // And each stepper takes 16 cycles
- #define ISR_STEPPER_CYCLES 16UL
-
-#else
-
- // The base ISR takes 752 cycles
- #define ISR_BASE_CYCLES 752UL
-
- // Linear advance base time is 32 cycles
- #if ENABLED(LIN_ADVANCE)
- #define ISR_LA_BASE_CYCLES 32UL
- #else
- #define ISR_LA_BASE_CYCLES 0UL
- #endif
-
- // S curve interpolation adds 160 cycles
- #if ENABLED(S_CURVE_ACCELERATION)
- #define ISR_S_CURVE_CYCLES 160UL
- #else
- #define ISR_S_CURVE_CYCLES 0UL
- #endif
-
- // Stepper Loop base cycles
- #define ISR_LOOP_BASE_CYCLES 32UL
-
- // And each stepper takes 88 cycles
- #define ISR_STEPPER_CYCLES 88UL
-
-#endif
-
-// For each stepper, we add its time
-#ifdef HAS_X_STEP
- #define ISR_X_STEPPER_CYCLES ISR_STEPPER_CYCLES
-#else
- #define ISR_X_STEPPER_CYCLES 0UL
-#endif
-
-// For each stepper, we add its time
-#ifdef HAS_Y_STEP
- #define ISR_Y_STEPPER_CYCLES ISR_STEPPER_CYCLES
-#else
- #define ISR_Y_STEPPER_CYCLES 0UL
-#endif
-
-// For each stepper, we add its time
-#ifdef HAS_Z_STEP
- #define ISR_Z_STEPPER_CYCLES ISR_STEPPER_CYCLES
-#else
- #define ISR_Z_STEPPER_CYCLES 0UL
-#endif
-
-// E is always interpolated, even for mixing extruders
-#define ISR_E_STEPPER_CYCLES ISR_STEPPER_CYCLES
-
-// If linear advance is disabled, then the loop also handles them
-#if DISABLED(LIN_ADVANCE) && ENABLED(MIXING_EXTRUDER)
- #define ISR_MIXING_STEPPER_CYCLES ((MIXING_STEPPERS) * ISR_STEPPER_CYCLES)
-#else
- #define ISR_MIXING_STEPPER_CYCLES 0UL
-#endif
-
-// And the total minimum loop time is, without including the base
-#define MIN_ISR_LOOP_CYCLES (ISR_X_STEPPER_CYCLES + ISR_Y_STEPPER_CYCLES + ISR_Z_STEPPER_CYCLES + ISR_E_STEPPER_CYCLES + ISR_MIXING_STEPPER_CYCLES)
-
-// Calculate the minimum MPU cycles needed per pulse to enforce not surpassing the maximum stepper rate
-#define _MIN_STEPPER_PULSE_CYCLES(N) MAX((F_CPU) / (MAXIMUM_STEPPER_RATE), ((F_CPU) / 500000UL) * (N))
-#if MINIMUM_STEPPER_PULSE
- #define MIN_STEPPER_PULSE_CYCLES _MIN_STEPPER_PULSE_CYCLES(MINIMUM_STEPPER_PULSE)
-#else
- #define MIN_STEPPER_PULSE_CYCLES _MIN_STEPPER_PULSE_CYCLES(1)
-#endif
-
-// But the user could be enforcing a minimum time, so the loop time is
-#define ISR_LOOP_CYCLES (ISR_LOOP_BASE_CYCLES + MAX(MIN_STEPPER_PULSE_CYCLES, MIN_ISR_LOOP_CYCLES))
-
-// If linear advance is enabled, then it is handled separately
-#if ENABLED(LIN_ADVANCE)
-
- // Estimate the minimum LA loop time
- #if ENABLED(MIXING_EXTRUDER)
- #define MIN_ISR_LA_LOOP_CYCLES ((MIXING_STEPPERS) * (ISR_STEPPER_CYCLES))
- #else
- #define MIN_ISR_LA_LOOP_CYCLES ISR_STEPPER_CYCLES
- #endif
-
- // And the real loop time
- #define ISR_LA_LOOP_CYCLES MAX(MIN_STEPPER_PULSE_CYCLES, MIN_ISR_LA_LOOP_CYCLES)
-
-#else
- #define ISR_LA_LOOP_CYCLES 0UL
-#endif
-
-// Now estimate the total ISR execution time in cycles given a step per ISR multiplier
-#define ISR_EXECUTION_CYCLES(rate) (((ISR_BASE_CYCLES + ISR_S_CURVE_CYCLES + (ISR_LOOP_CYCLES * rate) + ISR_LA_BASE_CYCLES + ISR_LA_LOOP_CYCLES)) / rate)
-
-// The maximum allowable stepping frequency when doing x128-x1 stepping (in Hz)
-#define MAX_128X_STEP_ISR_FREQUENCY (F_CPU / ISR_EXECUTION_CYCLES(128))
-#define MAX_64X_STEP_ISR_FREQUENCY (F_CPU / ISR_EXECUTION_CYCLES(64))
-#define MAX_32X_STEP_ISR_FREQUENCY (F_CPU / ISR_EXECUTION_CYCLES(32))
-#define MAX_16X_STEP_ISR_FREQUENCY (F_CPU / ISR_EXECUTION_CYCLES(16))
-#define MAX_8X_STEP_ISR_FREQUENCY (F_CPU / ISR_EXECUTION_CYCLES(8))
-#define MAX_4X_STEP_ISR_FREQUENCY (F_CPU / ISR_EXECUTION_CYCLES(4))
-#define MAX_2X_STEP_ISR_FREQUENCY (F_CPU / ISR_EXECUTION_CYCLES(2))
-#define MAX_1X_STEP_ISR_FREQUENCY (F_CPU / ISR_EXECUTION_CYCLES(1))
-
-// The minimum allowable frequency for step smoothing will be 1/10 of the maximum nominal frequency (in Hz)
-#define MIN_STEP_ISR_FREQUENCY MAX_1X_STEP_ISR_FREQUENCY
-
-// Disable multiple steps per ISR
-//#define DISABLE_MULTI_STEPPING
-
#endif // CONDITIONALS_POST_H
diff --git a/Marlin/src/module/endstops.cpp b/Marlin/src/module/endstops.cpp
index d6842a580004..acf0be796be8 100644
--- a/Marlin/src/module/endstops.cpp
+++ b/Marlin/src/module/endstops.cpp
@@ -265,7 +265,7 @@ void Endstops::not_homing() {
// Enable / disable endstop z-probe checking
#if HAS_BED_PROBE
- void Endstops::enable_z_probe(bool onoff) {
+ void Endstops::enable_z_probe(const bool onoff) {
z_probe_enabled = onoff;
#if ENABLED(ENDSTOP_INTERRUPTS_FEATURE)
@@ -439,7 +439,7 @@ void Endstops::update() {
if (stepper.axis_is_moving(X_AXIS)) {
if (stepper.motor_direction(X_AXIS_HEAD)) { // -direction
#if HAS_X_MIN
- #if ENABLED(X_DUAL_ENDSTOPS)
+ #if ENABLED(X_DUAL_ENDSTOPS) && X_HOME_DIR < 0
UPDATE_ENDSTOP_BIT(X, MIN);
#if HAS_X2_MIN
UPDATE_ENDSTOP_BIT(X2, MIN);
@@ -453,7 +453,7 @@ void Endstops::update() {
}
else { // +direction
#if HAS_X_MAX
- #if ENABLED(X_DUAL_ENDSTOPS)
+ #if ENABLED(X_DUAL_ENDSTOPS) && X_HOME_DIR > 0
UPDATE_ENDSTOP_BIT(X, MAX);
#if HAS_X2_MAX
UPDATE_ENDSTOP_BIT(X2, MAX);
@@ -469,7 +469,7 @@ void Endstops::update() {
if (stepper.axis_is_moving(Y_AXIS)) {
if (stepper.motor_direction(Y_AXIS_HEAD)) { // -direction
- #if HAS_Y_MIN
+ #if HAS_Y_MIN && Y_HOME_DIR < 0
#if ENABLED(Y_DUAL_ENDSTOPS)
UPDATE_ENDSTOP_BIT(Y, MIN);
#if HAS_Y2_MIN
@@ -483,7 +483,7 @@ void Endstops::update() {
#endif
}
else { // +direction
- #if HAS_Y_MAX
+ #if HAS_Y_MAX && Y_HOME_DIR > 0
#if ENABLED(Y_DUAL_ENDSTOPS)
UPDATE_ENDSTOP_BIT(Y, MAX);
#if HAS_Y2_MAX
@@ -501,19 +501,17 @@ void Endstops::update() {
if (stepper.axis_is_moving(Z_AXIS)) {
if (stepper.motor_direction(Z_AXIS_HEAD)) { // Z -direction. Gantry down, bed up.
#if HAS_Z_MIN
- #if ENABLED(Z_DUAL_ENDSTOPS)
+ #if ENABLED(Z_DUAL_ENDSTOPS) && Z_HOME_DIR < 0
UPDATE_ENDSTOP_BIT(Z, MIN);
#if HAS_Z2_MIN
UPDATE_ENDSTOP_BIT(Z2, MIN);
#else
COPY_BIT(live_state, Z_MIN, Z2_MIN);
#endif
- #else
- #if ENABLED(Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN)
- if (z_probe_enabled) UPDATE_ENDSTOP_BIT(Z, MIN);
- #else
- UPDATE_ENDSTOP_BIT(Z, MIN);
- #endif
+ #elif ENABLED(Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN)
+ if (z_probe_enabled) UPDATE_ENDSTOP_BIT(Z, MIN);
+ #elif Z_HOME_DIR < 0
+ UPDATE_ENDSTOP_BIT(Z, MIN);
#endif
#endif
@@ -523,7 +521,7 @@ void Endstops::update() {
#endif
}
else { // Z +direction. Gantry up, bed down.
- #if HAS_Z_MAX
+ #if HAS_Z_MAX && Z_HOME_DIR > 0
// Check both Z dual endstops
#if ENABLED(Z_DUAL_ENDSTOPS)
UPDATE_ENDSTOP_BIT(Z, MAX);
@@ -532,9 +530,8 @@ void Endstops::update() {
#else
COPY_BIT(live_state, Z_MAX, Z2_MAX);
#endif
- // If this pin is not hijacked for the bed probe
- // then it belongs to the Z endstop
#elif DISABLED(Z_MIN_PROBE_ENDSTOP) || Z_MAX_PIN != Z_MIN_PROBE_PIN
+ // If this pin isn't the bed probe it's the Z endstop
UPDATE_ENDSTOP_BIT(Z, MAX);
#endif
#endif
diff --git a/Marlin/src/module/endstops.h b/Marlin/src/module/endstops.h
index eb411570cd4b..fe5c3a7b76bf 100644
--- a/Marlin/src/module/endstops.h
+++ b/Marlin/src/module/endstops.h
@@ -143,7 +143,7 @@ class Endstops {
// Enable / disable endstop z-probe checking
#if HAS_BED_PROBE
static volatile bool z_probe_enabled;
- static void enable_z_probe(bool onoff=true);
+ static void enable_z_probe(const bool onoff=true);
#endif
// Debugging of endstops
diff --git a/Marlin/src/module/planner.cpp b/Marlin/src/module/planner.cpp
index db02c8f43889..6393829fe9a1 100644
--- a/Marlin/src/module/planner.cpp
+++ b/Marlin/src/module/planner.cpp
@@ -745,8 +745,8 @@ void Planner::calculate_trapezoid_for_block(block_t* const block, const float &e
#if ENABLED(S_CURVE_ACCELERATION)
// Jerk controlled speed requires to express speed versus time, NOT steps
- uint32_t acceleration_time = ((float)(cruise_rate - initial_rate) / accel) * (HAL_STEPPER_TIMER_RATE),
- deceleration_time = ((float)(cruise_rate - final_rate) / accel) * (HAL_STEPPER_TIMER_RATE);
+ uint32_t acceleration_time = ((float)(cruise_rate - initial_rate) / accel) * (STEPPER_TIMER_RATE),
+ deceleration_time = ((float)(cruise_rate - final_rate) / accel) * (STEPPER_TIMER_RATE);
// And to offload calculations from the ISR, we also calculate the inverse of those times here
uint32_t acceleration_time_inverse = get_period_inverse(acceleration_time);
@@ -2097,11 +2097,11 @@ bool Planner::_populate_block(block_t * const block, bool split_move,
block->acceleration_steps_per_s2 = accel;
block->acceleration = accel / steps_per_mm;
#if DISABLED(S_CURVE_ACCELERATION)
- block->acceleration_rate = (uint32_t)(accel * (4096.0 * 4096.0 / (HAL_STEPPER_TIMER_RATE)));
+ block->acceleration_rate = (uint32_t)(accel * (4096.0 * 4096.0 / (STEPPER_TIMER_RATE)));
#endif
#if ENABLED(LIN_ADVANCE)
if (block->use_advance_lead) {
- block->advance_speed = (HAL_STEPPER_TIMER_RATE) / (extruder_advance_K * block->e_D_ratio * block->acceleration * axis_steps_per_mm[E_AXIS_N]);
+ block->advance_speed = (STEPPER_TIMER_RATE) / (extruder_advance_K * block->e_D_ratio * block->acceleration * axis_steps_per_mm[E_AXIS_N]);
#if ENABLED(LA_DEBUG)
if (extruder_advance_K * block->e_D_ratio * block->acceleration * 2 < SQRT(block->nominal_speed_sqr) * block->e_D_ratio)
SERIAL_ECHOLNPGM("More than 2 steps per eISR loop executed.");
diff --git a/Marlin/src/module/stepper.cpp b/Marlin/src/module/stepper.cpp
index fdedbb5f910e..369cadfb544c 100644
--- a/Marlin/src/module/stepper.cpp
+++ b/Marlin/src/module/stepper.cpp
@@ -1263,7 +1263,7 @@ void Stepper::isr() {
#else
1
#endif
- * (HAL_TICKS_PER_US)
+ * (STEPPER_TIMER_TICKS_PER_US)
);
/**
@@ -1316,10 +1316,10 @@ void Stepper::stepper_pulse_phase_isr() {
// Just update the value we will get at the end of the loop
step_events_completed += events_to_do;
- #if MINIMUM_STEPPER_PULSE
- // Get the timer count and estimate the end of the pulse
- hal_timer_t pulse_end = HAL_timer_get_count(PULSE_TIMER_NUM) + hal_timer_t((HAL_TICKS_PER_US) * (MINIMUM_STEPPER_PULSE));
- #endif
+ // Get the timer count and estimate the end of the pulse
+ hal_timer_t pulse_end = HAL_timer_get_count(PULSE_TIMER_NUM) + hal_timer_t(MIN_PULSE_TICKS);
+
+ const hal_timer_t added_step_ticks = ADDED_STEP_TICKS;
// Take multiple steps per interrupt (For high speed moves)
do {
@@ -1392,10 +1392,11 @@ void Stepper::stepper_pulse_phase_isr() {
#if MINIMUM_STEPPER_PULSE
// Just wait for the requested pulse duration
while (HAL_timer_get_count(PULSE_TIMER_NUM) < pulse_end) { /* nada */ }
- // Add to the value, the value needed for the pulse end and ensuring the maximum driver rate is enforced
- pulse_end += hal_timer_t(MIN_STEPPER_PULSE_CYCLES) - hal_timer_t((HAL_TICKS_PER_US) * (MINIMUM_STEPPER_PULSE));
#endif
+ // Add the delay needed to ensure the maximum driver rate is enforced
+ if (signed(added_step_ticks) > 0) pulse_end += hal_timer_t(added_step_ticks);
+
// Pulse stop
#if HAS_X_STEP
PULSE_STOP(X);
@@ -1423,15 +1424,15 @@ void Stepper::stepper_pulse_phase_isr() {
// Decrement the count of pending pulses to do
--events_to_do;
- #if MINIMUM_STEPPER_PULSE
- // For minimum pulse time wait after stopping pulses also
- if (events_to_do) {
- // Just wait for the requested pulse duration
- while (HAL_timer_get_count(PULSE_TIMER_NUM) < pulse_end) { /* nada */ }
+ // For minimum pulse time wait after stopping pulses also
+ if (events_to_do) {
+ // Just wait for the requested pulse duration
+ while (HAL_timer_get_count(PULSE_TIMER_NUM) < pulse_end) { /* nada */ }
+ #if MINIMUM_STEPPER_PULSE
// Add to the value, the time that the pulse must be active (to be used on the next loop)
- pulse_end += hal_timer_t((HAL_TICKS_PER_US) * (MINIMUM_STEPPER_PULSE));
- }
- #endif
+ pulse_end += hal_timer_t(MIN_PULSE_TICKS);
+ #endif
+ }
} while (events_to_do);
}
@@ -1443,7 +1444,7 @@ void Stepper::stepper_pulse_phase_isr() {
uint32_t Stepper::stepper_block_phase_isr() {
// If no queued movements, just wait 1ms for the next move
- uint32_t interval = (HAL_STEPPER_TIMER_RATE / 1000);
+ uint32_t interval = (STEPPER_TIMER_RATE / 1000);
// If there is a current block
if (current_block) {
@@ -1664,7 +1665,7 @@ uint32_t Stepper::stepper_block_phase_isr() {
uint32_t max_rate = current_block->nominal_rate; // Get the maximum rate (maximum event speed)
while (max_rate < MIN_STEP_ISR_FREQUENCY) {
max_rate <<= 1;
- if (max_rate >= MAX_1X_STEP_ISR_FREQUENCY) break;
+ if (max_rate >= MAX_STEP_ISR_FREQUENCY_1X) break;
++oversampling;
}
oversampling_factor = oversampling;
@@ -1810,13 +1811,15 @@ uint32_t Stepper::stepper_block_phase_isr() {
REV_E_DIR(active_extruder);
#endif
+ // Get the timer count and estimate the end of the pulse
+ hal_timer_t pulse_end = HAL_timer_get_count(PULSE_TIMER_NUM) + hal_timer_t(MIN_PULSE_TICKS);
+
+ const hal_timer_t added_step_ticks = ADDED_STEP_TICKS;
+
// Step E stepper if we have steps
while (LA_steps) {
- #if MINIMUM_STEPPER_PULSE
- hal_timer_t pulse_end = HAL_timer_get_count(PULSE_TIMER_NUM) + hal_timer_t((HAL_TICKS_PER_US) * (MINIMUM_STEPPER_PULSE));
- #endif
-
+ // Set the STEP pulse ON
#if ENABLED(MIXING_EXTRUDER)
MIXING_STEPPERS_LOOP(j) {
// Step mixing steppers (proportionally)
@@ -1828,15 +1831,18 @@ uint32_t Stepper::stepper_block_phase_isr() {
E_STEP_WRITE(active_extruder, !INVERT_E_STEP_PIN);
#endif
+ // Enforce a minimum duration for STEP pulse ON
#if MINIMUM_STEPPER_PULSE
// Just wait for the requested pulse duration
while (HAL_timer_get_count(PULSE_TIMER_NUM) < pulse_end) { /* nada */ }
- // Add to the value, the value needed for the pulse end and ensuring the maximum driver rate is enforced
- pulse_end += hal_timer_t(MIN_STEPPER_PULSE_CYCLES) - hal_timer_t((HAL_TICKS_PER_US) * (MINIMUM_STEPPER_PULSE));
#endif
+ // Add the delay needed to ensure the maximum driver rate is enforced
+ if (signed(added_step_ticks) > 0) pulse_end += hal_timer_t(added_step_ticks);
+
LA_steps < 0 ? ++LA_steps : --LA_steps;
+ // Set the STEP pulse OFF
#if ENABLED(MIXING_EXTRUDER)
MIXING_STEPPERS_LOOP(j) {
if (delta_error_m[j] >= 0) {
@@ -1848,12 +1854,15 @@ uint32_t Stepper::stepper_block_phase_isr() {
E_STEP_WRITE(active_extruder, INVERT_E_STEP_PIN);
#endif
- #if MINIMUM_STEPPER_PULSE
- // For minimum pulse time wait before looping
- // Just wait for the requested pulse duration
- if (LA_steps) while (HAL_timer_get_count(PULSE_TIMER_NUM) < pulse_end) { /* nada */ }
- #endif
-
+ // For minimum pulse time wait before looping
+ // Just wait for the requested pulse duration
+ if (LA_steps) {
+ while (HAL_timer_get_count(PULSE_TIMER_NUM) < pulse_end) { /* nada */ }
+ #if MINIMUM_STEPPER_PULSE
+ // Add to the value, the time that the pulse must be active (to be used on the next loop)
+ pulse_end += hal_timer_t(MIN_PULSE_TICKS);
+ #endif
+ }
} // LA_steps
return interval;
diff --git a/Marlin/src/module/stepper.h b/Marlin/src/module/stepper.h
index bda5a69ec778..eff7a5e3e13f 100644
--- a/Marlin/src/module/stepper.h
+++ b/Marlin/src/module/stepper.h
@@ -43,19 +43,169 @@
#ifndef STEPPER_H
#define STEPPER_H
+#include "../inc/MarlinConfig.h"
+
+// Disable multiple steps per ISR
+//#define DISABLE_MULTI_STEPPING
+
+//
+// Estimate the amount of time the Stepper ISR will take to execute
+//
+
+#ifndef MINIMUM_STEPPER_PULSE
+ #define MINIMUM_STEPPER_PULSE 0
+#endif
+
+#ifndef MAXIMUM_STEPPER_RATE
+ #if MINIMUM_STEPPER_PULSE
+ #define MAXIMUM_STEPPER_RATE (1000000UL / (2UL * (MINIMUM_STEPPER_PULSE)))
+ #else
+ #define MAXIMUM_STEPPER_RATE 500000UL
+ #endif
+#endif
+
+#ifdef CPU_32_BIT
+
+ // The base ISR takes 792 cycles
+ #define ISR_BASE_CYCLES 792UL
+
+ // Linear advance base time is 64 cycles
+ #if ENABLED(LIN_ADVANCE)
+ #define ISR_LA_BASE_CYCLES 64UL
+ #else
+ #define ISR_LA_BASE_CYCLES 0UL
+ #endif
+
+ // S curve interpolation adds 40 cycles
+ #if ENABLED(S_CURVE_ACCELERATION)
+ #define ISR_S_CURVE_CYCLES 40UL
+ #else
+ #define ISR_S_CURVE_CYCLES 0UL
+ #endif
+
+ // Stepper Loop base cycles
+ #define ISR_LOOP_BASE_CYCLES 4UL
+
+ // And each stepper takes 16 cycles
+ #define ISR_STEPPER_CYCLES 16UL
+
+#else
+
+ // The base ISR takes 752 cycles
+ #define ISR_BASE_CYCLES 752UL
+
+ // Linear advance base time is 32 cycles
+ #if ENABLED(LIN_ADVANCE)
+ #define ISR_LA_BASE_CYCLES 32UL
+ #else
+ #define ISR_LA_BASE_CYCLES 0UL
+ #endif
+
+ // S curve interpolation adds 160 cycles
+ #if ENABLED(S_CURVE_ACCELERATION)
+ #define ISR_S_CURVE_CYCLES 160UL
+ #else
+ #define ISR_S_CURVE_CYCLES 0UL
+ #endif
+
+ // Stepper Loop base cycles
+ #define ISR_LOOP_BASE_CYCLES 32UL
+
+ // And each stepper takes 88 cycles
+ #define ISR_STEPPER_CYCLES 88UL
+
+#endif
+
+// Add time for each stepper
+#ifdef HAS_X_STEP
+ #define ISR_X_STEPPER_CYCLES ISR_STEPPER_CYCLES
+#else
+ #define ISR_X_STEPPER_CYCLES 0UL
+#endif
+#ifdef HAS_Y_STEP
+ #define ISR_Y_STEPPER_CYCLES ISR_STEPPER_CYCLES
+#else
+ #define ISR_Y_STEPPER_CYCLES 0UL
+#endif
+#ifdef HAS_Z_STEP
+ #define ISR_Z_STEPPER_CYCLES ISR_STEPPER_CYCLES
+#else
+ #define ISR_Z_STEPPER_CYCLES 0UL
+#endif
+
+// E is always interpolated, even for mixing extruders
+#define ISR_E_STEPPER_CYCLES ISR_STEPPER_CYCLES
+
+// If linear advance is disabled, then the loop also handles them
+#if DISABLED(LIN_ADVANCE) && ENABLED(MIXING_EXTRUDER)
+ #define ISR_MIXING_STEPPER_CYCLES ((MIXING_STEPPERS) * (ISR_STEPPER_CYCLES))
+#else
+ #define ISR_MIXING_STEPPER_CYCLES 0UL
+#endif
+
+// And the total minimum loop time, not including the base
+#define MIN_ISR_LOOP_CYCLES (ISR_X_STEPPER_CYCLES + ISR_Y_STEPPER_CYCLES + ISR_Z_STEPPER_CYCLES + ISR_E_STEPPER_CYCLES + ISR_MIXING_STEPPER_CYCLES)
+
+// Calculate the minimum MPU cycles needed per pulse to enforce, limited to the max stepper rate
+#define _MIN_STEPPER_PULSE_CYCLES(N) max((F_CPU) / (MAXIMUM_STEPPER_RATE), ((F_CPU) / 500000UL) * (N))
+#if MINIMUM_STEPPER_PULSE
+ #define MIN_STEPPER_PULSE_CYCLES _MIN_STEPPER_PULSE_CYCLES(MINIMUM_STEPPER_PULSE)
+#else
+ #define MIN_STEPPER_PULSE_CYCLES _MIN_STEPPER_PULSE_CYCLES(1)
+#endif
+
+#define MIN_PULSE_TICKS ((PULSE_TIMER_TICKS_PER_US) * (MINIMUM_STEPPER_PULSE))
+#define ADDED_STEP_TICKS ((MIN_STEPPER_PULSE_CYCLES) / (PULSE_TIMER_PRESCALE) - MIN_PULSE_TICKS)
+
+// But the user could be enforcing a minimum time, so the loop time is
+#define ISR_LOOP_CYCLES (ISR_LOOP_BASE_CYCLES + max(MIN_STEPPER_PULSE_CYCLES, MIN_ISR_LOOP_CYCLES))
+
+// If linear advance is enabled, then it is handled separately
+#if ENABLED(LIN_ADVANCE)
+
+ // Estimate the minimum LA loop time
+ #if ENABLED(MIXING_EXTRUDER)
+ #define MIN_ISR_LA_LOOP_CYCLES ((MIXING_STEPPERS) * (ISR_STEPPER_CYCLES))
+ #else
+ #define MIN_ISR_LA_LOOP_CYCLES ISR_STEPPER_CYCLES
+ #endif
+
+ // And the real loop time
+ #define ISR_LA_LOOP_CYCLES max(MIN_STEPPER_PULSE_CYCLES, MIN_ISR_LA_LOOP_CYCLES)
+
+#else
+ #define ISR_LA_LOOP_CYCLES 0UL
+#endif
+
+// Now estimate the total ISR execution time in cycles given a step per ISR multiplier
+#define ISR_EXECUTION_CYCLES(R) (((ISR_BASE_CYCLES + ISR_S_CURVE_CYCLES + (ISR_LOOP_CYCLES) * (R) + ISR_LA_BASE_CYCLES + ISR_LA_LOOP_CYCLES)) / (R))
+
+// The maximum allowable stepping frequency when doing x128-x1 stepping (in Hz)
+#define MAX_STEP_ISR_FREQUENCY_128X ((F_CPU) / ISR_EXECUTION_CYCLES(128))
+#define MAX_STEP_ISR_FREQUENCY_64X ((F_CPU) / ISR_EXECUTION_CYCLES(64))
+#define MAX_STEP_ISR_FREQUENCY_32X ((F_CPU) / ISR_EXECUTION_CYCLES(32))
+#define MAX_STEP_ISR_FREQUENCY_16X ((F_CPU) / ISR_EXECUTION_CYCLES(16))
+#define MAX_STEP_ISR_FREQUENCY_8X ((F_CPU) / ISR_EXECUTION_CYCLES(8))
+#define MAX_STEP_ISR_FREQUENCY_4X ((F_CPU) / ISR_EXECUTION_CYCLES(4))
+#define MAX_STEP_ISR_FREQUENCY_2X ((F_CPU) / ISR_EXECUTION_CYCLES(2))
+#define MAX_STEP_ISR_FREQUENCY_1X ((F_CPU) / ISR_EXECUTION_CYCLES(1))
+
+// The minimum allowable frequency for step smoothing will be 1/10 of the maximum nominal frequency (in Hz)
+#define MIN_STEP_ISR_FREQUENCY MAX_STEP_ISR_FREQUENCY_1X
+
+//
+// Stepper class definition
+//
+
#include "stepper_indirection.h"
#ifdef __AVR__
#include "speed_lookuptable.h"
#endif
-#include "../inc/MarlinConfig.h"
#include "../module/planner.h"
#include "../core/language.h"
-class Stepper;
-extern Stepper stepper;
-
class Stepper {
public:
@@ -303,14 +453,14 @@ class Stepper {
// The stepping frequency limits for each multistepping rate
static const uint32_t limit[] PROGMEM = {
- ( MAX_1X_STEP_ISR_FREQUENCY ),
- ( MAX_2X_STEP_ISR_FREQUENCY >> 1),
- ( MAX_4X_STEP_ISR_FREQUENCY >> 2),
- ( MAX_8X_STEP_ISR_FREQUENCY >> 3),
- ( MAX_16X_STEP_ISR_FREQUENCY >> 4),
- ( MAX_32X_STEP_ISR_FREQUENCY >> 5),
- ( MAX_64X_STEP_ISR_FREQUENCY >> 6),
- (MAX_128X_STEP_ISR_FREQUENCY >> 7)
+ ( MAX_STEP_ISR_FREQUENCY_1X ),
+ ( MAX_STEP_ISR_FREQUENCY_2X >> 1),
+ ( MAX_STEP_ISR_FREQUENCY_4X >> 2),
+ ( MAX_STEP_ISR_FREQUENCY_8X >> 3),
+ ( MAX_STEP_ISR_FREQUENCY_16X >> 4),
+ ( MAX_STEP_ISR_FREQUENCY_32X >> 5),
+ ( MAX_STEP_ISR_FREQUENCY_64X >> 6),
+ (MAX_STEP_ISR_FREQUENCY_128X >> 7)
};
// Select the proper multistepping
@@ -321,13 +471,13 @@ class Stepper {
++idx;
};
#else
- NOMORE(step_rate, uint32_t(MAX_1X_STEP_ISR_FREQUENCY));
+ NOMORE(step_rate, uint32_t(MAX_STEP_ISR_FREQUENCY_1X));
#endif
*loops = multistep;
#ifdef CPU_32_BIT
// In case of high-performance processor, it is able to calculate in real-time
- timer = uint32_t(HAL_STEPPER_TIMER_RATE) / step_rate;
+ timer = uint32_t(STEPPER_TIMER_RATE) / step_rate;
#else
constexpr uint32_t min_step_rate = F_CPU / 500000U;
NOLESS(step_rate, min_step_rate);
@@ -367,4 +517,6 @@ class Stepper {
};
+extern Stepper stepper;
+
#endif // STEPPER_H
diff --git a/Marlin/src/module/stepper_indirection.cpp b/Marlin/src/module/stepper_indirection.cpp
index be62f9d30875..e1ac4a54ad64 100644
--- a/Marlin/src/module/stepper_indirection.cpp
+++ b/Marlin/src/module/stepper_indirection.cpp
@@ -206,8 +206,6 @@
#if ENABLED(HYBRID_THRESHOLD)
st.stealth_max_speed(12650000UL*microsteps/(256*thrs*spmm));
#endif
- #elif ENABLED(SENSORLESS_HOMING)
- st.coolstep_min_speed(1024UL * 1024UL - 1UL);
#endif
st.GSTAT(); // Clear GSTAT
}
diff --git a/Marlin/src/pins/pins_STM32F4.h b/Marlin/src/pins/pins_STM32F4.h
index 5f312a4c25b8..22c83896358a 100644
--- a/Marlin/src/pins/pins_STM32F4.h
+++ b/Marlin/src/pins/pins_STM32F4.h
@@ -20,7 +20,7 @@
*
*/
-#if !defined(STM32F4)
+#if !defined(STM32F4) && !defined(STM32F4xx)
#error "Oops! Make sure you have an STM32F4 board selected from the 'Tools -> Boards' menu."
#endif
diff --git a/platformio.ini b/platformio.ini
index 2e8182491f47..1a5f1eeac5c0 100644
--- a/platformio.ini
+++ b/platformio.ini
@@ -265,7 +265,7 @@ monitor_speed = 250000
platform = ststm32
framework = arduino
board = disco_f407vg
-build_flags = ${common.build_flags} -DUSE_STM32GENERIC -DMENU_USB_SERIAL -DMENU_SERIAL=SerialUSB
+build_flags = ${common.build_flags} -DUSE_STM32GENERIC -DSTM32GENERIC -DMENU_USB_SERIAL -DMENU_SERIAL=SerialUSB
lib_deps = ${common.lib_deps}
lib_ignore = Adafruit NeoPixel, c1921b4, TMC2130Stepper
src_filter = ${common.default_src_filter}