diff --git a/gcode.h b/gcode.h index 8a29aab..81ae4d9 100644 --- a/gcode.h +++ b/gcode.h @@ -164,6 +164,7 @@ typedef struct { float spindle_speed; // RPM float feed_rate; // Millimeters/min uint8_t tool; // Tracks tool number. NOT USED. +// int32_t line_number; // Last line number sent float position[N_AXIS]; // Where the interpreter considers the tool to be at this point in the code diff --git a/limits.c b/limits.c index 12cc248..4538dcb 100644 --- a/limits.c +++ b/limits.c @@ -122,6 +122,7 @@ void limits_disable() // mask, which prevents the stepper algorithm from executing step pulses. Homing motions typically // circumvent the processes for executing motions in normal operation. // NOTE: Only the abort runtime command can interrupt this process. +// TODO: Move limit pin-specific calls to a general function for portability. void limits_go_home(uint8_t cycle_mask) { if (sys.abort) { return; } // Block if system reset has been issued. diff --git a/motion_control.c b/motion_control.c index 2208a93..66e9701 100644 --- a/motion_control.c +++ b/motion_control.c @@ -240,13 +240,12 @@ void mc_dwell(float seconds) // executing the homing cycle. This prevents incorrect buffered plans after homing. void mc_homing_cycle() { - uint8_t limits_on; - if (bit_istrue(settings.flags,BITFLAG_INVERT_LIMIT_PINS)) { - limits_on = ((~LIMIT_PIN) & LIMIT_MASK); - } else { - limits_on = (LIMIT_PIN & LIMIT_MASK); - } - if (limits_on) { + // Check and abort homing cycle, if hard limits are already enabled. Helps prevent problems + // with machines with limits wired on both ends of travel to one limit pin. + // TODO: Move the pin-specific LIMIT_PIN call to limits.c as a function. + uint8_t limit_state = (LIMIT_PIN & LIMIT_MASK); + if (bit_isfalse(settings.flags,BITFLAG_INVERT_LIMIT_PINS)) { limit_state ^= LIMIT_MASK; } + if (limit_state) { mc_reset(); // Issue system reset and ensure spindle and coolant are shutdown. bit_true_atomic(sys.execute, (EXEC_ALARM | EXEC_CRIT_EVENT)); // Indicate homing limit critical event return;