Skip to content

Create stepper_motor driver class #101330

@jilaypandya

Description

@jilaypandya

Problem Description

Problem Statement

The original stepper driver class was split into two driver classes namely stepper_driver_api (stepper motor motion control APIs)and stepper_drv_driver_api (stepper motor driver APIs) in #91979, leading to two similiar sounding driver classes in stepper.h.

Couple of issues which have been noted after the split w.r.t code structure are:

  1. We have now two driver classes in stepper.h.
  2. stepper_driver_api and stepper_drv_driver_api sound pretty similiar & can be confusing.
  3. TMC5XXX devices are modeled as MFDs but are not structured accordingly, in contrast to other MFDs.

Why was the API Split necessary?

Image

Fig 1: Depiction of different combinations of stepper motion control and stepper_driverdevices.

Image

Fig 2: TMC429 Application example using Step/Dir driver interface

The images above show that stepper motion controller and stepper driver are actually two seperate devices.

Proposed Change (Summary)

Split stepper.h in

include/zephyr/drivers
|_____ stepper.h (for stepper drivers only)
|_____ stepper_motor.h (for stepper motor motion controller driver only)

Split stepper_motor_drivers and stepper_drivers in:

drivers/
|_____ stepper/ (for stepper drivers only)
|_____ stepper_motor/ (for stepper motor motion controller driver only)

Proposed Change (Detailed)

Step 1: (achieveable till 4.4)
Linked PR: #101001

  1. Rename stepper_driver_api --> stepper_motor_driver_api.
  2. Rename stepper_drv_driver_api --> stepper_driver_api.
  3. Create a new header file called stepper_motor.h in drivers.
    include/zephyr/drivers
    |_____ stepper.h (for stepper drivers only)
    |_____ stepper_motor.h (for stepper motor motion controller driver only)

Step 1.1: (achieveable till 4.4)

  1. Split stepper_shell in stepper_motor_shell and stepper_shell

Step 2: (~ achieveable till 4.4) (latest by 4.5)

  1. Refactor stepper motor drivers in stepper_motor/ under:
    Note: stepper_motor_driver_apiwill scale to motor_driver_api over time.
drivers/
|_____ stepper/ (for stepper drivers only)
|_____ stepper_motor/ (for stepper motor motion controller driver only)
  1. TMC5XXX devices are to be restructured as:
mfd
|_____ mfd_tmc50xx.c
stepper
|_____ tmc50xx_stepper_driver.c
stepper_motor
|_____ tmc50xx_stepper_motor.c

Dependencies

None that I can think of at the moment.

Concerns and Unresolved Questions

How would the versioning of the new driver api class look like?

  • unstable, since 4.0 ? These APIs have been there since 4.0 are now named differently.

Alternatives Considered

Linked PR: #101120

  • Replace _drv from stepper_drv_driver_api with _amp, resulting in stepper_amp_driver_api and place the new stepper_amp_driver_api class as:
include/zephyr/drivers
|_____ stepper/stepper_amp.h (for stepper drivers only)
|_____ stepper.h (for stepper motor driver only)

Metadata

Metadata

Assignees

Labels

RFCRequest For Comments: want input from the communityarea: Stepper

Type

Projects

Status

In Progress

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions