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

drivers: stepper: tmc: create rampgen Kconfig template #83063

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions doc/releases/migration-guide-4.1.rst
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,8 @@ Stepper
* Renamed the ``stepper_enable_constant_velocity_mode`` function to :c:func:`stepper_run`.
* Renamed the ``stepper_move`` function to :c:func:`stepper_move_by`.
* Renamed the ``stepper_set_target_position`` function to :c:func:`stepper_move_to`.
* The :kconfig:option:`STEPPER_ADI_TMC_RAMP_GEN` is now deprecated and is replaced with the new
:kconfig:option:`STEPPER_ADI_TMC5041_RAMP_GEN` option.

SPI
===
Expand Down
7 changes: 0 additions & 7 deletions drivers/stepper/adi_tmc/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,6 @@ menuconfig STEPPER_ADI_TMC

if STEPPER_ADI_TMC

config STEPPER_ADI_TMC_RAMP_GEN
bool "Use Trinamic Stepper Controller with Ramp Generator"
depends on STEPPER_ADI_TMC
default y
help
Enable ramp generator for trinamic stepper controller

config STEPPER_ADI_TMC_SPI
bool "Use Trinamic Stepper Controller with SPI"
depends on STEPPER_ADI_TMC
Expand Down
20 changes: 3 additions & 17 deletions drivers/stepper/adi_tmc/Kconfig.tmc5041
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,6 @@ config STEPPER_ADI_TMC5041
help
Stepper driver for TMC5041.

config STEPPER_ADI_TMC5041_RAMPSTAT_POLL
bool "TMC5041 poll ramp status"
depends on STEPPER_ADI_TMC5041
default y
help
When enabled, the ramp status will be polled on TMC5041, to check for events:
- TMC5041_POS_REACHED_EVENT
- TMC5041_STOP_SG_EVENT
- TMC5041_STOP_LEFT_EVENT
- TMC5041_STOP_RIGHT_EVENT

config STEPPER_ADI_TMC5041_RAMPSTAT_POLL_INTERVAL_IN_MSEC
int "TMC5041 poll ramp status interval in ms"
depends on STEPPER_ADI_TMC5041_RAMPSTAT_POLL
default 100
help
The interval in ms to poll the ramp status on TMC5041.
module = TMC5041
module-str = tmc5041
rsource "Kconfig.tmc_rampgen_template"
27 changes: 27 additions & 0 deletions drivers/stepper/adi_tmc/Kconfig.tmc_rampgen_template
dipakgmx marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# SPDX-FileCopyrightText: Copyright (c) 2024 Jilay Sandeep Pandya
# SPDX-License-Identifier: Apache-2.0

config STEPPER_ADI_$(module)_RAMPSTAT_POLL
bool "$(module-str) poll ramp status"
depends on STEPPER_ADI_$(module)
default y
help
When enabled, the ramp status will be polled on TMC, to check for events:
- TMC_POS_REACHED_EVENT
- TMC_STOP_SG_EVENT
- TMC_STOP_LEFT_EVENT
- TMC_STOP_RIGHT_EVENT

config STEPPER_ADI_$(module)_RAMPSTAT_POLL_INTERVAL_IN_MSEC
int "$(module-str) poll ramp status interval in ms"
depends on STEPPER_ADI_$(module)_RAMPSTAT_POLL
default 100
help
The interval in ms to poll the ramp status on TMC.

config STEPPER_ADI_$(module)_RAMP_GEN
bool "Use $(module-str) with Ramp Generator"
depends on STEPPER_ADI_$(module)
default y
help
Enable ramp generator for trinamic stepper controller
10 changes: 5 additions & 5 deletions drivers/stepper/adi_tmc/adi_tmc5041_stepper_controller.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ struct tmc5041_stepper_config {
const uint32_t sg_threshold_velocity;
/* parent controller required for bus communication */
const struct device *controller;
#ifdef CONFIG_STEPPER_ADI_TMC_RAMP_GEN
#ifdef CONFIG_STEPPER_ADI_TMC5041_RAMP_GEN
const struct tmc_ramp_generator_data default_ramp_config;
#endif
};
Expand Down Expand Up @@ -537,7 +537,7 @@ static int tmc5041_stepper_run(const struct device *dev, const enum stepper_dire
return 0;
}

#ifdef CONFIG_STEPPER_ADI_TMC_RAMP_GEN
#ifdef CONFIG_STEPPER_ADI_TMC5041_RAMP_GEN

int tmc5041_stepper_set_ramp(const struct device *dev,
const struct tmc_ramp_generator_data *ramp_data)
Expand Down Expand Up @@ -676,7 +676,7 @@ static int tmc5041_stepper_init(const struct device *dev)
}
}

#ifdef CONFIG_STEPPER_ADI_TMC_RAMP_GEN
#ifdef CONFIG_STEPPER_ADI_TMC5041_RAMP_GEN
err = tmc5041_stepper_set_ramp(dev, &stepper_config->default_ramp_config);
if (err != 0) {
return -EIO;
Expand All @@ -702,7 +702,7 @@ static int tmc5041_stepper_init(const struct device *dev)
COND_CODE_1(DT_PROP_EXISTS(child, stallguard_threshold_velocity), \
BUILD_ASSERT(DT_PROP(child, stallguard_threshold_velocity), \
"stallguard threshold velocity must be a positive value"), ()); \
IF_ENABLED(CONFIG_STEPPER_ADI_TMC_RAMP_GEN, (CHECK_RAMP_DT_DATA(child))); \
IF_ENABLED(CONFIG_STEPPER_ADI_TMC5041_RAMP_GEN, (CHECK_RAMP_DT_DATA(child))); \
static const struct tmc5041_stepper_config tmc5041_stepper_config_##child = { \
.controller = DEVICE_DT_GET(DT_PARENT(child)), \
.default_micro_step_res = DT_PROP(child, micro_step_res), \
Expand All @@ -712,7 +712,7 @@ static int tmc5041_stepper_init(const struct device *dev)
.sg_velocity_check_interval_ms = DT_PROP(child, \
stallguard_velocity_check_interval_ms), \
.is_sg_enabled = DT_PROP(child, activate_stallguard2), \
IF_ENABLED(CONFIG_STEPPER_ADI_TMC_RAMP_GEN, \
IF_ENABLED(CONFIG_STEPPER_ADI_TMC5041_RAMP_GEN, \
(.default_ramp_config = TMC_RAMP_DT_SPEC_GET(child))) };

#define TMC5041_STEPPER_DATA_DEFINE(child) \
Expand Down
Loading