@ -1144,11 +1144,14 @@ void Stepper::set_directions() {
HAL_STEP_TIMER_ISR {
HAL_STEP_TIMER_ISR {
HAL_timer_isr_prologue ( STEP_TIMER_NUM ) ;
HAL_timer_isr_prologue ( STEP_TIMER_NUM ) ;
# if ENABLED(LIN_ADVANCE)
# if ENABLED(LIN_ADVANCE)
Stepper : : advance_isr_scheduler ( ) ;
Stepper : : advance_isr_scheduler ( ) ;
# else
# else
Stepper : : isr ( ) ;
Stepper : : isr ( ) ;
# endif
# endif
HAL_timer_isr_epilogue ( STEP_TIMER_NUM ) ;
}
}
void Stepper : : isr ( ) {
void Stepper : : isr ( ) {
@ -1156,15 +1159,6 @@ void Stepper::isr() {
# define ENDSTOP_NOMINAL_OCR_VAL 1500 * HAL_TICKS_PER_US // Check endstops every 1.5ms to guarantee two stepper ISRs within 5ms for BLTouch
# define ENDSTOP_NOMINAL_OCR_VAL 1500 * HAL_TICKS_PER_US // Check endstops every 1.5ms to guarantee two stepper ISRs within 5ms for BLTouch
# define OCR_VAL_TOLERANCE 500 * HAL_TICKS_PER_US // First max delay is 2.0ms, last min delay is 0.5ms, all others 1.5ms
# define OCR_VAL_TOLERANCE 500 * HAL_TICKS_PER_US // First max delay is 2.0ms, last min delay is 0.5ms, all others 1.5ms
# if DISABLED(LIN_ADVANCE)
// Disable Timer0 ISRs and enable global ISR again to capture UART events (incoming chars)
DISABLE_TEMPERATURE_INTERRUPT ( ) ; // Temperature ISR
DISABLE_STEPPER_DRIVER_INTERRUPT ( ) ;
# ifndef CPU_32_BIT
sei ( ) ;
# endif
# endif
hal_timer_t ocr_val ;
hal_timer_t ocr_val ;
static uint32_t step_remaining = 0 ; // SPLIT function always runs. This allows 16 bit timers to be
static uint32_t step_remaining = 0 ; // SPLIT function always runs. This allows 16 bit timers to be
// used to generate the stepper ISR.
// used to generate the stepper ISR.
@ -1191,7 +1185,6 @@ void Stepper::isr() {
# if DISABLED(LIN_ADVANCE)
# if DISABLED(LIN_ADVANCE)
HAL_timer_restrain ( STEP_TIMER_NUM , STEP_TIMER_MIN_INTERVAL * HAL_TICKS_PER_US ) ;
HAL_timer_restrain ( STEP_TIMER_NUM , STEP_TIMER_MIN_INTERVAL * HAL_TICKS_PER_US ) ;
HAL_ENABLE_ISRs ( ) ;
# endif
# endif
return ;
return ;
@ -1215,7 +1208,6 @@ void Stepper::isr() {
}
}
current_block = NULL ; // Prep to get a new block after cleaning
current_block = NULL ; // Prep to get a new block after cleaning
_NEXT_ISR ( HAL_STEPPER_TIMER_RATE / 10000 ) ; // Run at max speed - 10 KHz
_NEXT_ISR ( HAL_STEPPER_TIMER_RATE / 10000 ) ; // Run at max speed - 10 KHz
HAL_ENABLE_ISRs ( ) ;
return ;
return ;
}
}
@ -1291,7 +1283,6 @@ void Stepper::isr() {
if ( current_block - > steps [ Z_AXIS ] > 0 ) {
if ( current_block - > steps [ Z_AXIS ] > 0 ) {
enable_Z ( ) ;
enable_Z ( ) ;
_NEXT_ISR ( HAL_STEPPER_TIMER_RATE / 1000 ) ; // Run at slow speed - 1 KHz
_NEXT_ISR ( HAL_STEPPER_TIMER_RATE / 1000 ) ; // Run at slow speed - 1 KHz
HAL_ENABLE_ISRs ( ) ;
return ;
return ;
}
}
# endif
# endif
@ -1299,7 +1290,6 @@ void Stepper::isr() {
else {
else {
// If no more queued moves, postpone next check for 1mS
// If no more queued moves, postpone next check for 1mS
_NEXT_ISR ( HAL_STEPPER_TIMER_RATE / 1000 ) ; // Run at slow speed - 1 KHz
_NEXT_ISR ( HAL_STEPPER_TIMER_RATE / 1000 ) ; // Run at slow speed - 1 KHz
HAL_ENABLE_ISRs ( ) ;
return ;
return ;
}
}
}
}
@ -1631,9 +1621,6 @@ void Stepper::isr() {
current_block = NULL ;
current_block = NULL ;
planner . discard_current_block ( ) ;
planner . discard_current_block ( ) ;
}
}
# if DISABLED(LIN_ADVANCE)
HAL_ENABLE_ISRs ( ) ;
# endif
}
}
# if ENABLED(LIN_ADVANCE)
# if ENABLED(LIN_ADVANCE)
@ -1755,10 +1742,6 @@ void Stepper::isr() {
}
}
void Stepper : : advance_isr_scheduler ( ) {
void Stepper : : advance_isr_scheduler ( ) {
// Disable Timer0 ISRs and enable global ISR again to capture UART events (incoming chars)
DISABLE_TEMPERATURE_INTERRUPT ( ) ; // Temperature ISR
DISABLE_STEPPER_DRIVER_INTERRUPT ( ) ;
sei ( ) ;
// Run main stepping ISR if flagged
// Run main stepping ISR if flagged
if ( ! nextMainISR ) isr ( ) ;
if ( ! nextMainISR ) isr ( ) ;
@ -1787,9 +1770,6 @@ void Stepper::isr() {
// Make sure stepper ISR doesn't monopolize the CPU
// Make sure stepper ISR doesn't monopolize the CPU
HAL_timer_restrain ( STEP_TIMER_NUM , STEP_TIMER_MIN_INTERVAL * HAL_TICKS_PER_US ) ;
HAL_timer_restrain ( STEP_TIMER_NUM , STEP_TIMER_MIN_INTERVAL * HAL_TICKS_PER_US ) ;
// Restore original ISR settings
HAL_ENABLE_ISRs ( ) ;
}
}
# endif // LIN_ADVANCE
# endif // LIN_ADVANCE