@@ -338,53 +338,6 @@ static int tmc50xx_stepper_is_moving(const struct device *dev, bool *is_moving)
338338 return 0 ;
339339}
340340
341- static int tmc50xx_stepper_move_by (const struct device * dev , const int32_t micro_steps )
342- {
343- const struct tmc50xx_stepper_config * config = dev -> config ;
344- struct tmc50xx_stepper_data * data = dev -> data ;
345- int err ;
346-
347- if (config -> is_sg_enabled ) {
348- err = stallguard_enable (dev , false);
349- if (err != 0 ) {
350- return - EIO ;
351- }
352- }
353-
354- int32_t position ;
355-
356- err = stepper_get_actual_position (dev , & position );
357- if (err != 0 ) {
358- return - EIO ;
359- }
360- int32_t target_position = position + micro_steps ;
361-
362- err = tmc50xx_write (config -> controller , TMC50XX_RAMPMODE (config -> index ),
363- TMC5XXX_RAMPMODE_POSITIONING_MODE );
364- if (err != 0 ) {
365- return - EIO ;
366- }
367- LOG_DBG ("Stepper motor controller %s moved to %d by steps: %d" , dev -> name , target_position ,
368- micro_steps );
369- err = tmc50xx_write (config -> controller , TMC50XX_XTARGET (config -> index ), target_position );
370- if (err != 0 ) {
371- return - EIO ;
372- }
373-
374- if (config -> is_sg_enabled ) {
375- k_work_reschedule (& data -> stallguard_dwork ,
376- K_MSEC (config -> sg_velocity_check_interval_ms ));
377- }
378- #ifdef CONFIG_STEPPER_ADI_TMC50XX_RAMPSTAT_POLL
379- if (data -> callback ) {
380- k_work_reschedule (
381- & data -> rampstat_callback_dwork ,
382- K_MSEC (CONFIG_STEPPER_ADI_TMC50XX_RAMPSTAT_POLL_INTERVAL_IN_MSEC ));
383- }
384- #endif
385- return 0 ;
386- }
387-
388341int tmc50xx_stepper_set_max_velocity (const struct device * dev , uint32_t velocity )
389342{
390343 const struct tmc50xx_stepper_config * config = dev -> config ;
@@ -497,7 +450,7 @@ static int tmc50xx_stepper_get_actual_position(const struct device *dev, int32_t
497450
498451static int tmc50xx_stepper_move_to (const struct device * dev , const int32_t micro_steps )
499452{
500- LOG_DBG ("Stepper motor controller %s set target position to %d" , dev -> name , micro_steps );
453+ LOG_DBG ("%s set target position to %d" , dev -> name , micro_steps );
501454 const struct tmc50xx_stepper_config * config = dev -> config ;
502455 struct tmc50xx_stepper_data * data = dev -> data ;
503456 int err ;
@@ -530,6 +483,22 @@ static int tmc50xx_stepper_move_to(const struct device *dev, const int32_t micro
530483 return 0 ;
531484}
532485
486+ static int tmc50xx_stepper_move_by (const struct device * dev , const int32_t micro_steps )
487+ {
488+ int err ;
489+ int32_t position ;
490+
491+ err = stepper_get_actual_position (dev , & position );
492+ if (err != 0 ) {
493+ return - EIO ;
494+ }
495+ int32_t target_position = position + micro_steps ;
496+
497+ LOG_DBG ("%s moved to %d by steps: %d" , dev -> name , target_position , micro_steps );
498+
499+ return tmc50xx_stepper_move_to (dev , target_position );
500+ }
501+
533502static int tmc50xx_stepper_run (const struct device * dev , const enum stepper_direction direction )
534503{
535504 LOG_DBG ("Stepper motor controller %s run" , dev -> name );
0 commit comments