33 void init(uint8_t slaveSelectPin) { ssPin = slaveSelectPin;
35 digitalWrite(ssPin, HIGH);
36 pinMode(ssPin, OUTPUT);
43 transfer(address & 0b11111);
44 uint8_t dataOut = transfer(0);
53 transfer(0x80 | (address & 0b11111));
63 SPISettings settings = SPISettings(500000, MSBFIRST, SPI_MODE0);
65 uint8_t transfer(uint8_t value)
67 return SPI.transfer(value);
72 digitalWrite(ssPin, LOW);
73 SPI.beginTransaction(settings);
78 digitalWrite(ssPin, HIGH);
99 wr = cr0 = cr1 = cr2 = cr3 = 0;
113 CompensatedHalf = MicroStep2,
114 CompensatedFullTwoPhaseOn = MicroStep1,
115 CompensatedFullOnePhaseOn = 200,
116 UncompensatedHalf = 201,
117 UncompensatedFull = 202,
161 void init(uint8_t slaveSelectPin)
173 wr = cr0 = cr1 = cr2 = cr3 = 0;
251 if (current >= 3000) { code = 0b11001; }
252 else if (current >= 2845) { code = 0b11000; }
253 else if (current >= 2700) { code = 0b10111; }
254 else if (current >= 2440) { code = 0b10110; }
255 else if (current >= 2240) { code = 0b10101; }
256 else if (current >= 2070) { code = 0b10100; }
257 else if (current >= 1850) { code = 0b10011; }
258 else if (current >= 1695) { code = 0b10010; }
259 else if (current >= 1520) { code = 0b10001; }
260 else if (current >= 1405) { code = 0b10000; }
261 else if (current >= 1260) { code = 0b01111; }
262 else if (current >= 1150) { code = 0b01110; }
263 else if (current >= 1060) { code = 0b01101; }
264 else if (current >= 955) { code = 0b01100; }
265 else if (current >= 870) { code = 0b01011; }
266 else if (current >= 780) { code = 0b01010; }
267 else if (current >= 715) { code = 0b01001; }
268 else if (current >= 640) { code = 0b01000; }
269 else if (current >= 585) { code = 0b00111; }
270 else if (current >= 540) { code = 0b00110; }
271 else if (current >= 485) { code = 0b00101; }
272 else if (current >= 445) { code = 0b00100; }
273 else if (current >= 395) { code = 0b00011; }
274 else if (current >= 355) { code = 0b00010; }
275 else if (current >= 245) { code = 0b00001; }
277 cr0 = (cr0 & 0b11100000) | code;
299 return ((uint16_t)sr3 << 2) | (sr4 & 3);
350 case MicroStep32: sm = 0b000;
break;
351 case MicroStep16: sm = 0b001;
break;
352 case MicroStep8: sm = 0b010;
break;
353 case MicroStep4: sm = 0b011;
break;
354 case CompensatedHalf: sm = 0b100;
break;
355 case UncompensatedHalf: sm = 0b101;
break;
356 case UncompensatedFull: sm = 0b110;
break;
357 case MicroStep128: esm = 0b001;
break;
358 case MicroStep64: esm = 0b010;
break;
359 case CompensatedFullTwoPhaseOn: esm = 0b011;
break;
360 case CompensatedFullOnePhaseOn: esm = 0b100;
break;
363 cr0 = (cr0 & ~0b11100000) | (sm << 5);
364 cr3 = (cr3 & ~0b111) | esm;
446 cr1 = (cr1 & ~0b11) | (emc & 0b11);
535 return (sr2 << 8) | sr1;
540 uint8_t wr, cr0, cr1, cr2, cr3;
void writeReg(uint8_t address, uint8_t value)
void setPwmFrequencyDouble()
void init(uint8_t slaveSelectPin)
uint8_t readStatusReg(uint8_t address)
uint16_t readLatchedStatusFlagsAndClear()
void setCurrentMilliamps(uint16_t current)
void setStepMode(uint8_t mode)
void setPwmFrequencyDefault()
void setSlaTransparencyOff()
void setSlaTransparencyOn()
void setDirection(bool value)
uint8_t readReg(uint8_t address)
void setPwmSlope(uint8_t emc)
uint16_t readNonLatchedStatusFlags()
void init(uint8_t slaveSelectPin)