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 <jilay.pandya@outlook.com>
This commit is contained in:
parent
843625a29b
commit
195c2c1360
4 changed files with 13 additions and 11 deletions
|
@ -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
|
||||
===========
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* 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);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue