Zephyr API Documentation 4.4.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
stepper_trinamic.h
Go to the documentation of this file.
1
8
9/*
10 * SPDX-FileCopyrightText: Copyright (c) 2024 Carl Zeiss Meditec AG
11 * SPDX-FileCopyrightText: Copyright (c) 2025 Prevas A/S
12 *
13 * SPDX-License-Identifier: Apache-2.0
14 */
15
16#ifndef ZEPHYR_INCLUDE_DRIVERS_STEPPER_STEPPER_TRINAMIC_H_
17#define ZEPHYR_INCLUDE_DRIVERS_STEPPER_STEPPER_TRINAMIC_H_
18
27
28#include <stdint.h>
30
31#ifdef __cplusplus
32extern "C" {
33#endif
34
36#define TMC_RAMP_VACTUAL_SHIFT 23
37#define TMC_RAMP_XACTUAL_SHIFT 31
39
55
102
110#define TMC_RAMP_DT_SPEC_GET_COMMON(node) \
111 .vstart = DT_PROP(node, vstart), \
112 .v1 = DT_PROP(node, v1), \
113 .vmax = DT_PROP(node, vmax), \
114 .a1 = DT_PROP(node, a1), \
115 .amax = DT_PROP(node, amax), \
116 .d1 = DT_PROP(node, d1), \
117 .dmax = DT_PROP(node, dmax), \
118 .vstop = DT_PROP(node, vstop), \
119 .tzerowait = DT_PROP(node, tzerowait), \
120 .iholdrun = (TMC5XXX_IRUN(DT_PROP(node, irun)) | \
121 TMC5XXX_IHOLD(DT_PROP(node, ihold)) | \
122 TMC5XXX_IHOLDDELAY(DT_PROP(node, iholddelay))),
123
131#define TMC_RAMP_DT_SPEC_GET_TMC50XX(node) \
132 { \
133 TMC_RAMP_DT_SPEC_GET_COMMON(node) \
134 .vhigh = DT_PROP(node, vhigh), \
135 .vcoolthrs = DT_PROP(node, vcoolthrs), \
136 }
137
145#define TMC_RAMP_DT_SPEC_GET_TMC51XX(node) \
146 { \
147 TMC_RAMP_DT_SPEC_GET_COMMON(DT_DRV_INST(node)) \
148 .tpowerdown = DT_INST_PROP(node, tpowerdown), \
149 .tpwmthrs = DT_INST_PROP(node, tpwmthrs), \
150 .tcoolthrs = DT_INST_PROP(node, tcoolthrs), \
151 .thigh = DT_INST_PROP(node, thigh), \
152 }
153
165 const struct tmc_ramp_generator_data *ramp_data);
166
177
186 const struct tmc_stallguard_settings *sg_settings);
187
195 const struct tmc_stallguard_settings *sg_settings);
196
210
211#ifdef __cplusplus
212}
213#endif
214
215#endif /* ZEPHYR_INCLUDE_DRIVERS_STEPPER_STEPPER_TRINAMIC_H_ */
void tmc51xx_stepper_ctrl_configure_stallguard(const struct device *dev, const struct tmc_stallguard_settings *sg_settings)
Configure TMC51XX Stepper StallGuard settings.
int tmc50xx_stepper_ctrl_set_ramp(const struct device *dev, const struct tmc_ramp_generator_data *ramp_data)
Configure Trinamic Stepper Ramp Generator.
int tmc50xx_stepper_ctrl_set_max_velocity(const struct device *dev, uint32_t velocity)
Set the maximum velocity of the stepper motor.
void tmc50xx_stepper_ctrl_configure_stallguard(const struct device *dev, const struct tmc_stallguard_settings *sg_settings)
Configure TMC50XX Stepper StallGuard settings.
int tmc51xx_stepper_ctrl_set_max_velocity(const struct device *dev, uint32_t velocity)
Set the maximum velocity of the stepper motor.
__UINT32_TYPE__ uint32_t
Definition stdint.h:90
__UINT16_TYPE__ uint16_t
Definition stdint.h:89
Main header file for stepper hardware driver API.
Runtime device structure (in ROM) per driver instance.
Definition device.h:513
Trinamic Stepper Ramp Generator data.
Definition stepper_trinamic.h:59
uint16_t amax
Second acceleration between V1 and VMAX.
Definition stepper_trinamic.h:69
uint16_t dmax
Deceleration between VMAX and V1.
Definition stepper_trinamic.h:73
uint32_t tpowerdown
Delay time from stand still to motor current power down.
Definition stepper_trinamic.h:92
uint32_t vcoolthrs
Lower threshold velocity for switching on CoolStep and StallGuard.
Definition stepper_trinamic.h:85
uint32_t vmax
Motion ramp target velocity.
Definition stepper_trinamic.h:65
uint32_t vhigh
Velocity threshold for switching to a different chopper mode.
Definition stepper_trinamic.h:87
uint32_t vstop
Motor stop velocity.
Definition stepper_trinamic.h:75
uint32_t vstart
Motor start velocity.
Definition stepper_trinamic.h:61
uint32_t thigh
Velocity threshold for switching to a different chopper mode.
Definition stepper_trinamic.h:98
uint16_t d1
Deceleration between V1 and VSTOP.
Definition stepper_trinamic.h:71
uint32_t tcoolthrs
Lower threshold velocity for switching on CoolStep and StallGuard.
Definition stepper_trinamic.h:96
uint32_t tpwmthrs
Upper velocity threshold for StealthChop voltage PWM mode.
Definition stepper_trinamic.h:94
uint32_t iholdrun
Hold and run current settings (combined IHOLD_IRUN register value).
Definition stepper_trinamic.h:79
uint16_t tzerowait
Waiting time after ramping down to zero velocity before next movement.
Definition stepper_trinamic.h:77
uint32_t v1
First acceleration/deceleration phase threshold velocity.
Definition stepper_trinamic.h:63
uint16_t a1
First acceleration between VSTART and V1.
Definition stepper_trinamic.h:67
Trinamic Stepper StallGuard Settings.
Definition stepper_trinamic.h:43
bool is_sg_enabled
Enable StallGuard2 feature.
Definition stepper_trinamic.h:45
uint16_t sg_velocity_check_interval_ms
Stallguard should not be enabled during motor spin-up.
Definition stepper_trinamic.h:51
uint32_t sg_threshold_velocity
StallGuard2 threshold velocity.
Definition stepper_trinamic.h:53