-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
drivers: stepper: adi: trinamic tmc5041 #79163
base: main
Are you sure you want to change the base?
drivers: stepper: adi: trinamic tmc5041 #79163
Conversation
92e4488
to
f6d112b
Compare
5d3070e
to
c1c828a
Compare
c1c828a
to
7d84fc3
Compare
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.
Device driver specific APIs go to include/zephyr/drivers/stepper/ and are not exposed using an API structure, they are just "normal" functions :)
7d16948
to
466ad9a
Compare
d5cd2cb
to
563a319
Compare
extern "C" { | ||
#endif | ||
|
||
#ifdef CONFIG_TRINAMIC_RAMP_GENERATOR |
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.
No need to ifdef these, the structs and function declarations can be visible, only the driver needs to be "ifdefed" out AKA not included in the build :)
563a319
to
295ca4a
Compare
3af7d3f
to
cf74a7c
Compare
.tzerowait = DT_PROP_OR(node, tzerowait, 0), \ | ||
.vstart = DT_PROP_OR(node, vstart, 0), .a1 = DT_PROP_OR(node, a1, 0), \ | ||
.amax = DT_PROP_OR(node, amax, 0), .d1 = DT_PROP_OR(node, d1, 0), \ | ||
.dmax = DT_PROP_OR(node, dmax, 0), .v1 = DT_PROP_OR(node, v1, 0), \ | ||
.vmax = DT_PROP_OR(node, vmax, 0), .vstop = DT_PROP_OR(node, vstop, 0), \ | ||
.vhigh = DT_PROP_OR(node, vhigh, 0), .vcoolthrs = DT_PROP_OR(node, vcoolthrs, 0), \ | ||
.iholdrun = (TMC5041_IRUN(DT_PROP_OR(node, irun, 0)) | \ | ||
TMC5041_IHOLD(DT_PROP_OR(node, ihold, 0)) | \ | ||
TMC5041_IHOLDDELAY(DT_PROP_OR(node, iholddelay, 0))), \ |
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.
Could you format this so it matches the layout of struct tmc_ramp_generator_data
?
{
.vstart = DT_PROP_OR(node, vstart, 0),
.a1 = DT_PROP_OR(node, a1, 0),
...
}
that makes it easy to read/review since you can go one by one without searching :)
Update: |
2d1293f
to
e13026e
Compare
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.
File name seems incorrect. Needs to be adi_tmc5041_stepper_controller.c
.
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 took the reference from sensors actually. over there they have names such adltc2990.c and so on, in the folder adi they use prefix ad for analog devices. Probably let's keep it that way for now?, or?
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.
On a second thought, adi_tmc sounds better
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.
is the ad_
prefix needed in the first place?
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 adi_tmc prefix looks good, it's done at some places in the project, in sensors its done widely
#79163 (comment)
drivers/stepper/adi_tmc/ad_tmc_reg.h
Outdated
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.
File needs to to have tmc5041 in its name.
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 was thinking of putting all the registers in a single file like this, I think a lot of these registers are repetitive and could be used across drivers.
#ifdef CONFIG_STEPPER_ADI_TMC5041
#define TMC5041_MOTOR_ADDR(m) (0x20 << (m))
#define TMC5041_MOTOR_ADDR_DRV(m) ((m) << 4)
#define TMC5041_MOTOR_ADDR_PWM(m) ((m) << 3)
e13026e
to
a8b150b
Compare
The reason for nack has been resolved
a8b150b
to
071d397
Compare
071d397
to
677d88c
Compare
return -EIO; | ||
} | ||
|
||
*is_moving = (FIELD_GET(TMC5041_DRV_STATUS_STST_SHIFT_BIT, reg_value) == 1U) ? true : false; |
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.
Ternary not needed here the result is already bool
const struct tmc5041_config *config = dev->config; | ||
int err; | ||
|
||
k_sem_init(&data->sem, 0, 1); |
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 could add a static declaration of the semaphore to the device definition macro and only store a pointer to it in the data, this would remove the need for this initialisation. Or just combine the two lines by setting the initial count to 1 straight away.
9bfcdfd
to
335e777
Compare
335e777
to
f10c767
Compare
This commit introduces initial structure for trinamic drivers TMC5041 is implemented with following features: - StallGuard - RAMPSTAT_POLL - RAMP_GEN Signed-off-by: Dipak Shetty <dipak.shetty@zeiss.com> Signed-off-by: Jilay Pandya <jilay.pandya@zeiss.com>
f10c767
to
493f7dc
Compare
This PR does the following:
Todos: