diff --git a/grblHAL_Teensy4/src/driver.c b/grblHAL_Teensy4/src/driver.c index cd300d3..0821e2d 100644 --- a/grblHAL_Teensy4/src/driver.c +++ b/grblHAL_Teensy4/src/driver.c @@ -1164,7 +1164,7 @@ static void spindleSetState (spindle_state_t state, float rpm) static void spindle_set_speed (uint_fast16_t pwm_value) { if (pwm_value == spindle_pwm.off_value) { - if(settings.spindle.flags.pwm_action == SpindleAction_DisableWithZeroSPeed) + if(settings.spindle.flags.enable_rpm_controlled) spindle_off(); pwmEnabled = false; if(spindle_pwm.always_on) { @@ -1215,16 +1215,19 @@ static uint_fast16_t spindleGetPWM (float rpm) // Start or stop spindle. static void spindleSetStateVariable (spindle_state_t state, float rpm) { - if (!state.on || rpm == 0.0f) { - spindle_set_speed(spindle_pwm.off_value); - spindle_off(); - } else { #ifdef SPINDLE_DIRECTION_PIN + if (state.on) spindle_dir(state.ccw); #endif - spindle_set_speed(spindle_compute_pwm_value(&spindle_pwm, rpm, false)); + if(!settings.spindle.flags.enable_rpm_controlled) { + if (state.on) + spindle_on(); + else + spindle_off(); } + spindle_set_speed(state.on ? spindle_compute_pwm_value(&spindle_pwm, rpm, false) : spindle_pwm.off_value); + #if SPINDLE_SYNC_ENABLE if(settings.spindle.at_speed_tolerance > 0.0f) { float tolerance = rpm * settings.spindle.at_speed_tolerance / 100.0f; @@ -1278,7 +1281,7 @@ static void spindlePulseOn (uint_fast16_t pulse_length) bool spindleConfig (void) { - if((hal.spindle.cap.variable = spindle_precompute_pwm_values(&spindle_pwm, F_BUS_ACTUAL / 2))) { + if((hal.spindle.cap.variable = !settings.spindle.flags.pwm_disable && spindle_precompute_pwm_values(&spindle_pwm, F_BUS_ACTUAL / 2))) { #if SPINDLE_PWM_PIN == 12 TMR1_COMP11 = spindle_pwm.period; TMR1_CMPLD11 = spindle_pwm.period; @@ -1295,8 +1298,17 @@ bool spindleConfig (void) TMR2_SCTRL0 &= ~TMR_SCTRL_OPS; #endif hal.spindle.set_state = spindleSetStateVariable; - } else + } else { + if(pwmEnabled) + hal.spindle.set_state((spindle_state_t){0}, 0.0f); hal.spindle.set_state = spindleSetState; + } + +#if SPINDLE_SYNC_ENABLE + hal.spindle.cap.at_speed = hal.spindle.get_data == spindleGetData; +#endif + + spindle_update_caps(hal.spindle.cap.variable); return true; } @@ -1478,8 +1490,6 @@ static void settings_changed (settings_t *settings) { if(IOInitDone) { - stepperEnable(settings->steppers.deenergize); - #ifdef SQUARING_ENABLED hal.stepper.disable_motors((axes_signals_t){0}, SquaringMode_Both); #endif @@ -1491,7 +1501,7 @@ static void settings_changed (settings_t *settings) #if SPINDLE_SYNC_ENABLE - if((hal.spindle.get_data = (hal.driver_cap.spindle_at_speed = settings->spindle.ppr > 0) ? spindleGetData : NULL) && + if((hal.spindle.get_data = (hal.spindle.cap.at_speed = settings->spindle.ppr > 0) ? spindleGetData : NULL) && (spindle_encoder.ppr != settings->spindle.ppr || pidf_config_changed(&spindle_tracker.pid, &settings->position.pid))) { hal.spindle.reset_data = spindleDataReset; @@ -2233,7 +2243,7 @@ bool driver_init (void) options[strlen(options) - 1] = '\0'; hal.info = "iMXRT1062"; - hal.driver_version = "220325"; + hal.driver_version = "220710"; #ifdef BOARD_NAME hal.board = BOARD_NAME; #endif diff --git a/patches/sd_sdhc.zip b/patches/sd_sdhc.zip index 1450076..35626d8 100644 Binary files a/patches/sd_sdhc.zip and b/patches/sd_sdhc.zip differ