diff --git a/doc/releases/migration-guide-4.1.rst b/doc/releases/migration-guide-4.1.rst index d999f086274760..f8bdb8de4d2ec6 100644 --- a/doc/releases/migration-guide-4.1.rst +++ b/doc/releases/migration-guide-4.1.rst @@ -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 === diff --git a/drivers/stepper/adi_tmc/Kconfig b/drivers/stepper/adi_tmc/Kconfig index db6c6ed7f05c88..51060a5d46974d 100644 --- a/drivers/stepper/adi_tmc/Kconfig +++ b/drivers/stepper/adi_tmc/Kconfig @@ -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 diff --git a/drivers/stepper/adi_tmc/Kconfig.tmc5041 b/drivers/stepper/adi_tmc/Kconfig.tmc5041 index af3e0de4f82016..e6f01ebb1aea7e 100644 --- a/drivers/stepper/adi_tmc/Kconfig.tmc5041 +++ b/drivers/stepper/adi_tmc/Kconfig.tmc5041 @@ -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" diff --git a/drivers/stepper/adi_tmc/Kconfig.tmc_rampgen_template b/drivers/stepper/adi_tmc/Kconfig.tmc_rampgen_template new file mode 100644 index 00000000000000..34064f73b227bc --- /dev/null +++ b/drivers/stepper/adi_tmc/Kconfig.tmc_rampgen_template @@ -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 diff --git a/drivers/stepper/adi_tmc/adi_tmc5041_stepper_controller.c b/drivers/stepper/adi_tmc/adi_tmc5041_stepper_controller.c index efb88d24304edd..fd89e99c0c2f81 100644 --- a/drivers/stepper/adi_tmc/adi_tmc5041_stepper_controller.c +++ b/drivers/stepper/adi_tmc/adi_tmc5041_stepper_controller.c @@ -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 }; @@ -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) @@ -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; @@ -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), \ @@ -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) \