Skip to content

Commit 195c2c1

Browse files
jilaypandyanashif
authored andcommitted
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: Jilay Pandya <[email protected]>
1 parent 843625a commit 195c2c1

File tree

4 files changed

+13
-11
lines changed

4 files changed

+13
-11
lines changed

doc/hardware/peripherals/stepper.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ Control Stepper
2424
- Run continuously with a **constant velocity** in a specific direction until
2525
a stop is detected using :c:func:`stepper_enable_constant_velocity_mode`.
2626
- Check if the stepper is **moving** using :c:func:`stepper_is_moving`.
27+
- Register an **event callback** using :c:func:`stepper_set_event_callback`.
2728

2829
Device Tree
2930
===========

drivers/stepper/stepper_shell.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ static int cmd_stepper_move(const struct shell *sh, size_t argc, char **argv)
203203
return err;
204204
}
205205

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

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

396-
err = stepper_set_callback(dev, print_callback, NULL);
396+
err = stepper_set_event_callback(dev, print_callback, (void *)sh);
397397
if (err != 0) {
398398
shell_error(sh, "Failed to set callback: %d", err);
399399
}

include/zephyr/drivers/stepper.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ typedef void (*stepper_event_callback_t)(const struct device *dev, const enum st
180180
/**
181181
* @brief Set the callback function to be called when a stepper event occurs
182182
*
183-
* @see stepper_set_callback() for details.
183+
* @see stepper_set_event_callback() for details.
184184
*/
185185
typedef int (*stepper_set_event_callback_t)(const struct device *dev,
186186
stepper_event_callback_t callback, void *user_data);
@@ -449,11 +449,12 @@ static inline int z_impl_stepper_enable_constant_velocity_mode(
449449
* @retval -ENOSYS If not implemented by device driver
450450
* @retval 0 Success
451451
*/
452-
__syscall int stepper_set_callback(const struct device *dev, stepper_event_callback_t callback,
453-
void *user_data);
452+
__syscall int stepper_set_event_callback(const struct device *dev,
453+
stepper_event_callback_t callback, void *user_data);
454454

455-
static inline int z_impl_stepper_set_callback(const struct device *dev,
456-
stepper_event_callback_t callback, void *user_data)
455+
static inline int z_impl_stepper_set_event_callback(const struct device *dev,
456+
stepper_event_callback_t callback,
457+
void *user_data)
457458
{
458459
const struct stepper_driver_api *api = (const struct stepper_driver_api *)dev->api;
459460

tests/drivers/stepper/stepper_api/src/main.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2024 Jilay Sandeep Pandya
2+
* SPDX-FileCopyrightText: Copyright (c) 2024 Jilay Sandeep Pandya
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
@@ -17,7 +17,7 @@ struct k_poll_event stepper_event;
1717
void *user_data_received;
1818

1919
static void stepper_print_event_callback(const struct device *dev, enum stepper_event event,
20-
void *user_data)
20+
void *user_data)
2121
{
2222
user_data_received = user_data;
2323
switch (event) {
@@ -85,7 +85,7 @@ ZTEST_F(stepper, test_target_position)
8585
(void)stepper_set_max_velocity(fixture->dev, 100u);
8686

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

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

0 commit comments

Comments
 (0)