diff --git a/TinyG2/hardware.h b/TinyG2/hardware.h index be81ae618..ffdebef0c 100755 --- a/TinyG2/hardware.h +++ b/TinyG2/hardware.h @@ -154,7 +154,9 @@ static OutputPin grbl_feedhold_pin; static OutputPin grbl_cycle_start_pin; static OutputPin motor_common_enable_pin; -static OutputPin spindle_enable_pin; + +//Delay driving spindle output enable until we get the polarity setting +static OutputPin spindle_enable_pin(kNoInit); static OutputPin spindle_dir_pin; static PWMOutputPin spindle_pwm_pin; static PWMOutputPin secondary_pwm_pin; diff --git a/TinyG2/main.cpp b/TinyG2/main.cpp index f6c03a932..2bbdbadd0 100755 --- a/TinyG2/main.cpp +++ b/TinyG2/main.cpp @@ -159,6 +159,8 @@ void application_init_startup(void) canonical_machine_reset(); spindle_init(); // should be after PWM and canonical machine inits and config_init() spindle_reset(); + // We delayed driving spindle enable until we know the enable polarity + spindle_enable_pin.init(); // MOVED: report the system is ready is now in xio } diff --git a/TinyG2/motate/utility/SamPins.h b/TinyG2/motate/utility/SamPins.h index 3b0242f15..950228025 100755 --- a/TinyG2/motate/utility/SamPins.h +++ b/TinyG2/motate/utility/SamPins.h @@ -70,6 +70,9 @@ namespace Motate { // For use on PWM pins only! kPWMPinInverted = 1<<7, + + // Delay calling init() + kNoInit = 0xffff, }; enum PinInterruptOptions { @@ -201,7 +204,7 @@ namespace Motate { template struct OutputPin : Pin { OutputPin() : Pin(kOutput) {}; - OutputPin(const PinOptions options) : Pin(kOutput, options) {}; + OutputPin(const PinOptions options) { if(options!=kNoInit) Pin::init(kOutput, options, true);}; void init(const PinOptions options = kNormal) {Pin::init(kOutput, options);}; uint32_t get() { return Pin::getOutputValue();