Merge pull request #5259 from Sebastianv650/Allow_UART-ISR_inside_Stepper
Allow UART ISRs inside the stepper ISR
This commit is contained in:
commit
3f4c02e42f
@ -331,6 +331,14 @@ void Stepper::set_directions() {
|
|||||||
ISR(TIMER1_COMPA_vect) { Stepper::isr(); }
|
ISR(TIMER1_COMPA_vect) { Stepper::isr(); }
|
||||||
|
|
||||||
void Stepper::isr() {
|
void Stepper::isr() {
|
||||||
|
//Disable Timer0 ISRs and enable global ISR again to capture UART events (incoming chars)
|
||||||
|
#if ENABLED(ADVANCE) || ENABLED(LIN_ADVANCE)
|
||||||
|
CBI(TIMSK0, OCIE0A); //estepper ISR
|
||||||
|
#endif
|
||||||
|
CBI(TIMSK0, OCIE0B); //Temperature ISR
|
||||||
|
DISABLE_STEPPER_DRIVER_INTERRUPT();
|
||||||
|
sei();
|
||||||
|
|
||||||
if (cleaning_buffer_counter) {
|
if (cleaning_buffer_counter) {
|
||||||
--cleaning_buffer_counter;
|
--cleaning_buffer_counter;
|
||||||
current_block = NULL;
|
current_block = NULL;
|
||||||
@ -339,6 +347,12 @@ void Stepper::isr() {
|
|||||||
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
|
||||||
OCR1A = 200; // Run at max speed - 10 KHz
|
OCR1A = 200; // Run at max speed - 10 KHz
|
||||||
|
//re-enable ISRs
|
||||||
|
#if ENABLED(ADVANCE) || ENABLED(LIN_ADVANCE)
|
||||||
|
SBI(TIMSK0, OCIE0A);
|
||||||
|
#endif
|
||||||
|
SBI(TIMSK0, OCIE0B);
|
||||||
|
ENABLE_STEPPER_DRIVER_INTERRUPT();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -368,6 +382,11 @@ void Stepper::isr() {
|
|||||||
if (current_block->steps[Z_AXIS] > 0) {
|
if (current_block->steps[Z_AXIS] > 0) {
|
||||||
enable_z();
|
enable_z();
|
||||||
OCR1A = 2000; // Run at slow speed - 1 KHz
|
OCR1A = 2000; // Run at slow speed - 1 KHz
|
||||||
|
#if ENABLED(ADVANCE) || ENABLED(LIN_ADVANCE)
|
||||||
|
SBI(TIMSK0, OCIE0A);
|
||||||
|
#endif
|
||||||
|
SBI(TIMSK0, OCIE0B);
|
||||||
|
ENABLE_STEPPER_DRIVER_INTERRUPT();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -378,6 +397,11 @@ void Stepper::isr() {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
OCR1A = 2000; // Run at slow speed - 1 KHz
|
OCR1A = 2000; // Run at slow speed - 1 KHz
|
||||||
|
#if ENABLED(ADVANCE) || ENABLED(LIN_ADVANCE)
|
||||||
|
SBI(TIMSK0, OCIE0A);
|
||||||
|
#endif
|
||||||
|
SBI(TIMSK0, OCIE0B);
|
||||||
|
ENABLE_STEPPER_DRIVER_INTERRUPT();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -402,10 +426,6 @@ void Stepper::isr() {
|
|||||||
// Take multiple steps per interrupt (For high speed moves)
|
// Take multiple steps per interrupt (For high speed moves)
|
||||||
bool all_steps_done = false;
|
bool all_steps_done = false;
|
||||||
for (int8_t i = 0; i < step_loops; i++) {
|
for (int8_t i = 0; i < step_loops; i++) {
|
||||||
#ifndef USBCON
|
|
||||||
customizedSerial.checkRx(); // Check for serial chars.
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if ENABLED(LIN_ADVANCE)
|
#if ENABLED(LIN_ADVANCE)
|
||||||
|
|
||||||
counter_E += current_block->steps[E_AXIS];
|
counter_E += current_block->steps[E_AXIS];
|
||||||
@ -694,6 +714,11 @@ void Stepper::isr() {
|
|||||||
current_block = NULL;
|
current_block = NULL;
|
||||||
planner.discard_current_block();
|
planner.discard_current_block();
|
||||||
}
|
}
|
||||||
|
#if ENABLED(ADVANCE) || ENABLED(LIN_ADVANCE)
|
||||||
|
SBI(TIMSK0, OCIE0A);
|
||||||
|
#endif
|
||||||
|
SBI(TIMSK0, OCIE0B);
|
||||||
|
ENABLE_STEPPER_DRIVER_INTERRUPT();
|
||||||
}
|
}
|
||||||
|
|
||||||
#if ENABLED(ADVANCE) || ENABLED(LIN_ADVANCE)
|
#if ENABLED(ADVANCE) || ENABLED(LIN_ADVANCE)
|
||||||
|
@ -1489,6 +1489,9 @@ void Temperature::set_current_temp_raw() {
|
|||||||
ISR(TIMER0_COMPB_vect) { Temperature::isr(); }
|
ISR(TIMER0_COMPB_vect) { Temperature::isr(); }
|
||||||
|
|
||||||
void Temperature::isr() {
|
void Temperature::isr() {
|
||||||
|
//Allow UART and stepper ISRs
|
||||||
|
CBI(TIMSK0, OCIE0B); //Disable Temperature ISR
|
||||||
|
sei();
|
||||||
|
|
||||||
static uint8_t temp_count = 0;
|
static uint8_t temp_count = 0;
|
||||||
static TempState temp_state = StartupDelay;
|
static TempState temp_state = StartupDelay;
|
||||||
@ -1940,4 +1943,6 @@ void Temperature::isr() {
|
|||||||
if (!endstop_monitor_count) endstop_monitor(); // report changes in endstop status
|
if (!endstop_monitor_count) endstop_monitor(); // report changes in endstop status
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
SBI(TIMSK0, OCIE0B); //re-enable Temperature ISR
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user