diff --git a/Grbl_Esp32/src/Stepper.cpp b/Grbl_Esp32/src/Stepper.cpp index 6c7f8c2f..6f67cd51 100644 --- a/Grbl_Esp32/src/Stepper.cpp +++ b/Grbl_Esp32/src/Stepper.cpp @@ -68,10 +68,9 @@ typedef struct { uint32_t counter[MAX_N_AXIS]; // Counter variables for the bresenham line tracer - uint8_t step_bits; // Stores out_bits output to complete the step pulse delay - uint8_t execute_step; // Flags step execution for each interrupt. - uint8_t step_pulse_time; // Step pulse reset time after step rise - uint8_t step_outbits; // The next stepping-bits to be output + uint8_t step_bits; // Stores out_bits output to complete the step pulse delay + uint8_t execute_step; // Flags step execution for each interrupt. + uint8_t step_outbits; // The next stepping-bits to be output uint8_t dir_outbits; uint32_t steps[MAX_N_AXIS]; @@ -366,14 +365,6 @@ void stepper_init() { config->_disableDelayMicroSeconds, config->_directionDelayMicroSeconds); - switch (config->_stepType) { - case ST_I2S_STREAM: - case ST_I2S_STATIC: - // I2S stepper stream mode use callback but timer interrupt - i2s_out_set_pulse_callback(stepper_pulse_func); - break; - } - // Other stepper use timer interrupt Stepper_Timer_Init(); } @@ -404,13 +395,6 @@ void st_wake_up() { config->_axes->set_disable(false); stepper_idle = false; - // Initialize step pulse timing from settings. Here to ensure updating after re-writing. - // Step pulse delay handling is not require with ESP32 RMT...the RMT function does it. - if (config->_stepType != ST_RMT || config->_directionDelayMicroSeconds < 1) { - // Set step pulse time. Ad hoc computation from oscilloscope. Uses two's complement. - st.step_pulse_time = -(((config->_pulseMicroSeconds - 2) * ticksPerMicrosecond) >> 3); - } - // Enable Stepper Driver Interrupt Stepper_Timer_Start(); } @@ -947,7 +931,15 @@ static void IRAM_ATTR Stepper_Timer_WritePeriod(uint16_t timerTicks) { static void IRAM_ATTR Stepper_Timer_Init() { const bool isEdge = false; const bool countUp = true; - stepTimer = timerBegin(stepTimerNumber, fTimers / fStepperTimer, countUp); + + // Prepare stepping interrupt callbacks. The one that is actually + // used is determined by Stepper_Timer_Start() and _Stop() + + // Register stepper_pulse_func with the I2S subsystem + i2s_out_set_pulse_callback(stepper_pulse_func); + + // Setup a timer for direct stepping + stepTimer = timerBegin(stepTimerNumber, fTimers / fStepperTimer, countUp); timerAttachInterrupt(stepTimer, onStepperDriverTimer, isEdge); }