@@ -93,6 +93,8 @@ enum stepper_event {
9393 STEPPER_EVENT_LEFT_END_STOP_DETECTED = 2 ,
9494 /** Right end switch status changes to pressed */
9595 STEPPER_EVENT_RIGHT_END_STOP_DETECTED = 3 ,
96+ /** Stepper has stopped */
97+ STEPPER_EVENT_STOPPED = 4 ,
9698};
9799
98100/**
@@ -179,6 +181,13 @@ typedef int (*stepper_move_to_t)(const struct device *dev, const int32_t micro_s
179181 */
180182typedef int (* stepper_run_t )(const struct device * dev , const enum stepper_direction direction );
181183
184+ /**
185+ * @brief Stop the stepper
186+ *
187+ * @see stepper_stop() for details.
188+ */
189+ typedef int (* stepper_stop_t )(const struct device * dev );
190+
182191/**
183192 * @brief Is the target position fo the stepper reached
184193 *
@@ -200,6 +209,7 @@ __subsystem struct stepper_driver_api {
200209 stepper_move_by_t move_by ;
201210 stepper_move_to_t move_to ;
202211 stepper_run_t run ;
212+ stepper_stop_t stop ;
203213 stepper_is_moving_t is_moving ;
204214};
205215
@@ -211,7 +221,7 @@ __subsystem struct stepper_driver_api {
211221 * @brief Enable or disable stepper driver
212222 *
213223 * @details Enabling the driver will energize the coils, however not set the stepper in motion.
214- * Disabling the driver will de-energize the coils.
224+ * Disabling the driver shall cancel all active movements and de-energize the coils.
215225 *
216226 * @param dev pointer to the stepper driver instance
217227 * @param enable Input enable or disable stepper driver
@@ -349,7 +359,7 @@ static inline int z_impl_stepper_set_event_callback(const struct device *dev,
349359}
350360
351361/**
352- * @brief Set the time interval between steps in nanoseconds
362+ * @brief Set the time interval between steps in nanoseconds with immediate effect.
353363 *
354364 * @note Setting step interval does not set the stepper into motion, a combination of
355365 * set_microstep_interval and move is required to set the stepper into motion.
@@ -452,6 +462,28 @@ static inline int z_impl_stepper_run(const struct device *dev,
452462 return api -> run (dev , direction );
453463}
454464
465+ /**
466+ * @brief Stop the stepper
467+ * @details Cancel all active movements, however keep the coils energized.
468+ *
469+ * @param dev pointer to the stepper driver instance
470+ *
471+ * @retval -EIO General input / output error
472+ * @retval -ENOSYS If not implemented by device driver
473+ * @retval 0 Success
474+ */
475+ __syscall int stepper_stop (const struct device * dev );
476+
477+ static inline int z_impl_stepper_stop (const struct device * dev )
478+ {
479+ const struct stepper_driver_api * api = (const struct stepper_driver_api * )dev -> api ;
480+
481+ if (api -> stop == NULL ) {
482+ return - ENOSYS ;
483+ }
484+ return api -> stop (dev );
485+ }
486+
455487/**
456488 * @brief Check if the stepper is currently moving
457489 *
0 commit comments