-
Notifications
You must be signed in to change notification settings - Fork 8.4k
Stepper tmc5160 #80784
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
Stepper tmc5160 #80784
Conversation
|
Hi @cooked, Thanks for contributing to the project. |
|
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.
remove extra newline
5286eb3 to
b7484dc
Compare
|
Hi @jilaypandya, |
You can rename it tmc51xx in kconfig as well. tmc51xx as a driver shall serve both tmc5130 and tmc5160. |
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.
The set_ramp_parameters function is better off being within the respective drivers, i.e., tmc5041.c or tmc5160.c and then having a set_ramp_parametersfunction in stepper.h.
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.
We are gathering all trinamic specific functions in this file stepper_trinamic.h. IFDEFs are not really required coz compiler will report an error anyhow :)
|
The following west manifest projects have been modified in this Pull Request:
Note: This message is automatically posted and updated by the Manifest GitHub Action. |
| struct spi_dt_spec spi; | ||
| const uint32_t clock_frequency; | ||
| const uint16_t default_micro_step_res; | ||
| // StallGuard |
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.
Run python zephyr/scripts/ci/check_compliance.py locally before pushing, it will show you all the compliance errors. https://docs.zephyrproject.org/latest/contribute/guidelines.html
| include: | ||
| - name: spi-device.yaml | ||
| - name: adi,trinamic-gconf.yaml | ||
| property-allowlist: |
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.
gconf in tmc51xx has few more registers. You can extend adi, trinamic-gconf.yaml with those extra registers. Initially i just took stuff from tmc5041 and tmc2209, but it can be extended.
| } | ||
| if ((status_byte & BIT_MASK(1)) != 0) { | ||
| LOG_WRN("spi dataframe: driver_error(1) detected"); | ||
| LOG_WRN("spi dataframe: driver_error/driver_error(1) detected"); |
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.
drop driver_error(1)
| #include "adi_tmc_spi.h" | ||
|
|
||
| #include <zephyr/logging/log.h> | ||
|
|
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.
drop the empty line over here. :)
Signed-off-by: Stefano Cottafavi <[email protected]>
|
Since there are many more step-dir based drivers would it make sense to extract them to a device binding that can be used by multiple drivers internally? This would reduce the boilerplate for any other drivers. For inspiration what I mean you can look at the |
|
|
||
| def run(self): | ||
| exe = f"clang-format-diff.{'exe' if platform.system() == 'Windows' else 'py'}" | ||
| exe = f"clang-format-diff{'exe' if platform.system() == 'Windows' else ''}" |
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.
This change needs to be reverted
| const struct tmc5160_config *config = dev->config; | ||
| struct tmc5160_data *data = dev->data; |
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.
would it make sense to use the child device as argument to tmc5160_write, change these to dev->controller->config and dev->controller->data and just pass dev to this API? Make the code a bit more compact
| } | ||
| reg_value &= TMC5160_CHOPCONF_MRES_MASK; | ||
| reg_value >>= TMC5160_CHOPCONF_MRES_SHIFT; | ||
| *res = (1 << (MICRO_STEP_RES_INDEX(STEPPER_MICRO_STEP_256) - reg_value)); |
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.
can you do *res = BIT(MICRO_STEP_RES_INDEX(STEPPER_MICRO_STEP_256) - reg_value)?
|
|
||
| err = tmc5160_write(config->controller, TMC5160_VSTART, ramp_data->vstart); | ||
| if (err != 0) { | ||
| return -EIO; |
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.
do you have a reason to discard err and return -EIO instead? It's usually a good idea to pass through the error code, than one can log it and it may give some more information of what's wrong in the lower layers
|
This pull request has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this pull request will automatically be closed in 14 days. Note, that you can always re-open a closed pull request at any time. |
Add support for the ADI TMC5160 stepper driver, using the new stepper API