Skip to content

Commit ee909ef

Browse files
jilaypandyahenrikbrixandersen
authored andcommitted
tests: stepper_api: drop test_run_zero_step_interval_correct_position
Setting 0 as microstep interval is invalid. If microstep_interval is not set then the motion related functions should return -EINVAL. drop test_run_zero_step_interval_correct_position Signed-off-by: Jilay Pandya <[email protected]>
1 parent 7b3ac52 commit ee909ef

File tree

4 files changed

+13
-15
lines changed

4 files changed

+13
-15
lines changed

drivers/stepper/h_bridge_stepper.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,11 @@ static int h_bridge_stepper_run(const struct device *dev, const enum stepper_dir
268268
{
269269
struct h_bridge_stepper_data *data = dev->data;
270270

271+
if (data->delay_in_ns == 0) {
272+
LOG_ERR("Step interval not set or invalid step interval set");
273+
return -EINVAL;
274+
}
275+
271276
K_SPINLOCK(&data->lock) {
272277
data->run_mode = STEPPER_RUN_MODE_VELOCITY;
273278
data->direction = direction;

drivers/stepper/step_dir/step_dir_stepper_common.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,11 @@ int step_dir_stepper_common_run(const struct device *dev, const enum stepper_dir
347347
struct step_dir_stepper_common_data *data = dev->data;
348348
int ret;
349349

350+
if (data->microstep_interval_ns == 0) {
351+
LOG_ERR("Step interval not set or invalid step interval set");
352+
return -EINVAL;
353+
}
354+
350355
K_SPINLOCK(&data->lock) {
351356
data->run_mode = STEPPER_RUN_MODE_VELOCITY;
352357
data->direction = direction;

include/zephyr/drivers/stepper.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -441,6 +441,7 @@ static inline int z_impl_stepper_set_microstep_interval(const struct device *dev
441441
* @param micro_steps target micro-steps to be moved from the current position
442442
*
443443
* @retval -EIO General input / output error
444+
* @retval -EINVAL If the timing for steps is incorrectly configured
444445
* @retval 0 Success
445446
*/
446447
__syscall int stepper_move_by(const struct device *dev, int32_t micro_steps);
@@ -462,7 +463,7 @@ static inline int z_impl_stepper_move_by(const struct device *dev, const int32_t
462463
* @param micro_steps target position to set in micro-steps
463464
*
464465
* @retval -EIO General input / output error
465-
* @retval -ENOSYS If not implemented by device driver
466+
* @retval -EINVAL If the timing for steps is incorrectly configured
466467
* @retval 0 Success
467468
*/
468469
__syscall int stepper_move_to(const struct device *dev, int32_t micro_steps);
@@ -488,6 +489,7 @@ static inline int z_impl_stepper_move_to(const struct device *dev, const int32_t
488489
* @param direction The direction to set
489490
*
490491
* @retval -EIO General input / output error
492+
* @retval -EINVAL If the timing for steps is incorrectly configured
491493
* @retval -ENOSYS If not implemented by device driver
492494
* @retval 0 Success
493495
*/

tests/drivers/stepper/drv84xx/api/src/main.c

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -265,20 +265,6 @@ ZTEST_F(drv84xx_api, test_run_negative_direction_correct_position)
265265
"Current position should be between -6 and -4 but is %d", steps);
266266
}
267267

268-
ZTEST_F(drv84xx_api, test_run_zero_step_interval_correct_position)
269-
{
270-
uint64_t step_interval = 0;
271-
int32_t steps = 0;
272-
273-
(void)stepper_enable(fixture->dev);
274-
(void)stepper_set_microstep_interval(fixture->dev, step_interval);
275-
(void)stepper_run(fixture->dev, STEPPER_DIRECTION_POSITIVE);
276-
k_msleep(100);
277-
278-
zassert_equal(steps, 0, "Current position should not have changed from %d but is %d", 0,
279-
steps);
280-
}
281-
282268
ZTEST_F(drv84xx_api, test_run_is_moving_true_when_step_interval_greater_zero)
283269
{
284270
uint64_t step_interval = 20000000;

0 commit comments

Comments
 (0)