@@ -310,53 +310,6 @@ static int tmc50xx_stepper_is_moving(const struct device *dev, bool *is_moving)
310
310
return 0 ;
311
311
}
312
312
313
- static int tmc50xx_stepper_move_by (const struct device * dev , const int32_t micro_steps )
314
- {
315
- const struct tmc50xx_stepper_config * config = dev -> config ;
316
- struct tmc50xx_stepper_data * data = dev -> data ;
317
- int err ;
318
-
319
- if (config -> is_sg_enabled ) {
320
- err = stallguard_enable (dev , false);
321
- if (err != 0 ) {
322
- return - EIO ;
323
- }
324
- }
325
-
326
- int32_t position ;
327
-
328
- err = stepper_get_actual_position (dev , & position );
329
- if (err != 0 ) {
330
- return - EIO ;
331
- }
332
- int32_t target_position = position + micro_steps ;
333
-
334
- err = tmc50xx_write (config -> controller , TMC50XX_RAMPMODE (config -> index ),
335
- TMC5XXX_RAMPMODE_POSITIONING_MODE );
336
- if (err != 0 ) {
337
- return - EIO ;
338
- }
339
- LOG_DBG ("Stepper motor controller %s moved to %d by steps: %d" , dev -> name , target_position ,
340
- micro_steps );
341
- err = tmc50xx_write (config -> controller , TMC50XX_XTARGET (config -> index ), target_position );
342
- if (err != 0 ) {
343
- return - EIO ;
344
- }
345
-
346
- if (config -> is_sg_enabled ) {
347
- k_work_reschedule (& data -> stallguard_dwork ,
348
- K_MSEC (config -> sg_velocity_check_interval_ms ));
349
- }
350
- #ifdef CONFIG_STEPPER_ADI_TMC50XX_RAMPSTAT_POLL
351
- if (data -> callback ) {
352
- k_work_reschedule (
353
- & data -> rampstat_callback_dwork ,
354
- K_MSEC (CONFIG_STEPPER_ADI_TMC50XX_RAMPSTAT_POLL_INTERVAL_IN_MSEC ));
355
- }
356
- #endif
357
- return 0 ;
358
- }
359
-
360
313
int tmc50xx_stepper_set_max_velocity (const struct device * dev , uint32_t velocity )
361
314
{
362
315
const struct tmc50xx_stepper_config * config = dev -> config ;
@@ -458,7 +411,7 @@ static int tmc50xx_stepper_get_actual_position(const struct device *dev, int32_t
458
411
459
412
static int tmc50xx_stepper_move_to (const struct device * dev , const int32_t micro_steps )
460
413
{
461
- LOG_DBG ("Stepper motor controller %s set target position to %d" , dev -> name , micro_steps );
414
+ LOG_DBG ("%s set target position to %d" , dev -> name , micro_steps );
462
415
const struct tmc50xx_stepper_config * config = dev -> config ;
463
416
struct tmc50xx_stepper_data * data = dev -> data ;
464
417
int err ;
@@ -491,6 +444,24 @@ static int tmc50xx_stepper_move_to(const struct device *dev, const int32_t micro
491
444
return 0 ;
492
445
}
493
446
447
+ static int tmc50xx_stepper_move_by (const struct device * dev , const int32_t micro_steps )
448
+ {
449
+ const struct tmc50xx_stepper_config * config = dev -> config ;
450
+ int err ;
451
+
452
+ int32_t position ;
453
+
454
+ err = stepper_get_actual_position (dev , & position );
455
+ if (err != 0 ) {
456
+ return - EIO ;
457
+ }
458
+ int32_t target_position = position + micro_steps ;
459
+
460
+ LOG_DBG ("%s moved to %d by steps: %d" , dev -> name , target_position , micro_steps );
461
+
462
+ return tmc50xx_stepper_move_to (dev , target_position );
463
+ }
464
+
494
465
static int tmc50xx_stepper_run (const struct device * dev , const enum stepper_direction direction )
495
466
{
496
467
LOG_DBG ("Stepper motor controller %s run" , dev -> name );
0 commit comments