49 digitalWrite(csPin, LOW);
50 pinMode(csPin, OUTPUT);
61 uint16_t dataOut = transfer((0x8 | (address & 0b111)) << 12);
63 return dataOut & 0xFFF;
69 return readReg((uint8_t)address);
80 transfer(((address & 0b111) << 12) | (value & 0xFFF));
95 SPISettings settings = SPISettings(500000, MSBFIRST, SPI_MODE0);
97 uint16_t transfer(uint16_t value)
99 return SPI.transfer16(value);
104 digitalWrite(csPin, HIGH);
105 SPI.beginTransaction(settings);
110 SPI.endTransaction();
111 digitalWrite(csPin, LOW);
136 SlowIncMixedDec = 0b001,
139 SlowIncAutoMixedDec = 0b100,
231 driver.
readReg(HPSDRegAddr::TORQUE) == (torque & ~(1 << 10)) &&
300 return ctrl >> 1 & 1;
334 case HPSDStepMode::MicroStep1: sm = 0b0000;
break;
335 case HPSDStepMode::MicroStep2: sm = 0b0001;
break;
336 case HPSDStepMode::MicroStep4: sm = 0b0010;
break;
337 case HPSDStepMode::MicroStep8: sm = 0b0011;
break;
338 case HPSDStepMode::MicroStep16: sm = 0b0100;
break;
339 case HPSDStepMode::MicroStep32: sm = 0b0101;
break;
340 case HPSDStepMode::MicroStep64: sm = 0b0110;
break;
341 case HPSDStepMode::MicroStep128: sm = 0b0111;
break;
342 case HPSDStepMode::MicroStep256: sm = 0b1000;
break;
345 ctrl = (ctrl & 0b111110000111) | (sm << 3);
383 if (current > 8000) { current = 8000; }
402 uint8_t isgainBits = 0b11;
403 uint16_t torqueBits = ((uint32_t)768 * current) / 6875;
406 while (torqueBits > 0xFF)
412 ctrl = (ctrl & 0b110011111111) | (isgainBits << 8);
414 torque = (torque & 0b111100000000) | torqueBits;
426 decay = (decay & 0b00011111111) | (((uint8_t)mode & 0b111) << 8);
487 uint16_t ctrl, torque, off, blank, decay, stall, drive;
void setChipSelectPin(uint8_t pin)
uint16_t readReg(uint8_t address)
Reads the register at the given address and returns its raw value.
void writeDECAY()
Writes the cached value of the DECAY register to the device.
uint16_t readReg(HPSDRegAddr address)
Reads the register at the given address and returns its raw value.
void setDirection(bool value)
void writeCTRL()
Writes the cached value of the CTRL register to the device.
void writeOFF()
Writes the cached value of the OFF register to the device.
void enableDriver()
Enables the driver (ENBL = 1).
Channel A predriver fault.
void writeReg(HPSDRegAddr address, uint16_t value)
Writes the specified value to a register.
void disableDriver()
Disables the driver (ENBL = 0).
void writeTORQUE()
Writes the cached value of the TORQUE register to the device.
Channel A overcurrent shutdown.
Channel B overcurrent shutdown.
void setChipSelectPin(uint8_t pin)
Channel B predriver fault.
HPSDStepMode
Possible arguments to setStepMode().
void setStepMode(HPSDStepMode mode)
void writeBLANK()
Writes the cached value of the BLANK register to the device.
void writeDRIVE()
Writes the cached value of the DRIVE register to the device.
void setStepMode(uint16_t mode)
void writeReg(uint8_t address, uint16_t value)
Writes the specified value to a register.
void setDecayMode(HPSDDecayMode mode)
HighPowerStepperDriver()
The default constructor.
Overtemperature shutdown.
void writeSTALL()
Writes the cached value of the STALL register to the device.
HPSDDecayMode
Possible arguments to setDecayMode().
HPSDRegAddr
Addresses of control and status registers.
void setCurrentMilliamps36v4(uint16_t current)