-
Notifications
You must be signed in to change notification settings - Fork 197
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added TMC5160 support #725
base: dev
Are you sure you want to change the base?
Conversation
Hello @amken3d this is a very impressive PR! Thank you for working on it. I changed the branch for it to Also, I made a comment, although did not have time to look deeply in the new code. Also, wondering if you could please add a smoketest/example? Thanks! |
@deadprogram, thank you for the kind words. Regards |
go.mod
Outdated
go 1.18 | ||
go 1.22.1 | ||
|
||
toolchain go1.23.3 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment here as above.
When i do go mod tidy, it automatically upgrades to toolchain go1.23.1 Is there a way to pin it to 1.21? I've tried everything that google suggested and failed |
I think the
|
@deadprogram : Updated |
tmc5160/tmc5160.go
Outdated
if !exists { | ||
regName = "Unknown Register" | ||
} | ||
//println("Reading reg:", regName) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove commented out lines.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
tmc5160/SPIcomm.go
Outdated
if err != nil { | ||
return 0, err | ||
} | ||
//println("Received", rx[0], rx[1], rx[2], rx[3], rx[4]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove commented out lines.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
examples/tmc5160/main.go
Outdated
// Step 1. Setup your protocol. SPI setup shown below | ||
spi := machine.SPI1 | ||
spi.Configure(machine.SPIConfig{ | ||
SCK: machine.GPIO10, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should not need to specify SCK
, SDI
, and SDO
here since they are already the defaults for SPI1
on Pico. See https://github.com/tinygo-org/tinygo/blob/release/src/machine/board_pico.go#L60-L64 and https://github.com/tinygo-org/tinygo/blob/release/src/machine/machine_rp2040_spi.go#L176-L180
The file named |
tmc5160/func_test.go
Outdated
@@ -0,0 +1,61 @@ | |||
//go:build test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think due to this directive, the tests are in this file are not being run by the CI.
See https://github.com/tinygo-org/drivers/pull/725/checks#step:7:182
If you want to exclude these tests from being run by the GH action you should add it here https://github.com/tinygo-org/drivers/blob/dev/Makefile#L22
It would be better if the tests can run, however. 😸
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed the file as it was not relevant.
tmc5160/spicomm.go
Outdated
byte(txData >> 8), // Next 8 bits of data | ||
byte(txData), // Lower 8 bits of data | ||
} | ||
//println("Sending", tx[0], tx[1], tx[2], tx[3], tx[4]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove commented out line here.
Requesting review of the the PR to add support for TMC5160. The TMC5160 is a popular stepper driver and is feature packed. This implementation add support to using the TMC5160 using either the UART mode or the SPI mode. The code has been tested to work on rp2040. The smoke tests passed using "make test". The code is not fully tested for all available features of the TMC5160 as it is a pretty complicated piece of silicon.