|
@@ -565,11 +565,11 @@ void tmc2130_wr_THIGH(uint8_t axis, uint32_t val32)
|
|
|
tmc2130_wr(axis, TMC2130_REG_THIGH, val32);
|
|
|
}
|
|
|
|
|
|
-uint8_t tmc2130_usteps2mres(uint16_t usteps)
|
|
|
-{
|
|
|
- uint8_t mres = 8; while (mres && (usteps >>= 1)) mres--;
|
|
|
- return mres;
|
|
|
-}
|
|
|
+uint8_t tmc2130_usteps2mres(uint16_t usteps)
|
|
|
+{
|
|
|
+ uint8_t mres = 8; while (mres && (usteps >>= 1)) mres--;
|
|
|
+ return mres;
|
|
|
+}
|
|
|
|
|
|
uint8_t tmc2130_wr(uint8_t axis, uint8_t addr, uint32_t wval)
|
|
|
{
|
|
@@ -698,6 +698,15 @@ uint16_t tmc2130_get_res(uint8_t axis)
|
|
|
return tmc2130_mres2usteps(tmc2130_mres[axis]);
|
|
|
}
|
|
|
|
|
|
+void tmc2130_set_res(uint8_t axis, uint16_t res)
|
|
|
+{
|
|
|
+ tmc2130_mres[axis] = tmc2130_usteps2mres(res);
|
|
|
+// uint32_t u = micros();
|
|
|
+ tmc2130_setup_chopper(axis, tmc2130_mres[axis], tmc2130_current_h[axis], tmc2130_current_r[axis]);
|
|
|
+// u = micros() - u;
|
|
|
+// printf_P(PSTR("tmc2130_setup_chopper %c %lu us"), "XYZE"[axis], u);
|
|
|
+}
|
|
|
+
|
|
|
uint8_t tmc2130_get_pwr(uint8_t axis)
|
|
|
{
|
|
|
switch (axis)
|
|
@@ -872,26 +881,26 @@ void tmc2130_set_wave(uint8_t axis, uint8_t fac200)
|
|
|
break;*/
|
|
|
case 216: //calculated wave 247/1.080
|
|
|
tmc2130_wr_MSLUTSTART(axis, 0, 247);
|
|
|
- tmc2130_wr_MSLUT(axis, 0, 0x9494911e);
|
|
|
- tmc2130_wr_MSLUT(axis, 1, 0x4a94a94a);
|
|
|
- tmc2130_wr_MSLUT(axis, 2, 0x92492929);
|
|
|
- tmc2130_wr_MSLUT(axis, 3, 0x41044444);
|
|
|
- tmc2130_wr_MSLUT(axis, 4, 0x00000040);
|
|
|
- tmc2130_wr_MSLUT(axis, 5, 0xaedddf7f);
|
|
|
- tmc2130_wr_MSLUT(axis, 6, 0x94a956ad);
|
|
|
- tmc2130_wr_MSLUT(axis, 7, 0x00808448);
|
|
|
+ tmc2130_wr_MSLUT(axis, 0, 0x9494911e);
|
|
|
+ tmc2130_wr_MSLUT(axis, 1, 0x4a94a94a);
|
|
|
+ tmc2130_wr_MSLUT(axis, 2, 0x92492929);
|
|
|
+ tmc2130_wr_MSLUT(axis, 3, 0x41044444);
|
|
|
+ tmc2130_wr_MSLUT(axis, 4, 0x00000040);
|
|
|
+ tmc2130_wr_MSLUT(axis, 5, 0xaedddf7f);
|
|
|
+ tmc2130_wr_MSLUT(axis, 6, 0x94a956ad);
|
|
|
+ tmc2130_wr_MSLUT(axis, 7, 0x00808448);
|
|
|
tmc2130_wr_MSLUTSEL(axis, 4, 159, 255, 1, 2, 1, 1);
|
|
|
break;
|
|
|
case 218: //calculated wave 247/1.090
|
|
|
tmc2130_wr_MSLUTSTART(axis, 0, 247);
|
|
|
- tmc2130_wr_MSLUT(axis, 0, 0x4a49223e);
|
|
|
- tmc2130_wr_MSLUT(axis, 1, 0x4a52a529);
|
|
|
- tmc2130_wr_MSLUT(axis, 2, 0x49252529);
|
|
|
- tmc2130_wr_MSLUT(axis, 3, 0x08422224);
|
|
|
- tmc2130_wr_MSLUT(axis, 4, 0xfc008004);
|
|
|
- tmc2130_wr_MSLUT(axis, 5, 0xb6eef7df);
|
|
|
- tmc2130_wr_MSLUT(axis, 6, 0xa4aaaab5);
|
|
|
- tmc2130_wr_MSLUT(axis, 7, 0x00808448);
|
|
|
+ tmc2130_wr_MSLUT(axis, 0, 0x4a49223e);
|
|
|
+ tmc2130_wr_MSLUT(axis, 1, 0x4a52a529);
|
|
|
+ tmc2130_wr_MSLUT(axis, 2, 0x49252529);
|
|
|
+ tmc2130_wr_MSLUT(axis, 3, 0x08422224);
|
|
|
+ tmc2130_wr_MSLUT(axis, 4, 0xfc008004);
|
|
|
+ tmc2130_wr_MSLUT(axis, 5, 0xb6eef7df);
|
|
|
+ tmc2130_wr_MSLUT(axis, 6, 0xa4aaaab5);
|
|
|
+ tmc2130_wr_MSLUT(axis, 7, 0x00808448);
|
|
|
tmc2130_wr_MSLUTSEL(axis, 5, 153, 255, 1, 2, 1, 1);
|
|
|
break;
|
|
|
case 220: //calculated wave 247/1.100
|
|
@@ -908,26 +917,26 @@ void tmc2130_set_wave(uint8_t axis, uint8_t fac200)
|
|
|
break;
|
|
|
case 222: //calculated wave 247/1.110
|
|
|
tmc2130_wr_MSLUTSTART(axis, 0, 247);
|
|
|
- tmc2130_wr_MSLUT(axis, 0, 0x524910fe);
|
|
|
- tmc2130_wr_MSLUT(axis, 1, 0xa5294a52);
|
|
|
- tmc2130_wr_MSLUT(axis, 2, 0x24929294);
|
|
|
- tmc2130_wr_MSLUT(axis, 3, 0x20844489);
|
|
|
- tmc2130_wr_MSLUT(axis, 4, 0xc0004008);
|
|
|
- tmc2130_wr_MSLUT(axis, 5, 0xdbbbdf7f);
|
|
|
- tmc2130_wr_MSLUT(axis, 6, 0x252aab5a);
|
|
|
- tmc2130_wr_MSLUT(axis, 7, 0x00808449);
|
|
|
+ tmc2130_wr_MSLUT(axis, 0, 0x524910fe);
|
|
|
+ tmc2130_wr_MSLUT(axis, 1, 0xa5294a52);
|
|
|
+ tmc2130_wr_MSLUT(axis, 2, 0x24929294);
|
|
|
+ tmc2130_wr_MSLUT(axis, 3, 0x20844489);
|
|
|
+ tmc2130_wr_MSLUT(axis, 4, 0xc0004008);
|
|
|
+ tmc2130_wr_MSLUT(axis, 5, 0xdbbbdf7f);
|
|
|
+ tmc2130_wr_MSLUT(axis, 6, 0x252aab5a);
|
|
|
+ tmc2130_wr_MSLUT(axis, 7, 0x00808449);
|
|
|
tmc2130_wr_MSLUTSEL(axis, 7, 157, 255, 1, 2, 1, 1);
|
|
|
break;
|
|
|
case 224: //calculated wave 247/1.120
|
|
|
tmc2130_wr_MSLUTSTART(axis, 0, 247);
|
|
|
- tmc2130_wr_MSLUT(axis, 0, 0x292223fe);
|
|
|
- tmc2130_wr_MSLUT(axis, 1, 0x94a52949);
|
|
|
- tmc2130_wr_MSLUT(axis, 2, 0x92524a52);
|
|
|
- tmc2130_wr_MSLUT(axis, 3, 0x04222244);
|
|
|
- tmc2130_wr_MSLUT(axis, 4, 0x00000101);
|
|
|
- tmc2130_wr_MSLUT(axis, 5, 0x6dddefe0);
|
|
|
- tmc2130_wr_MSLUT(axis, 6, 0x254aad5b);
|
|
|
- tmc2130_wr_MSLUT(axis, 7, 0x00810889);
|
|
|
+ tmc2130_wr_MSLUT(axis, 0, 0x292223fe);
|
|
|
+ tmc2130_wr_MSLUT(axis, 1, 0x94a52949);
|
|
|
+ tmc2130_wr_MSLUT(axis, 2, 0x92524a52);
|
|
|
+ tmc2130_wr_MSLUT(axis, 3, 0x04222244);
|
|
|
+ tmc2130_wr_MSLUT(axis, 4, 0x00000101);
|
|
|
+ tmc2130_wr_MSLUT(axis, 5, 0x6dddefe0);
|
|
|
+ tmc2130_wr_MSLUT(axis, 6, 0x254aad5b);
|
|
|
+ tmc2130_wr_MSLUT(axis, 7, 0x00810889);
|
|
|
tmc2130_wr_MSLUTSEL(axis, 9, 164, 255, 1, 2, 1, 1);
|
|
|
break;
|
|
|
/* case 230: //calculated wave 247/1.150
|