Fix interrupt-based endstop detection
- Also implemented real endstop reading on interrupt.
This commit is contained in:
@ -75,7 +75,10 @@ class Stepper {
|
||||
|
||||
private:
|
||||
|
||||
static uint8_t last_direction_bits; // The next stepping-bits to be output
|
||||
static uint8_t last_direction_bits, // The next stepping-bits to be output
|
||||
last_movement_extruder; // Last movement extruder, as computed when the last movement was fetched from planner
|
||||
static bool abort_current_block, // Signals to the stepper that current block should be aborted
|
||||
last_movement_non_null[NUM_AXIS]; // Last Movement in the given direction is not null, as computed when the last movement was fetched from planner
|
||||
|
||||
#if ENABLED(X_DUAL_ENDSTOPS)
|
||||
static bool locked_x_motor, locked_x2_motor;
|
||||
@ -189,13 +192,16 @@ class Stepper {
|
||||
static void wake_up();
|
||||
|
||||
// Quickly stop all steppers
|
||||
static void quick_stop();
|
||||
FORCE_INLINE static void quick_stop() { abort_current_block = true; }
|
||||
|
||||
// The direction of a single motor
|
||||
FORCE_INLINE static bool motor_direction(const AxisEnum axis) { return TEST(last_direction_bits, axis); }
|
||||
|
||||
// Kill current block
|
||||
static void kill_current_block();
|
||||
// The last movement direction was not null on the specified axis. Note that motor direction is not necessarily the same.
|
||||
FORCE_INLINE static bool movement_non_null(const AxisEnum axis) { return last_movement_non_null[axis]; }
|
||||
|
||||
// The extruder associated to the last movement
|
||||
FORCE_INLINE static uint8_t movement_extruder() { return last_movement_extruder; }
|
||||
|
||||
// Handle a triggered endstop
|
||||
static void endstop_triggered(const AxisEnum axis);
|
||||
@ -249,7 +255,7 @@ class Stepper {
|
||||
FORCE_INLINE static uint32_t calc_timer_interval(uint32_t step_rate) {
|
||||
uint32_t timer;
|
||||
|
||||
NOMORE(step_rate, MAX_STEP_FREQUENCY);
|
||||
NOMORE(step_rate, uint32_t(MAX_STEP_FREQUENCY));
|
||||
|
||||
// TODO: HAL: tidy this up, use Conditionals_post.h
|
||||
#ifdef CPU_32_BIT
|
||||
@ -288,7 +294,7 @@ class Stepper {
|
||||
timer = uint32_t(HAL_STEPPER_TIMER_RATE) / step_rate;
|
||||
NOLESS(timer, min_time_per_step); // (STEP_DOUBLER_FREQUENCY * 2 kHz - this should never happen)
|
||||
#else
|
||||
NOLESS(step_rate, F_CPU / 500000);
|
||||
NOLESS(step_rate, uint32_t(F_CPU / 500000U));
|
||||
step_rate -= F_CPU / 500000; // Correct for minimal speed
|
||||
if (step_rate >= (8 * 256)) { // higher step rate
|
||||
uint8_t tmp_step_rate = (step_rate & 0x00FF);
|
||||
|
Reference in New Issue
Block a user