Browse Source

Reinstate the nop instruction as delay in non-DEDGE

When TMC2130_MINIMUM_PULSE is 0 a minimum delay is implied.
In this case, use a single "nop" instruction.
Yuri D'Elia 3 years ago
parent
commit
a9625747db
2 changed files with 5 additions and 2 deletions
  1. 2 1
      Firmware/stepper.cpp
  2. 3 1
      Firmware/tmc2130.h

+ 2 - 1
Firmware/stepper.cpp

@@ -83,7 +83,8 @@ uint16_t SP_min = 0x21FF;
 #endif
 
 #ifdef TMC2130_DEDGE_STEPPING
-static_assert(TMC2130_MINIMUM_PULSE == 0, "DEDGE requires/implies TMC2130_MINIMUM_PULSE == 0");
+static_assert(TMC2130_MINIMUM_DELAY 1, // this will fail to compile when non-empty
+              "DEDGE implies/requires an empty TMC2130_MINIMUM_DELAY");
 #define STEP_NC_HI(axis) TOGGLE(_STEP_PIN_##axis)
 #define STEP_NC_LO(axis) //NOP
 #else

+ 3 - 1
Firmware/tmc2130.h

@@ -33,8 +33,10 @@ extern uint8_t tmc2130_sg_homing_axes_mask;
 #define TMC2130_SET_DIR_DELAY 20  // minimum delay after setting direction in uS
 #define TMC2130_SET_PWR_DELAY 0   // minimum delay after changing pwr mode in uS
 
-#if TMC2130_MINIMUM_PULSE == 0
+#ifdef TMC2130_DEDGE_STEPPING
 #define TMC2130_MINIMUM_DELAY //NOP
+#elif TMC2130_MINIMUM_PULSE == 0
+#define TMC2130_MINIMUM_DELAY asm("nop")
 #else
 #define TMC2130_MINIMUM_DELAY delayMicroseconds(TMC2130_MINIMUM_PULSE)
 #endif