-
Notifications
You must be signed in to change notification settings - Fork 7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
drivers: stepper: add stepper driver for allegro a4979 #86620
base: main
Are you sure you want to change the base?
drivers: stepper: add stepper driver for allegro a4979 #86620
Conversation
Adding a stepper driver for allegro a4979 microstepping programmable stepper motor driver. Signed-off-by: Verena Schweinstetter <verena.schweinstetter@zeiss.com>
…legro a4979 Add entry in gpio.dtsi for allegro a4979 stepper in tests/drivers/build_all/stepper Signed-off-by: Verena Schweinstetter <verena.schweinstetter@zeiss.com>
Hello @verenascst, and thank you very much for your first pull request to the Zephyr project! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work, some things around formatting and minor nits 👍
zephyr_library() | ||
zephyr_library_property(ALLOW_EMPTY TRUE) | ||
|
||
zephyr_library_sources_ifdef(CONFIG_A4979_STEPPER a4979.c) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check you editor settings, there should be a new line at the end of file.
|
||
comment "Allegro Stepper Drivers" | ||
|
||
rsource "Kconfig.a4979" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe add a zephyr-keep-sorted directive?
* | ||
* This structure contains all of the devicetree specifications for the pins | ||
* needed by a given A4979 stepper driver. | ||
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Usually we only add doxygen comments for public facing headers. Internal implementation files should not have them.
data->enabled = enable; | ||
if (!enable) { | ||
config->common.timing_source->stop(dev); | ||
ret = gpio_pin_set_dt(&config->common.step_pin, 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a benefit to setting the step pin explicitly?
enum stepper_micro_step_resolution *micro_step_res) | ||
{ | ||
struct a4979_data *data = dev->data; | ||
*micro_step_res = data->micro_step_res; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Compliance check probably wants some new lines here.
} | ||
|
||
/* Configure microstep pin 0 */ | ||
ret = gpio_pin_configure_dt(&config->m0_pin, GPIO_OUTPUT_INACTIVE); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess you should check the gpio_is_ready_dt
there also before trying to configure.
\ | ||
DEVICE_DT_INST_DEFINE(inst, a4979_init, NULL, &a4979_data_##inst, \ | ||
&a4979_config_##inst, POST_KERNEL, \ | ||
CONFIG_STEPPER_INIT_PRIORITY, &a4979_stepper_api); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check the formatting of the macro, some lines are too long. clang-format usually gets you 90% of the way there but I guess in some cases it fails for our macrobatics :^)
- counter | ||
|
||
properties: | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Drop the empty line.
compatible: "allegro,a4979" | ||
|
||
include: | ||
#- name: spi-device.yaml |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Leftover :^) ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @verenascst for the contribution :-) Try running
python scripts/ci/check_compliance.py
after you have committed your changes locally and it should report all the whitespacing & other compliance errors :-)
# SPDX-FileCopyrightText: Copyright (c) 2025 Carl Zeiss Meditec AG | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
config STEPPER_ALLEGRO |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
config STEPPER_ALLEGRO | |
menuconfig STEPPER_ALLEGRO |
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
config A4979_STEPPER | ||
bool "Activate driver for A4979 stepper motor driver" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bool "Activate driver for A4979 stepper motor driver" | |
bool "Activate allegro A4979 stepper driver" |
default y | ||
depends on DT_HAS_ALLEGRO_A4979_ENABLED | ||
select STEP_DIR_STEPPER | ||
select STEPPER_STEP_DIR_GENERATE_ISR_SAFE_EVENTS |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
User should be able to select this :)
select STEPPER_STEP_DIR_GENERATE_ISR_SAFE_EVENTS |
#include "../step_dir/step_dir_stepper_common.h" | ||
|
||
#include <zephyr/logging/log.h> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* | ||
* This structure contains mutable data used by a A4979 stepper driver. | ||
*/ | ||
struct a4979_data { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as what @faxe1008 mentioned above :)
@@ -0,0 +1,46 @@ | |||
description: | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The spacing needs to be adjusted over here a bit :)
tmc2209 is a good example.
https://docs.zephyrproject.org/latest/build/dts/api/bindings/stepper/adi/adi%2Ctmc2209.html
This PR adds a stepper driver for allegro a4979 microstepping driver.
It has manly been developed analogous to drv8429 with adaptions where they are needed. It was tested with the generic stepper sample.