Commit 649ca563 authored by Jilay Pandya's avatar Jilay Pandya Committed by Benjamin Cabé
Browse files

drivers: stepper: add stop function to common step-dir lib

add stop function to common step-dir lib

Signed-off-by: default avatarJilay Pandya <jilay.pandya@outlook.com>
parent 6249470b
Loading
Loading
Loading
Loading
+1 −0
Changes for drivers/stepper/adi_tmc/adi_tmc22xx_stepper_controller.c: 1 added line, 0 removed lines.
Original line number Diff line number Diff line
@@ -152,6 +152,7 @@ static DEVICE_API(stepper, tmc22xx_stepper_api) = {
	.move_to = step_dir_stepper_common_move_to,
	.set_microstep_interval = step_dir_stepper_common_set_microstep_interval,
	.run = step_dir_stepper_common_run,
	.stop = step_dir_stepper_common_stop,
	.set_event_callback = step_dir_stepper_common_set_event_callback,
	.set_micro_step_res = tmc22xx_stepper_set_micro_step_res,
	.get_micro_step_res = tmc22xx_stepper_get_micro_step_res,
+15 −0
Changes for drivers/stepper/step_dir/step_dir_stepper_common.c: 15 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -329,6 +329,21 @@ int step_dir_stepper_common_run(const struct device *dev, const enum stepper_dir
	return 0;
}

int step_dir_stepper_common_stop(const struct device *dev)
{
	const struct step_dir_stepper_common_config *config = dev->config;
	int ret;

	ret = config->timing_source->stop(dev);
	if (ret != 0) {
		LOG_ERR("Failed to stop timing source: %d", ret);
		return ret;
	}

	stepper_trigger_callback(dev, STEPPER_EVENT_STOPPED);
	return 0;
}

int step_dir_stepper_common_set_event_callback(const struct device *dev,
					       stepper_event_callback_t callback, void *user_data)
{
+8 −0
Changes for drivers/stepper/step_dir/step_dir_stepper_common.h: 8 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -195,6 +195,14 @@ int step_dir_stepper_common_is_moving(const struct device *dev, bool *is_moving)
 */
int step_dir_stepper_common_run(const struct device *dev, const enum stepper_direction direction);

/**
 * @brief Stop the stepper motor.
 *
 * @param dev Pointer to the device structure.
 * @return 0 on success, or a negative error code on failure.
 */
int step_dir_stepper_common_stop(const struct device *dev);

/**
 * @brief Set a callback function for stepper motor events.
 *
+1 −0
Changes for drivers/stepper/ti/drv8424.c: 1 added line, 0 removed lines.
Original line number Diff line number Diff line
@@ -341,6 +341,7 @@ static DEVICE_API(stepper, drv8424_stepper_api) = {
	.get_actual_position = step_dir_stepper_common_get_actual_position,
	.set_microstep_interval = step_dir_stepper_common_set_microstep_interval,
	.run = drv8424_run,
	.stop = step_dir_stepper_common_stop,
	.set_micro_step_res = drv8424_set_micro_step_res,
	.get_micro_step_res = drv8424_get_micro_step_res,
	.set_event_callback = step_dir_stepper_common_set_event_callback,