|
@ -286,17 +286,15 @@ void checkHitEndstops() { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
#if ENABLED(COREXY) || ENABLED(COREXZ) |
|
|
#if ENABLED(COREXY) |
|
|
#if ENABLED(COREXY) |
|
|
#define CORE_AXIS_2 B_AXIS |
|
|
#define CORE_AXIS_2 B_AXIS |
|
|
#elif ENABLED(COREXZ) |
|
|
#else |
|
|
#define CORE_AXIS_2 C_AXIS |
|
|
#define CORE_AXIS_2 C_AXIS |
|
|
|
|
|
#endif |
|
|
|
|
|
#endif |
|
|
#endif |
|
|
|
|
|
|
|
|
void enable_endstops(bool check) { check_endstops = check; } |
|
|
void enable_endstops(bool check) { check_endstops = check; } |
|
|
|
|
|
|
|
|
// Check endstops - called from ISR!
|
|
|
// Check endstops - Called from ISR!
|
|
|
inline void update_endstops() { |
|
|
inline void update_endstops() { |
|
|
|
|
|
|
|
|
#if ENABLED(Z_DUAL_ENDSTOPS) |
|
|
#if ENABLED(Z_DUAL_ENDSTOPS) |
|
@ -543,32 +541,19 @@ FORCE_INLINE unsigned short calc_timer(unsigned short step_rate) { |
|
|
*/ |
|
|
*/ |
|
|
void set_stepper_direction() { |
|
|
void set_stepper_direction() { |
|
|
|
|
|
|
|
|
if (TEST(out_bits, X_AXIS)) { // A_AXIS
|
|
|
#define SET_STEP_DIR(AXIS) \ |
|
|
X_APPLY_DIR(INVERT_X_DIR, 0); |
|
|
if (TEST(out_bits, AXIS ##_AXIS)) { \ |
|
|
count_direction[X_AXIS] = -1; |
|
|
AXIS ##_APPLY_DIR(INVERT_## AXIS ##_DIR, false); \ |
|
|
} |
|
|
count_direction[AXIS ##_AXIS] = -1; \ |
|
|
else { |
|
|
} \ |
|
|
X_APPLY_DIR(!INVERT_X_DIR, 0); |
|
|
else { \ |
|
|
count_direction[X_AXIS] = 1; |
|
|
AXIS ##_APPLY_DIR(!INVERT_## AXIS ##_DIR, false); \ |
|
|
} |
|
|
count_direction[AXIS ##_AXIS] = 1; \ |
|
|
|
|
|
} |
|
|
if (TEST(out_bits, Y_AXIS)) { // B_AXIS
|
|
|
|
|
|
Y_APPLY_DIR(INVERT_Y_DIR, 0); |
|
|
|
|
|
count_direction[Y_AXIS] = -1; |
|
|
|
|
|
} |
|
|
|
|
|
else { |
|
|
|
|
|
Y_APPLY_DIR(!INVERT_Y_DIR, 0); |
|
|
|
|
|
count_direction[Y_AXIS] = 1; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (TEST(out_bits, Z_AXIS)) { // C_AXIS
|
|
|
SET_STEP_DIR(X); // A
|
|
|
Z_APPLY_DIR(INVERT_Z_DIR, 0); |
|
|
SET_STEP_DIR(Y); // B
|
|
|
count_direction[Z_AXIS] = -1; |
|
|
SET_STEP_DIR(Z); // C
|
|
|
} |
|
|
|
|
|
else { |
|
|
|
|
|
Z_APPLY_DIR(!INVERT_Z_DIR, 0); |
|
|
|
|
|
count_direction[Z_AXIS] = 1; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#if DISABLED(ADVANCE) |
|
|
#if DISABLED(ADVANCE) |
|
|
if (TEST(out_bits, E_AXIS)) { |
|
|
if (TEST(out_bits, E_AXIS)) { |
|
@ -787,65 +772,32 @@ ISR(TIMER1_COMPA_vect) { |
|
|
ISR(TIMER0_COMPA_vect) { |
|
|
ISR(TIMER0_COMPA_vect) { |
|
|
old_OCR0A += 52; // ~10kHz interrupt (250000 / 26 = 9615kHz)
|
|
|
old_OCR0A += 52; // ~10kHz interrupt (250000 / 26 = 9615kHz)
|
|
|
OCR0A = old_OCR0A; |
|
|
OCR0A = old_OCR0A; |
|
|
// Set E direction (Depends on E direction + advance)
|
|
|
|
|
|
for (unsigned char i = 0; i < 4; i++) { |
|
|
#define STEP_E_ONCE(INDEX) \ |
|
|
if (e_steps[0] != 0) { |
|
|
if (e_steps[INDEX] != 0) { \ |
|
|
E0_STEP_WRITE(INVERT_E_STEP_PIN); |
|
|
E## INDEX ##_STEP_WRITE(INVERT_E_STEP_PIN); \ |
|
|
if (e_steps[0] < 0) { |
|
|
if (e_steps[INDEX] < 0) { \ |
|
|
E0_DIR_WRITE(INVERT_E0_DIR); |
|
|
E## INDEX ##_DIR_WRITE(INVERT_E## INDEX ##_DIR); \ |
|
|
e_steps[0]++; |
|
|
e_steps[INDEX]++; \ |
|
|
E0_STEP_WRITE(!INVERT_E_STEP_PIN); |
|
|
} \ |
|
|
} |
|
|
else if (e_steps[INDEX] > 0) { \ |
|
|
else if (e_steps[0] > 0) { |
|
|
E## INDEX ##_DIR_WRITE(!INVERT_E## INDEX ##_DIR); \ |
|
|
E0_DIR_WRITE(!INVERT_E0_DIR); |
|
|
e_steps[INDEX]--; \ |
|
|
e_steps[0]--; |
|
|
} \ |
|
|
E0_STEP_WRITE(!INVERT_E_STEP_PIN); |
|
|
E## INDEX ##_STEP_WRITE(!INVERT_E_STEP_PIN); \ |
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Step all E steppers that have steps, up to 4 steps per interrupt
|
|
|
|
|
|
for (unsigned char i = 0; i < 4; i++) { |
|
|
|
|
|
STEP_E_ONCE(0); |
|
|
#if EXTRUDERS > 1 |
|
|
#if EXTRUDERS > 1 |
|
|
if (e_steps[1] != 0) { |
|
|
STEP_E_ONCE(1); |
|
|
E1_STEP_WRITE(INVERT_E_STEP_PIN); |
|
|
#if EXTRUDERS > 2 |
|
|
if (e_steps[1] < 0) { |
|
|
STEP_E_ONCE(2); |
|
|
E1_DIR_WRITE(INVERT_E1_DIR); |
|
|
#if EXTRUDERS > 3 |
|
|
e_steps[1]++; |
|
|
STEP_E_ONCE(3); |
|
|
E1_STEP_WRITE(!INVERT_E_STEP_PIN); |
|
|
#endif |
|
|
} |
|
|
#endif |
|
|
else if (e_steps[1] > 0) { |
|
|
|
|
|
E1_DIR_WRITE(!INVERT_E1_DIR); |
|
|
|
|
|
e_steps[1]--; |
|
|
|
|
|
E1_STEP_WRITE(!INVERT_E_STEP_PIN); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
#endif |
|
|
|
|
|
#if EXTRUDERS > 2 |
|
|
|
|
|
if (e_steps[2] != 0) { |
|
|
|
|
|
E2_STEP_WRITE(INVERT_E_STEP_PIN); |
|
|
|
|
|
if (e_steps[2] < 0) { |
|
|
|
|
|
E2_DIR_WRITE(INVERT_E2_DIR); |
|
|
|
|
|
e_steps[2]++; |
|
|
|
|
|
E2_STEP_WRITE(!INVERT_E_STEP_PIN); |
|
|
|
|
|
} |
|
|
|
|
|
else if (e_steps[2] > 0) { |
|
|
|
|
|
E2_DIR_WRITE(!INVERT_E2_DIR); |
|
|
|
|
|
e_steps[2]--; |
|
|
|
|
|
E2_STEP_WRITE(!INVERT_E_STEP_PIN); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
#endif |
|
|
|
|
|
#if EXTRUDERS > 3 |
|
|
|
|
|
if (e_steps[3] != 0) { |
|
|
|
|
|
E3_STEP_WRITE(INVERT_E_STEP_PIN); |
|
|
|
|
|
if (e_steps[3] < 0) { |
|
|
|
|
|
E3_DIR_WRITE(INVERT_E3_DIR); |
|
|
|
|
|
e_steps[3]++; |
|
|
|
|
|
E3_STEP_WRITE(!INVERT_E_STEP_PIN); |
|
|
|
|
|
} |
|
|
|
|
|
else if (e_steps[3] > 0) { |
|
|
|
|
|
E3_DIR_WRITE(!INVERT_E3_DIR); |
|
|
|
|
|
e_steps[3]--; |
|
|
|
|
|
E3_STEP_WRITE(!INVERT_E_STEP_PIN); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
#endif |
|
|
#endif |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|