Merge pull request #2342 from vintagepc/2306-hard-reset-homing-fails

Fix #2306 hard reset homing fails
This commit is contained in:
DRracer 2019-12-15 10:51:52 +01:00 committed by GitHub
commit d6ac9e4638
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -807,15 +807,15 @@ void tmc2130_goto_step(uint8_t axis, uint8_t step, uint8_t dir, uint16_t delay_u
{
dir = tmc2130_get_inv(axis)?0:1;
int steps = (int)step - (int)(mscnt >> shift);
if (steps < 0)
{
dir ^= 1;
steps = -steps;
}
if (steps > static_cast<int>(cnt / 2))
{
dir ^= 1;
steps = cnt - steps;
steps = cnt - steps; // This can create a negative step value
}
if (steps < 0)
{
dir ^= 1;
steps = -steps;
}
cnt = steps;
}