@@ -61,6 +61,9 @@ static void print_callback(const struct device *dev, const enum stepper_event ev
6161 case STEPPER_EVENT_RIGHT_END_STOP_DETECTED :
6262 shell_info (sh , "%s: Right limit switch pressed." , dev -> name );
6363 break ;
64+ case STEPPER_EVENT_STOPPED :
65+ shell_info (sh , "%s: Stepper stopped." , dev -> name );
66+ break ;
6467 default :
6568 shell_info (sh , "%s: Unknown signal received." , dev -> name );
6669 break ;
@@ -195,6 +198,30 @@ static int cmd_stepper_enable(const struct shell *sh, size_t argc, char **argv)
195198 return err ;
196199}
197200
201+ static int cmd_stepper_stop (const struct shell * sh , size_t argc , char * * argv )
202+ {
203+ const struct device * dev ;
204+ int err = 0 ;
205+
206+ err = parse_device_arg (sh , argv , & dev );
207+ if (err < 0 ) {
208+ return err ;
209+ }
210+
211+ err = stepper_stop (dev );
212+ if (err ) {
213+ shell_error (sh , "Error: %d" , err );
214+ return err ;
215+ }
216+
217+ err = stepper_set_event_callback (dev , print_callback , (void * )sh );
218+ if (err != 0 ) {
219+ shell_error (sh , "Failed to set callback: %d" , err );
220+ }
221+
222+ return err ;
223+ }
224+
198225static int cmd_stepper_move_by (const struct shell * sh , size_t argc , char * * argv )
199226{
200227 const struct device * dev ;
@@ -452,10 +479,6 @@ SHELL_STATIC_SUBCMD_SET_CREATE(
452479 stepper_cmds ,
453480 SHELL_CMD_ARG (enable , & dsub_pos_stepper_motor_name , "<device> <on/off>" , cmd_stepper_enable ,
454481 3 , 0 ),
455- SHELL_CMD_ARG (move_by , & dsub_pos_stepper_motor_name , "<device> <microsteps>" ,
456- cmd_stepper_move_by , 3 , 0 ),
457- SHELL_CMD_ARG (set_microstep_interval , & dsub_pos_stepper_motor_name ,
458- "<device> <microstep_interval_ns>" , cmd_stepper_set_microstep_interval , 3 , 0 ),
459482 SHELL_CMD_ARG (set_micro_step_res , & dsub_pos_stepper_motor_name_microstep ,
460483 "<device> <resolution>" , cmd_stepper_set_micro_step_res , 3 , 0 ),
461484 SHELL_CMD_ARG (get_micro_step_res , & dsub_pos_stepper_motor_name , "<device>" ,
@@ -464,10 +487,15 @@ SHELL_STATIC_SUBCMD_SET_CREATE(
464487 cmd_stepper_set_reference_position , 3 , 0 ),
465488 SHELL_CMD_ARG (get_actual_position , & dsub_pos_stepper_motor_name , "<device>" ,
466489 cmd_stepper_get_actual_position , 2 , 0 ),
490+ SHELL_CMD_ARG (set_microstep_interval , & dsub_pos_stepper_motor_name ,
491+ "<device> <microstep_interval_ns>" , cmd_stepper_set_microstep_interval , 3 , 0 ),
492+ SHELL_CMD_ARG (move_by , & dsub_pos_stepper_motor_name , "<device> <microsteps>" ,
493+ cmd_stepper_move_by , 3 , 0 ),
467494 SHELL_CMD_ARG (move_to , & dsub_pos_stepper_motor_name , "<device> <microsteps>" ,
468495 cmd_stepper_move_to , 3 , 0 ),
469496 SHELL_CMD_ARG (run , & dsub_pos_stepper_motor_name_dir , "<device> <direction>" ,
470497 cmd_stepper_run , 3 , 0 ),
498+ SHELL_CMD_ARG (stop , & dsub_pos_stepper_motor_name , "<device>" , cmd_stepper_stop , 2 , 0 ),
471499 SHELL_CMD_ARG (info , & dsub_pos_stepper_motor_name , "<device>" , cmd_stepper_info , 2 , 0 ),
472500 SHELL_SUBCMD_SET_END );
473501
0 commit comments