Commit Graph

86 Commits

Author SHA1 Message Date
Jilay Pandya
3ce26616c9 drivers: stepper: rename gpio_steppper_controller to h_bridge_stepper
rename gpio stepper to h bridge stepper
minor correction in stepper_stop, stepper_stop shall cancel all active
movements and should not be concerned about keeping the coils energized
or not, since that is a concern of a motion controller and not a stepper
driver.

Signed-off-by: Jilay Pandya <jilay.pandya@outlook.com>
2025-07-19 09:57:40 +02:00
Jilay Pandya
08dd7c519a drivers: stepper: tmc5xxx: introduce stop function
Introduce stop function in tmc5xxx

Signed-off-by: Jilay Pandya <jilay.pandya@outlook.com>
2025-06-23 13:44:51 +02:00
Jilay Pandya
2aca0d3e9d drivers: stepper: remove stop function wrapped in disable
Removing stop functionality wrapped in stepper_disable since
there is a dedicated function for it.

Signed-off-by: Jilay Pandya <jilay.pandya@outlook.com>
2025-06-23 13:44:51 +02:00
Jilay Pandya
d25b1d1959 drivers: stepper: add check for inval resolution in set_microstep_res
Add check for invalid microstep resolution directly in api to avoid the
check in each and every driver
Set microstep resolution is made a mandatory function now as all
stepper drivers support it and hence should implement it

Signed-off-by: Jilay Pandya <jilay.pandya@outlook.com>
2025-06-19 22:35:51 -07:00
Jilay Pandya
ca2f7254d2 drivers: stepper: tmc50xx: add a null pointer check
Check if the actual velocity pointer is NULL or not, if its null return
-EINVAL in order to avoid null pointer dereferencing later in code

Signed-off-by: Jilay Pandya <jilay.pandya@outlook.com>
2025-06-04 17:04:30 +02:00
Dipak Shetty
358907b25f drivers: stepper: adi_tmc: tmc51xx uart support
Added support for tmc51xx uart support alongside the
existing spi support. The tmc51xx driver is now consolidated
into a dedicated folder.

Signed-off-by: Dipak Shetty <shetty.dipak@gmx.com>
2025-05-30 19:40:34 +02:00
Dipak Shetty
a66d064dc4 drivers: stepper: adi_tmc: extend rampstat mask range
Now added pos_reached_mask for polling rampstat when
position reached event is not supported, for example,
with uart drivers. Consequently, when the position is
reached, the position is reached, and the event flag is
set active. Hence, an additional value is now introduced.

Signed-off-by: Dipak Shetty <shetty.dipak@gmx.com>
2025-05-30 19:40:34 +02:00
Dipak Shetty
b914537603 drivers: stepper: adi_tmc: extend to support uart
Add support for trinamic controller with single wire UART

Signed-off-by: Dipak Shetty <shetty.dipak@gmx.com>
2025-05-30 19:40:34 +02:00
Dipak Shetty
6cc860d892 drivers: stepper: adi_tmc: bus: abstraction layer for bus
Now a bus abstraction for Trinamic stepper drivers with
unified interface for SPI/UART communication. Separates
transport logic from device-specific functionality.

Signed-off-by: Dipak Shetty <shetty.dipak@gmx.com>
2025-05-30 19:40:34 +02:00
Verena Schweinstetter
9313df9813 drivers: stepper: allegro: Fix missing break statement
Fix missing break statement in a4979.c after line 123

Signed-off-by: Verena Schweinstetter <verena.schweinstetter@zeiss.com>
2025-05-27 17:56:27 +02:00
Alberto Escolar Piedras
d20adfedb1 drivers/stepper/adi_tmc: Fix code compliance issues
Fix issues detected by checkpatch

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2025-05-21 12:35:28 +02:00
Dipak Shetty
4c38b16f03 drivers: stepper: adi_tmc: tmc5xxxx: fixed standstill detection
The standstill detection logic now stands corrected. Moving would
be indicated when the standstill bit is not zero.

Signed-off-by: Dipak Shetty <shetty.dipak@gmx.com>
2025-05-13 03:20:39 +02:00
Dipak Shetty
418d2e6baa drivers: stepper: adi_tmc: diag0 interrupt support for tmc51xx
Add support for using the diag0 pin as an interrupt source. This
allows event detection via diag0 interrupts instead of polling rampstat.
The driver now:
- Configures diag0 when the GPIO is available
- Sets up GPIO interrupt handling for rising edge transitions for
rampstat reading
- Falls back to polling only when diag0 is not available

Signed-off-by: Dipak Shetty <shetty.dipak@gmx.com>
2025-05-07 13:34:02 +02:00
Dipak Shetty
e5026d4a96 drivers: stepper: simplify event detection config
Simplified by removing redundant options and
enabled automatic fallback to ramp status polling when
diag0 pin is unavailable for event detection.

Signed-off-by: Dipak Shetty <shetty.dipak@gmx.com>
2025-05-07 13:34:02 +02:00
Josselin Bunt
902824db1f drivers: stepper: Fix stepper callbacks when using work_q
Fix issue where stepper callbacks were not being called when
using work_q. This was due to the steps being counted down before
the work_q was rescheduled.

Signed-off-by: Josselin Bunt <josselin@sensible.health>
2025-05-04 19:55:51 +02:00
Jilay Pandya
a371f0c516 drivers: stepper: tmc_spi: remove print_status_byte
print_status_byte is specific to tmc50xx and hence shoud not
be placeed in common tmc_spi.c which is supposed to be reused
by a variety of drivers

Signed-off-by: Jilay Pandya <jilay.pandya@outlook.com>
2025-04-29 08:16:57 +01:00
Jilay Pandya
92d914e465 drivers: stepper: fix trinamic controller names
dropping adi prefix & stepper_controller suffix from trinamic drivers.

Signed-off-by: Jilay Pandya <jilay.pandya@outlook.com>
2025-04-24 20:29:07 +02:00
Anders Nielsen
b469fc188b drivers: stepper: adi_tmc: Add progress log for stall guard tuning.
Replace stall guard retry error log on EAGAIN with enable/disable info log.
Log position, sg result and sg status on each rampstat_work_handler() call.
Treat only negative return values from tmc_spi_write_register() and
tmc_spi_read_register() as an error. Only log actual velocity when not 0.
Use helper functions rampstat_work_reschedule() and read_vactual().

Signed-off-by: Anders Nielsen <anders.nielsen@prevas.dk>
2025-04-24 16:55:15 +02:00
Anders Nielsen
4b4dc77340 drivers: stepper: adi_tmc: Use helper functions in tmc50xx.
Use rampstat_work_reschedule() and read_vactual().
Only log actual velocity when not 0.
Update log_stallguard() output.

Signed-off-by: Anders Nielsen <anders.nielsen@prevas.dk>
2025-04-24 16:55:15 +02:00
Jilay Pandya
82c6add9b1 drivers: stepper: gpio: refactor work rescheduling logic
update remaining steps should just update the remaining steps, rescheduling
should happen after updating steps and hence is moved to position mode task
which is also in coherence with velocity mode task

Signed-off-by: Jilay Pandya <jilay.pandya@outlook.com>
2025-04-23 02:16:19 +02:00
Anders Nielsen
b98bd7c145 drivers: stepper: adi_tmc: Add tmc51xx support
Add tmc51xx support based on tmc50xx implementation.

Signed-off-by: Anders Nielsen <anders.nielsen@prevas.dk>
2025-04-22 12:09:18 +02:00
Anders Nielsen
242e6ea12a drivers: stepper: adi_tmc: Prepare for tmc51xx support
Add Kconfig option. Find common regs. Update ramp generator data.

Signed-off-by: Anders Nielsen <anders.nielsen@prevas.dk>
2025-04-22 12:09:18 +02:00
Dipak Shetty
8f6b0b2e2e drivers: stepper: refactor stepper move_to and move_by calls
Refactored stepper move_to calls and move_by calls.
Now, relative movement required or absolute target position
is calculated and then redirected to move_by or move_to calls
respectively.

Signed-off-by: Dipak Shetty <shetty.dipak@gmx.com>
2025-04-17 21:17:55 +02:00
Anders Nielsen
b2b597aa6e drivers: stepper: adi_tmc: adi_tmc50xx_stepper_controller.c
Replace stall guard retry error log on EAGAIN with enable/disable info log.
Log position, sg result and sg status on each rampstat_work_handler() call.
Treat only negative return values from tmc_spi_write_register() and
tmc_spi_read_register() as an error.

Signed-off-by: Anders Nielsen <anders.nielsen@prevas.dk>
2025-04-16 20:37:04 +02:00
Jan Behrens
f75c057e85 drivers: stepper: Renamed DRV8424 to DRV84XX
Renamed the drv8424 stepper driver to indicate its support of the drv8424,
drv8425, drv8426, drv8434 and drv8436 stepper controllors. Also made the
microstep pins optional. All test files are renamed as well.

Signed-off-by: Jan Behrens <jan.behrens@navimatix.de>
2025-04-09 19:34:00 +02:00
Jan Behrens
d486c7794a drivers: stepper: DRV8424 Fault Event
Adds support for the fault event via the fault pin to the drv8424 driver.

Signed-off-by: Jan Behrens <jan.behrens@navimatix.de>
2025-04-09 19:34:00 +02:00
Jan Behrens
c8c79a9fc6 drivers: stepper: Renamed Fault Event + Non Static Event Trigger
Renamed fault event to be more in line with other events and added it to
the stepper shell.
Makes the event callback trigger function of the step-dir implementation
non-static so that step-dir stepper drivers can use it to trigger events
themself.

Signed-off-by: Jan Behrens <jan.behrens@navimatix.de>
2025-04-09 19:34:00 +02:00
Jilay Pandya
4838c0f200 drivers: stepper: introduce valid micro-step resolution check
Introduce macro to check for valid microstep resolution in stepper api
Use this macro in tmc50xx driver. Stepper api tests adjusted in order to
accomodate the not implemented stepper api functions.

Signed-off-by: Jilay Pandya <jilay.pandya@outlook.com>
2025-04-08 11:45:40 +02:00
Jilay Pandya
6bfea730b1 doc: migration-guide: 4.2: add migration guide entry for enable
- Add migration guide entry for enable->enable/disable function
- Add stepper_disable to stepper.rst

Signed-off-by: Jilay Pandya <jilay.pandya@outlook.com>
2025-04-03 00:03:29 +02:00
Jilay Pandya
d18f49132c drivers: stepper: refactor enable(dev,flag) to enable & disable
refactoring enable function into enable and disable increasing readability
and increasing coherence with other stepper apis in terms of
nomenclature

Signed-off-by: Jilay Pandya <jilay.pandya@outlook.com>
2025-04-03 00:03:29 +02:00
Jilay Pandya
b4b5d8b236 drivers: stepper: a4979: add stop function
add stop function to a4979 stepper controller

Signed-off-by: Jilay Pandya <jilay.pandya@outlook.com>
2025-03-22 02:41:23 +01:00
Jilay Pandya
79221db413 dts: bindings: stepper remove property-allowlist from step-dir drivers
drop property-allowlist and implement invert-direction in step-dir-common

Signed-off-by: Jilay Pandya <jilay.pandya@outlook.com>
2025-03-19 01:29:24 +01:00
Jilay Pandya
649ca563ab drivers: stepper: add stop function to common step-dir lib
add stop function to common step-dir lib

Signed-off-by: Jilay Pandya <jilay.pandya@outlook.com>
2025-03-18 16:41:31 +01:00
Verena Schweinstetter
5c2b7bcbf7 drivers: stepper: Add stepper driver for allegro a4979
Adding a stepper driver implementation for allegro a4979
microstepping programmable stepper motor driver.
The implemenation was tested using the drv8424/api testsuite.

Signed-off-by: Verena Schweinstetter <verena.schweinstetter@zeiss.com>
2025-03-14 09:23:57 +01:00
Jilay Pandya
761c6fbae6 tests: stepper_api: test stop, set_micro_step_res, set_micro_step_interval
unify error codes from all drivers based on stepper specification
add a generic test case for set_micro_step_interval and stop

Signed-off-by: Jilay Pandya <jilay.pandya@outlook.com>
2025-03-13 07:31:06 +01:00
Jilay Pandya
b5ff37297d samples: stepper: add generic stepper sample
Add a generic stepper sample with gpio-stepper

Signed-off-by: Jilay Pandya <jilay.pandya@outlook.com>
2025-03-12 07:13:33 +01:00
Jilay Pandya
1f1bec86f3 drivers: stepper: shell: add stop function
Add stop function to stepper shell. align the function order to match
the one in __subsystem stepper_driver_api struct

Signed-off-by: Jilay Pandya <jilay.pandya@outlook.com>
2025-03-07 20:17:38 +01:00
Jilay Pandya
99cce692c2 drivers: stepper: gpio: implement stop function
Implement sample stop function and update enable function

Signed-off-by: Jilay Pandya <jilay.pandya@outlook.com>
2025-03-07 20:17:38 +01:00
Jilay Pandya
8272b36b5b drivers: stepper: tmc50xx: extend tmc5041 to tmc50xx
Extend tmc5041 to tmc50xx in order to accomodate tmc5072

Signed-off-by: Jilay Pandya <jilay.pandya@outlook.com>
2025-02-05 01:14:47 +01:00
Jamie McCrae
3142c51d87 drivers: kconfig: Fix menu items
Fixes items that are not properly in menus or have Kconfig
selections that make no sense

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2025-01-31 11:50:12 +01:00
Fabio Baltieri
0bc123da11 drivers: drop few redundant device_is_ready
Drop few redundant device_is_ready for functions that are only used as
argument to shell_device_filter, as shell_device_filter checks for that
alrady.

Suggested-by: Yishai Jaffe <yishai1999@gmail.com>
Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2025-01-22 05:40:11 +01:00
Fabian Blatz
705365c747 drivers: stepper: Change stepper velocity to step interval
Change the stepper API to instead of changing the stepper speed based on
the velocity in microsteps per second to use the delay in usec between
successive steps. Also remove the velocity from the `stepper_run` function
as typical API usage is enable -> set step interval -> run.

Signed-off-by: Fabian Blatz <fabianblatz@gmail.com>
2025-01-15 15:06:37 +01:00
Fabian Blatz
0ac9a6c512 drivers: stepper: drv8424: Use step_dir common code
Adapt the drv8424 driver to use the common step dir interface.

Signed-off-by: Fabian Blatz <fabianblatz@gmail.com>
2025-01-01 02:04:53 +01:00
Fabian Blatz
39dbd49874 drivers: stepper: step_dir: Fix actual position increment
Address issue where the timing source is not stopped upon step completion
and not adjusting the actual position after performing a step.

Signed-off-by: Fabian Blatz <fabianblatz@gmail.com>
2025-01-01 02:04:53 +01:00
Fabian Blatz
9e6366a01e drivers: stepper: step_dir: Add fallback for dual-edge-step
Adds a fallback for the dual-edge-step property in the step dir common
code. Without this drivers using the common code would have to declare the
dual-edge-step property so it can default to false when not set, even if
the IC does not support adjusting it.

Signed-off-by: Fabian Blatz <fabianblatz@gmail.com>
2025-01-01 02:04:53 +01:00
Fabian Blatz
0b124a2ff6 drivers: stepper: Add timing source for step dir stepper
Adds a timing source api which is used by the step-dir stepper common code.
This allows the reusable common code to configure different timing sources,
since the initial delayable work implementation was inacurate for higher
maximum velocities.

Signed-off-by: Fabian Blatz <fabianblatz@gmail.com>
2024-12-28 04:37:05 +01:00
Fabian Blatz
fc2567939b drivers: stepper: shell: Use shell_device_filter
Use the shell_device_filter utils method and leverage the new api classing
to only suggest stepper devices via tab-complete within the shell.

Signed-off-by: Fabian Blatz <fabianblatz@gmail.com>
2024-12-27 21:18:04 +01:00
Jilay Pandya
2382d239d7 drivers: stepper: gpio: return -ECANCELED from move operations
return -ECANCELED when move operations are called with stepper not enabled

Signed-off-by: Jilay Pandya <jilay.pandya@outlook.com>
2024-12-23 22:00:35 +01:00
Jilay Pandya
59064a409e dts: bindings: stepper: add en-gpios to common stepper-controller.yaml
- rename enable-gpios to en-gpios in adi,tmc2209
- place en-gpios in common stepper-controller.yaml

Signed-off-by: Jilay Pandya <jilay.pandya@outlook.com>
2024-12-23 17:10:06 +01:00
Sarah Renkhoff
79d62944b1 drivers: stepper: Add driver for DRV8424 stepper motor controller
Adds a step/dir stepper driver for the drv8424 stepper driver.

Signed-off-by: Sarah Renkhoff <sarah.renkhoff@navimatix.de>
2024-12-19 15:21:44 +01:00