|
|
@ -83,7 +83,7 @@ block_t* Stepper::current_block = NULL; // A pointer to the block currently bei
|
|
|
|
// private:
|
|
|
|
// private:
|
|
|
|
|
|
|
|
|
|
|
|
uint8_t Stepper::last_direction_bits = 0; // The next stepping-bits to be output
|
|
|
|
uint8_t Stepper::last_direction_bits = 0; // The next stepping-bits to be output
|
|
|
|
uint16_t Stepper::cleaning_buffer_counter = 0;
|
|
|
|
int16_t Stepper::cleaning_buffer_counter = 0;
|
|
|
|
|
|
|
|
|
|
|
|
#if ENABLED(X_DUAL_ENDSTOPS)
|
|
|
|
#if ENABLED(X_DUAL_ENDSTOPS)
|
|
|
|
bool Stepper::locked_x_motor = false, Stepper::locked_x2_motor = false;
|
|
|
|
bool Stepper::locked_x_motor = false, Stepper::locked_x2_motor = false;
|
|
|
@ -381,7 +381,7 @@ void Stepper::isr() {
|
|
|
|
|
|
|
|
|
|
|
|
uint16_t ocr_val;
|
|
|
|
uint16_t ocr_val;
|
|
|
|
|
|
|
|
|
|
|
|
#define ENDSTOP_NOMINAL_OCR_VAL 3000 // check endstops every 1.5ms to guarantee two stepper ISRs within 5ms for BLTouch
|
|
|
|
#define ENDSTOP_NOMINAL_OCR_VAL 3000 // Check endstops every 1.5ms to guarantee two stepper ISRs within 5ms for BLTouch
|
|
|
|
#define OCR_VAL_TOLERANCE 1000 // First max delay is 2.0ms, last min delay is 0.5ms, all others 1.5ms
|
|
|
|
#define OCR_VAL_TOLERANCE 1000 // First max delay is 2.0ms, last min delay is 0.5ms, all others 1.5ms
|
|
|
|
|
|
|
|
|
|
|
|
#if DISABLED(LIN_ADVANCE)
|
|
|
|
#if DISABLED(LIN_ADVANCE)
|
|
|
@ -393,9 +393,13 @@ void Stepper::isr() {
|
|
|
|
|
|
|
|
|
|
|
|
#define _SPLIT(L) (ocr_val = (uint16_t)L)
|
|
|
|
#define _SPLIT(L) (ocr_val = (uint16_t)L)
|
|
|
|
#if ENABLED(ENDSTOP_INTERRUPTS_FEATURE)
|
|
|
|
#if ENABLED(ENDSTOP_INTERRUPTS_FEATURE)
|
|
|
|
|
|
|
|
|
|
|
|
#define SPLIT(L) _SPLIT(L)
|
|
|
|
#define SPLIT(L) _SPLIT(L)
|
|
|
|
#else // sample endstops in between step pulses
|
|
|
|
|
|
|
|
|
|
|
|
#else // !ENDSTOP_INTERRUPTS_FEATURE : Sample endstops between stepping ISRs
|
|
|
|
|
|
|
|
|
|
|
|
static uint32_t step_remaining = 0;
|
|
|
|
static uint32_t step_remaining = 0;
|
|
|
|
|
|
|
|
|
|
|
|
#define SPLIT(L) do { \
|
|
|
|
#define SPLIT(L) do { \
|
|
|
|
_SPLIT(L); \
|
|
|
|
_SPLIT(L); \
|
|
|
|
if (ENDSTOPS_ENABLED && L > ENDSTOP_NOMINAL_OCR_VAL) { \
|
|
|
|
if (ENDSTOPS_ENABLED && L > ENDSTOP_NOMINAL_OCR_VAL) { \
|
|
|
@ -407,33 +411,34 @@ void Stepper::isr() {
|
|
|
|
|
|
|
|
|
|
|
|
if (step_remaining && ENDSTOPS_ENABLED) { // Just check endstops - not yet time for a step
|
|
|
|
if (step_remaining && ENDSTOPS_ENABLED) { // Just check endstops - not yet time for a step
|
|
|
|
endstops.update();
|
|
|
|
endstops.update();
|
|
|
|
if (step_remaining > ENDSTOP_NOMINAL_OCR_VAL) {
|
|
|
|
|
|
|
|
step_remaining -= ENDSTOP_NOMINAL_OCR_VAL;
|
|
|
|
|
|
|
|
ocr_val = ENDSTOP_NOMINAL_OCR_VAL;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
ocr_val = step_remaining;
|
|
|
|
|
|
|
|
step_remaining = 0; // last one before the ISR that does the step
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Next ISR either for endstops or stepping
|
|
|
|
|
|
|
|
ocr_val = step_remaining <= ENDSTOP_NOMINAL_OCR_VAL ? step_remaining : ENDSTOP_NOMINAL_OCR_VAL;
|
|
|
|
|
|
|
|
step_remaining -= ocr_val;
|
|
|
|
_NEXT_ISR(ocr_val);
|
|
|
|
_NEXT_ISR(ocr_val);
|
|
|
|
|
|
|
|
|
|
|
|
NOLESS(OCR1A, TCNT1 + 16);
|
|
|
|
NOLESS(OCR1A, TCNT1 + 16);
|
|
|
|
|
|
|
|
|
|
|
|
_ENABLE_ISRs(); // re-enable ISRs
|
|
|
|
_ENABLE_ISRs(); // re-enable ISRs
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endif // !ENDSTOP_INTERRUPTS_FEATURE
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// When cleaning, discard the current block and run fast
|
|
|
|
|
|
|
|
//
|
|
|
|
if (cleaning_buffer_counter) {
|
|
|
|
if (cleaning_buffer_counter) {
|
|
|
|
--cleaning_buffer_counter;
|
|
|
|
|
|
|
|
current_block = NULL;
|
|
|
|
current_block = NULL;
|
|
|
|
planner.discard_current_block();
|
|
|
|
planner.discard_current_block();
|
|
|
|
|
|
|
|
if (cleaning_buffer_counter < 0)
|
|
|
|
|
|
|
|
++cleaning_buffer_counter; // Count up for endstop hit
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
--cleaning_buffer_counter; // Count down for abort print
|
|
|
|
#ifdef SD_FINISHED_RELEASECOMMAND
|
|
|
|
#ifdef SD_FINISHED_RELEASECOMMAND
|
|
|
|
if (!cleaning_buffer_counter && (SD_FINISHED_STEPPERRELEASE)) enqueue_and_echo_commands_P(PSTR(SD_FINISHED_RELEASECOMMAND));
|
|
|
|
if (!cleaning_buffer_counter && (SD_FINISHED_STEPPERRELEASE)) enqueue_and_echo_commands_P(PSTR(SD_FINISHED_RELEASECOMMAND));
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
}
|
|
|
|
_NEXT_ISR(200); // Run at max speed - 10 KHz
|
|
|
|
_NEXT_ISR(200); // Run at max speed - 10 KHz
|
|
|
|
_ENABLE_ISRs(); // re-enable ISRs
|
|
|
|
_ENABLE_ISRs();
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|