Commit 195c2c13 authored by Jilay Pandya's avatar Jilay Pandya Committed by Anas Nashif
Browse files

drivers: stepper: fix stepper_set_event_callback c prototype and definition

This commit fixes incorrect c prototype and defintion of
stepper_set_callback to stepper_set_event_callback

Signed-off-by: default avatarJilay Pandya <jilay.pandya@outlook.com>
parent 843625a2
Loading
Loading
Loading
Loading
+1 −0
Changes for doc/hardware/peripherals/stepper.rst: 1 added line, 0 removed lines.
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ Control Stepper
- Run continuously with a **constant velocity** in a specific direction until
  a stop is detected using :c:func:`stepper_enable_constant_velocity_mode`.
- Check if the stepper is **moving** using :c:func:`stepper_is_moving`.
- Register an **event callback** using :c:func:`stepper_set_event_callback`.

Device Tree
===========
+3 −3
Changes for drivers/stepper/stepper_shell.c: 3 added lines, 3 removed lines.
Original line number Diff line number Diff line
@@ -203,7 +203,7 @@ static int cmd_stepper_move(const struct shell *sh, size_t argc, char **argv)
		return err;
	}

	err = stepper_set_callback(dev, print_callback, (void *)sh);
	err = stepper_set_event_callback(dev, print_callback, (void *)sh);
	if (err != 0) {
		shell_error(sh, "Failed to set callback: %d", err);
	}
@@ -350,7 +350,7 @@ static int cmd_stepper_set_target_position(const struct shell *sh, size_t argc,
		return err;
	}

	err = stepper_set_callback(dev, print_callback, NULL);
	err = stepper_set_event_callback(dev, print_callback, (void *)sh);
	if (err != 0) {
		shell_error(sh, "Failed to set callback: %d", err);
	}
@@ -393,7 +393,7 @@ static int cmd_stepper_enable_constant_velocity_mode(const struct shell *sh, siz
		return err;
	}

	err = stepper_set_callback(dev, print_callback, NULL);
	err = stepper_set_event_callback(dev, print_callback, (void *)sh);
	if (err != 0) {
		shell_error(sh, "Failed to set callback: %d", err);
	}
+6 −5
Changes for include/zephyr/drivers/stepper.h: 6 added lines, 5 removed lines.
Original line number Diff line number Diff line
@@ -180,7 +180,7 @@ typedef void (*stepper_event_callback_t)(const struct device *dev, const enum st
/**
 * @brief Set the callback function to be called when a stepper event occurs
 *
 * @see stepper_set_callback() for details.
 * @see stepper_set_event_callback() for details.
 */
typedef int (*stepper_set_event_callback_t)(const struct device *dev,
					    stepper_event_callback_t callback, void *user_data);
@@ -449,11 +449,12 @@ static inline int z_impl_stepper_enable_constant_velocity_mode(
 * @retval -ENOSYS If not implemented by device driver
 * @retval 0 Success
 */
__syscall int stepper_set_callback(const struct device *dev, stepper_event_callback_t callback,
				   void *user_data);
__syscall int stepper_set_event_callback(const struct device *dev,
					 stepper_event_callback_t callback, void *user_data);

static inline int z_impl_stepper_set_callback(const struct device *dev,
					      stepper_event_callback_t callback, void *user_data)
static inline int z_impl_stepper_set_event_callback(const struct device *dev,
						    stepper_event_callback_t callback,
						    void *user_data)
{
	const struct stepper_driver_api *api = (const struct stepper_driver_api *)dev->api;

+2 −2
Changes for tests/drivers/stepper/stepper_api/src/main.c: 2 added lines, 2 removed lines.
Original line number Diff line number Diff line
/*
 * Copyright 2024 Jilay Sandeep Pandya
 * SPDX-FileCopyrightText: Copyright (c) 2024 Jilay Sandeep Pandya
 *
 * SPDX-License-Identifier: Apache-2.0
 */
@@ -85,7 +85,7 @@ ZTEST_F(stepper, test_target_position)
	(void)stepper_set_max_velocity(fixture->dev, 100u);

	/* Pass the function name as user data */
	(void)stepper_set_callback(fixture->dev, fixture->callback, &fixture);
	(void)stepper_set_event_callback(fixture->dev, fixture->callback, &fixture);

	(void)stepper_set_target_position(fixture->dev, pos);