14 TMC_SW_SPI = SW_SPI_Obj;
22 TMC_SW_SPI = SW_SPI_Obj;
27 digitalWrite(_pinCS, state);
31 uint32_t response = 0UL;
32 uint32_t dummy = ((uint32_t)DRVCONF_register.address<<17) | DRVCONF_register.sr;
33 if (TMC_SW_SPI !=
nullptr) {
35 response |= TMC_SW_SPI->
transfer((dummy >> 16) & 0xFF);
37 response |= TMC_SW_SPI->
transfer((dummy >> 8) & 0xFF);
39 response |= TMC_SW_SPI->
transfer(dummy & 0xFF);
41 SPI.beginTransaction(SPISettings(spi_speed, MSBFIRST, SPI_MODE3));
43 response |= SPI.transfer((dummy >> 16) & 0xFF);
45 response |= SPI.transfer((dummy >> 8) & 0xFF);
47 response |= SPI.transfer(dummy & 0xFF);
55 uint32_t data = (uint32_t)addressByte<<17 | config;
56 if (TMC_SW_SPI !=
nullptr) {
58 TMC_SW_SPI->
transfer((data >> 16) & 0xFF);
59 TMC_SW_SPI->
transfer((data >> 8) & 0xFF);
62 SPI.beginTransaction(SPISettings(spi_speed, MSBFIRST, SPI_MODE3));
64 SPI.transfer((data >> 16) & 0xFF);
65 SPI.transfer((data >> 8) & 0xFF);
66 SPI.transfer(data & 0xFF);
74 pinMode(_pinCS, OUTPUT);
88 case 0xFFCFF:
return 1;
111 return (
float)(CS+1)/32.0 * (
vsense() ? 0.165 : 0.310)/(Rsense+0.02) / 1.41421 * 1000;
118 uint8_t CS = 32.0*1.41421*mA/1000.0*Rsense/0.310 - 1;
122 CS = 32.0*1.41421*mA/1000.0*Rsense/0.165 - 1;
135 DRVCTRL(
sdoff() ? DRVCTRL_1_register.sr : DRVCTRL_0_register.sr);
150 case 256:
mres(0);
break;
151 case 128:
mres(1);
break;
152 case 64:
mres(2);
break;
153 case 32:
mres(3);
break;
154 case 16:
mres(4);
break;
155 case 8:
mres(5);
break;
156 case 4:
mres(6);
break;
157 case 2:
mres(7);
break;
158 case 0:
mres(8);
break;
180 case 16:
tbl(0b00);
break;
181 case 24:
tbl(0b01);
break;
182 case 36:
tbl(0b10);
break;
183 case 54:
tbl(0b11);
break;
189 case 0b00:
return 16;
190 case 0b01:
return 24;
191 case 0b10:
return 36;
192 case 0b11:
return 54;