tmc2130: simplify parsing axis mask
There is no need to check if every axis bit with each for-loop iteration. We just need to check if a given axit bit is set. Change in memory: Flash: -6 bytes SRAM: 0 bytes
This commit is contained in:
parent
e88c92a8dc
commit
4e31bb94ef
|
|
@ -272,8 +272,7 @@ void tmc2130_home_enter(uint8_t axes_mask)
|
||||||
tmc2130_wait_standstill_xy(1000);
|
tmc2130_wait_standstill_xy(1000);
|
||||||
for (uint8_t axis = X_AXIS; axis <= Z_AXIS; axis++) //X Y and Z axes
|
for (uint8_t axis = X_AXIS; axis <= Z_AXIS; axis++) //X Y and Z axes
|
||||||
{
|
{
|
||||||
uint8_t mask = (X_AXIS_MASK << axis);
|
if (const uint8_t mask = axes_mask & _BV(axis); mask)
|
||||||
if (axes_mask & mask)
|
|
||||||
{
|
{
|
||||||
tmc2130_sg_homing_axes_mask |= mask;
|
tmc2130_sg_homing_axes_mask |= mask;
|
||||||
//Configuration to spreadCycle
|
//Configuration to spreadCycle
|
||||||
|
|
@ -281,8 +280,7 @@ void tmc2130_home_enter(uint8_t axes_mask)
|
||||||
tmc2130_wr(axis, TMC2130_REG_COOLCONF, (((uint32_t)tmc2130_sg_thr_home[axis]) << 16));
|
tmc2130_wr(axis, TMC2130_REG_COOLCONF, (((uint32_t)tmc2130_sg_thr_home[axis]) << 16));
|
||||||
tmc2130_wr(axis, TMC2130_REG_TCOOLTHRS, __tcoolthrs(axis));
|
tmc2130_wr(axis, TMC2130_REG_TCOOLTHRS, __tcoolthrs(axis));
|
||||||
tmc2130_setup_chopper(axis, tmc2130_mres[axis], tmc2130_current_h[axis], tmc2130_current_r_home[axis]);
|
tmc2130_setup_chopper(axis, tmc2130_mres[axis], tmc2130_current_h[axis], tmc2130_current_r_home[axis]);
|
||||||
if (mask & (X_AXIS_MASK | Y_AXIS_MASK | Z_AXIS_MASK))
|
tmc2130_wr(axis, TMC2130_REG_GCONF, TMC2130_GCONF_SGSENS); //stallguard output DIAG1, DIAG1 = pushpull
|
||||||
tmc2130_wr(axis, TMC2130_REG_GCONF, TMC2130_GCONF_SGSENS); //stallguard output DIAG1, DIAG1 = pushpull
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif //TMC2130_SG_HOMING
|
#endif //TMC2130_SG_HOMING
|
||||||
|
|
@ -298,8 +296,7 @@ void tmc2130_home_exit()
|
||||||
{
|
{
|
||||||
for (uint8_t axis = X_AXIS; axis <= Z_AXIS; axis++) //X Y and Z axes
|
for (uint8_t axis = X_AXIS; axis <= Z_AXIS; axis++) //X Y and Z axes
|
||||||
{
|
{
|
||||||
uint8_t mask = (X_AXIS_MASK << axis);
|
if (tmc2130_sg_homing_axes_mask & _BV(axis))
|
||||||
if (tmc2130_sg_homing_axes_mask & mask & (X_AXIS_MASK | Y_AXIS_MASK | Z_AXIS_MASK))
|
|
||||||
{
|
{
|
||||||
#ifndef TMC2130_STEALTH_Z
|
#ifndef TMC2130_STEALTH_Z
|
||||||
if ((tmc2130_mode == TMC2130_MODE_SILENT) && (axis != Z_AXIS))
|
if ((tmc2130_mode == TMC2130_MODE_SILENT) && (axis != Z_AXIS))
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue