Skip to content

Commit

Permalink
Merge branch 'bugfix-2.1.x' of https://github.com/MarlinFirmware/Marlin
Browse files Browse the repository at this point in the history
… into bugfix-2.1.x
  • Loading branch information
fnsign committed Jul 13, 2024
2 parents 9d211f1 + ad4de74 commit 4d7f8ba
Show file tree
Hide file tree
Showing 11 changed files with 42 additions and 31 deletions.
8 changes: 4 additions & 4 deletions Marlin/Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
* Serial port -1 is the USB emulated serial port, if available.
* Note: The first serial port (-1 or 0) will always be used by the Arduino bootloader.
*
* :[-1, 0, 1, 2, 3, 4, 5, 6, 7]
* :[-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
*/
#define SERIAL_PORT 2

Expand All @@ -100,22 +100,22 @@
/**
* Select a secondary serial port on the board to use for communication with the host.
* Currently Ethernet (-2) is only supported on Teensy 4.1 boards.
* :[-2, -1, 0, 1, 2, 3, 4, 5, 6, 7]
* :[-2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
*/
#define SERIAL_PORT_2 -1
//#define BAUDRATE_2 250000 // :[2400, 9600, 19200, 38400, 57600, 115200, 250000, 500000, 1000000] Enable to override BAUDRATE

/**
* Select a third serial port on the board to use for communication with the host.
* Currently only supported for AVR, DUE, LPC1768/9 and STM32/STM32F1
* :[-1, 0, 1, 2, 3, 4, 5, 6, 7]
* :[-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
*/
//#define SERIAL_PORT_3 1
//#define BAUDRATE_3 250000 // :[2400, 9600, 19200, 38400, 57600, 115200, 250000, 500000, 1000000] Enable to override BAUDRATE

/**
* Select a serial port to communicate with RS485 protocol
* :[-1, 0, 1, 2, 3, 4, 5, 6, 7]
* :[-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
*/
//#define RS485_SERIAL_PORT 1
#ifdef RS485_SERIAL_PORT
Expand Down
2 changes: 1 addition & 1 deletion Marlin/Version.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
* here we define this default string as the date where the latest release
* version was tagged.
*/
//#define STRING_DISTRIBUTION_DATE "2024-07-12"
//#define STRING_DISTRIBUTION_DATE "2024-07-13"

/**
* Defines a generic printer name to be output to the LCD after booting Marlin.
Expand Down
3 changes: 1 addition & 2 deletions Marlin/src/HAL/ESP32/timers.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,11 @@ typedef uint64_t hal_timer_t;
#if ENABLED(I2S_STEPPER_STREAM)
#define STEPPER_TIMER_PRESCALE 1
#define STEPPER_TIMER_RATE 250000 // 250khz, 4µs pulses of i2s word clock
#define STEPPER_TIMER_TICKS_PER_US ((STEPPER_TIMER_RATE) / 1000000) // stepper timer ticks per µs // wrong would be 0.25
#else
#define STEPPER_TIMER_PRESCALE 40
#define STEPPER_TIMER_RATE ((HAL_TIMER_RATE) / (STEPPER_TIMER_PRESCALE)) // frequency of stepper timer, 2MHz
#define STEPPER_TIMER_TICKS_PER_US ((STEPPER_TIMER_RATE) / 1000000) // stepper timer ticks per µs
#endif
#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

Expand Down
3 changes: 3 additions & 0 deletions Marlin/src/HAL/STM32/MarlinSerial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@
#ifndef USART5
#define USART5 UART5
#endif
#ifndef USART6
#define USART6 UART6
#endif
#ifndef USART7
#define USART7 UART7
#endif
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/HAL/TEENSY31_32/timers.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ typedef uint32_t hal_timer_t;
#define FTM0_TIMER_PRESCALE_BITS 0b011
#define FTM1_TIMER_PRESCALE_BITS 0b010

#define FTM0_TIMER_RATE (F_BUS / (FTM0_TIMER_PRESCALE)) // 60MHz / 8 = 7500kHz
#define FTM0_TIMER_RATE (F_BUS / (FTM0_TIMER_PRESCALE)) // 60MHz / 8 = 7.5MHz
#define FTM1_TIMER_RATE (F_BUS / (FTM1_TIMER_PRESCALE)) // 60MHz / 4 = 15MHz

#define HAL_TIMER_RATE (FTM0_TIMER_RATE)
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/inc/Version.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
* version was tagged.
*/
#ifndef STRING_DISTRIBUTION_DATE
#define STRING_DISTRIBUTION_DATE "2024-07-12"
#define STRING_DISTRIBUTION_DATE "2024-07-13"
#endif

/**
Expand Down
19 changes: 13 additions & 6 deletions Marlin/src/module/endstops.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
#define _ES_ENUM(A,M) A##_##M
#define ES_ENUM(A,M) _ES_ENUM(A,M)

#define _ES_ITEM(N) N,
#define _ES_ITEM(N) , N
#define ES_ITEM(K,N) TERN(K,_ES_ITEM,_IF_1_ELSE)(N)

#define _ESN_ITEM(K,A,M) ES_ITEM(K,ES_ENUM(A,M))
Expand All @@ -57,7 +57,9 @@
* - Z_MIN_PROBE is an alias to Z_MIN when the Z_MIN_PIN is being used as the probe pin.
* - When homing with the probe Z_ENDSTOP is a Z_MIN_PROBE alias, otherwise a Z_MIN/MAX alias.
*/
enum EndstopEnum : char {
enum EndstopEnum : int8_t {
_ES_START_ = -1

// Common XYZ (ABC) endstops.
ES_MINMAX(X) ES_MINMAX(Y) ES_MINMAX(Z)
ES_MINMAX(I) ES_MINMAX(J) ES_MINMAX(K)
Expand All @@ -70,12 +72,18 @@ enum EndstopEnum : char {
ES_ITEM(HAS_CALIBRATION_STATE, CALIBRATION)

// Bed Probe state is distinct or shared with Z_MIN (i.e., when the probe is the only Z endstop)
ES_ITEM(HAS_Z_PROBE_STATE, Z_MIN_PROBE IF_DISABLED(USE_Z_MIN_PROBE, = Z_MIN))
#if HAS_Z_PROBE_STATE && USE_Z_MIN_PROBE
, Z_MIN_PROBE
#endif

// The total number of states
NUM_ENDSTOP_STATES
// The total number of distinct states
, NUM_ENDSTOP_STATES

// Endstop aliases
#if HAS_Z_PROBE_STATE && !USE_Z_MIN_PROBE
, Z_MIN_PROBE = Z_MIN
#endif

#if HAS_X_STATE
, X_ENDSTOP = TERN(X_HOME_TO_MAX, X_MAX, X_MIN)
#endif
Expand All @@ -88,7 +96,6 @@ enum EndstopEnum : char {
#if HAS_Y2_STATE
, Y2_ENDSTOP = TERN(Y_HOME_TO_MAX, Y2_MAX, Y2_MIN)
#endif

#if HOMING_Z_WITH_PROBE
, Z_ENDSTOP = Z_MIN_PROBE // "Z" endstop alias when homing with the probe
#elif HAS_Z_STATE
Expand Down
12 changes: 3 additions & 9 deletions Marlin/src/module/planner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -729,8 +729,6 @@ void Planner::init() {
#endif
#endif

#define MINIMAL_STEP_RATE 120

/**
* Get the current block for processing
* and mark the block as busy.
Expand Down Expand Up @@ -796,13 +794,9 @@ void Planner::calculate_trapezoid_for_block(block_t * const block, const_float_t
uint32_t initial_rate = entry_speed ? LROUND(entry_speed * spmm) : block->initial_rate,
final_rate = LROUND(exit_speed * spmm);

// Removing code to constrain values produces judder in direction-switching moves because the
// current discrete stepping math diverges from physical motion under constant acceleration
// when acceleration_steps_per_s2 is large compared to initial/final_rate.
NOLESS(initial_rate, uint32_t(MINIMAL_STEP_RATE));
NOLESS(final_rate, uint32_t(MINIMAL_STEP_RATE));
NOMORE(initial_rate, block->nominal_rate); // NOTE: The nominal rate may be less than MINIMAL_STEP_RATE!
NOMORE(final_rate, block->nominal_rate);
NOLESS(initial_rate, stepper.minimal_step_rate);
NOLESS(final_rate, stepper.minimal_step_rate);
NOLESS(block->nominal_rate, stepper.minimal_step_rate);

#if ANY(S_CURVE_ACCELERATION, LIN_ADVANCE)
// If we have some plateau time, the cruise rate will be the nominal rate
Expand Down
8 changes: 3 additions & 5 deletions Marlin/src/module/stepper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2201,12 +2201,10 @@ hal_timer_t Stepper::calc_timer_interval(uint32_t step_rate) {
#ifdef CPU_32_BIT

// A fast processor can just do integer division
constexpr uint32_t min_step_rate = uint32_t(STEPPER_TIMER_RATE) / HAL_TIMER_TYPE_MAX;
return step_rate > min_step_rate ? uint32_t(STEPPER_TIMER_RATE) / step_rate : HAL_TIMER_TYPE_MAX;
return step_rate > minimal_step_rate ? uint32_t(STEPPER_TIMER_RATE) / step_rate : HAL_TIMER_TYPE_MAX;

#else

constexpr uint32_t min_step_rate = (F_CPU) / 500000U; // i.e., 32 or 40
if (step_rate >= 0x0800) { // higher step rate
// AVR is able to keep up at around 65kHz Stepping ISR rate at most.
// So values for step_rate > 65535 might as well be truncated.
Expand All @@ -2220,8 +2218,8 @@ hal_timer_t Stepper::calc_timer_interval(uint32_t step_rate) {
const uint8_t gain = uint8_t(pgm_read_byte(table_address + 2));
return base - MultiU8X8toH8(uint8_t(step_rate & 0x00FF), gain);
}
else if (step_rate > min_step_rate) { // lower step rates
step_rate -= min_step_rate; // Correct for minimal speed
else if (step_rate > minimal_step_rate) { // lower step rates
step_rate -= minimal_step_rate; // Correct for minimal speed
const uintptr_t table_address = uintptr_t(&speed_lookuptable_slow[uint8_t(step_rate >> 3)]);
return uint16_t(pgm_read_word(table_address))
- ((uint16_t(pgm_read_word(table_address + 2)) * uint8_t(step_rate & 0x0007)) >> 3);
Expand Down
10 changes: 10 additions & 0 deletions Marlin/src/module/stepper.h
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,16 @@ class Stepper {

public:

// The minimal step rate ensures calculations stay within limits
// and avoid the most unreasonably slow step rates.
static constexpr uint32_t minimal_step_rate = (
#ifdef CPU_32_BIT
_MAX((STEPPER_TIMER_RATE) / HAL_TIMER_TYPE_MAX, 1U) // 32-bit shouldn't go below 1
#else
(F_CPU) / 500000U // AVR shouldn't go below 32 (16MHz) or 40 (20MHz)
#endif
);

#if ANY(HAS_EXTRA_ENDSTOPS, Z_STEPPER_AUTO_ALIGN)
static bool separate_multi_axis;
#endif
Expand Down
4 changes: 2 additions & 2 deletions Marlin/src/pins/ramps/pins_MKS_BASE_14.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@
#ifndef RGB_LED_R_PIN
#define RGB_LED_R_PIN 50
#endif
#ifndef RGB_LED_R_PIN
#ifndef RGB_LED_G_PIN
#define RGB_LED_G_PIN 51
#endif
#ifndef RGB_LED_R_PIN
#ifndef RGB_LED_B_PIN
#define RGB_LED_B_PIN 52
#endif

Expand Down

0 comments on commit 4d7f8ba

Please sign in to comment.