mirror of
https://github.com/tinygo-org/drivers.git
synced 2026-07-26 10:38:41 +00:00
87c205fd65
TMC2209: Added TMC2209 support
38 lines
606 B
Go
38 lines
606 B
Go
package tmc2209
|
|
|
|
func SetMicrostepsPerStep(microsteps uint16) uint8 {
|
|
exponent := uint8(0)
|
|
microstepsShifted := microsteps >> 1
|
|
|
|
for microstepsShifted > 0 {
|
|
microstepsShifted = microstepsShifted >> 1
|
|
exponent++
|
|
}
|
|
|
|
SetMicrostepsPerStepPowerOfTwo(exponent)
|
|
return exponent
|
|
}
|
|
|
|
func SetMicrostepsPerStepPowerOfTwo(exponent uint8) {
|
|
switch exponent {
|
|
case 0:
|
|
// Set MRES_001
|
|
case 1:
|
|
// Set MRES_002
|
|
case 2:
|
|
// Set MRES_004
|
|
case 3:
|
|
// Set MRES_008
|
|
case 4:
|
|
// Set MRES_016
|
|
case 5:
|
|
// Set MRES_032
|
|
case 6:
|
|
// Set MRES_064
|
|
case 7:
|
|
// Set MRES_128
|
|
default:
|
|
// Set MRES_256
|
|
}
|
|
}
|