Skip to content
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

Support for TMC5160 #73

Open
fireup924 opened this issue Aug 31, 2023 · 4 comments
Open

Support for TMC5160 #73

fireup924 opened this issue Aug 31, 2023 · 4 comments

Comments

@fireup924
Copy link

I would like to add support for TMC5160 which uses SPI but not sure where to start?

Do I add a new file call tmc_spi.c and include the two functions:

tmc_spi_write() and tmc_spi_read() ?

@terjeio
Copy link
Contributor

terjeio commented Aug 31, 2023

It is a little more involved than that, best is to start with code from another driver. There are two SPI modes for Trinamic drivers, either separate chip select lines for each drivers or a common one. The latter requires the SPI lines to be chained and the drivers appear as a single long register.

Part of the STM32F4xx driver code can be used as a starting point. To save pins you can use the existing SPI interface provided in spi.c.

@fireup924
Copy link
Author

fireup924 commented May 9, 2024

I was able to get TMC5160 working on RP2040 but only one drive is working at the moment. There's a driver.cs_pin variable declared in trinamic_motor_t struct, but don't know where I can assign it so I can use it later in tmc_spi_write() and tmc_spi_read() ?

@terjeio
Copy link
Contributor

terjeio commented May 9, 2024

The STM32F4xx driver code linked above has separate chip select lines for each driver, this board specific code has a shared line for chained drivers.

driver.c needs to be updated to handle the chip select(s), again see the STM32F4xx driver here and here. The latter code ensures the pin(s) are enabled as outputs with the level set high initially.

@fireup924
Copy link
Author

fireup924 commented May 11, 2024

Thank you for the help. I got it working now! 👍

I'm using the output from HC595 shift register for CS pins and I didn't initialize them as high and was causing SPI bus collision

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants