Merge pull request #13 from XPila/MK3

TMC2130 - variable Z current reference (IRUN>31 => vsense = 0, IRUN/=…
This commit is contained in:
XPila 2017-07-06 22:36:01 +02:00 committed by GitHub
commit d109602896

View File

@ -117,8 +117,16 @@ void tmc2130_init()
for (int i = 2; i < 3; i++) // Z axis
{
uint8_t mres = tmc2130_mres(TMC2130_USTEPS_Z);
if (tmc2130_current_r[i] <= 31)
{
tmc2130_wr_CHOPCONF(tmc2130_cs[i], 3, 5, 1, 0, 0, 0, 0, 2, 1, 0, 0, 0, mres, TMC2130_INTPOL_Z, 0, 0);
tmc2130_wr(tmc2130_cs[i], TMC2130_REG_IHOLD_IRUN, 0x000f0000 | ((tmc2130_current_r[i] & 0x1f) << 8) | (tmc2130_current_h[i] & 0x1f));
}
else
{
tmc2130_wr_CHOPCONF(tmc2130_cs[i], 3, 5, 1, 0, 0, 0, 0, 2, 0, 0, 0, 0, mres, TMC2130_INTPOL_Z, 0, 0);
tmc2130_wr(tmc2130_cs[i], TMC2130_REG_IHOLD_IRUN, 0x000f0000 | (((tmc2130_current_r[i] >> 1) & 0x1f) << 8) | ((tmc2130_current_h[i] >> 1) & 0x1f));
}
tmc2130_wr(tmc2130_cs[i], TMC2130_REG_TPOWERDOWN, 0x00000000);
tmc2130_wr(tmc2130_cs[i], TMC2130_REG_GCONF, 0x00000000);
}