-
Notifications
You must be signed in to change notification settings - Fork 7.4k
drivers: stepper: refactor ISR safe event mechanism #90424
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
base: main
Are you sure you want to change the base?
drivers: stepper: refactor ISR safe event mechanism #90424
Conversation
c60bfe4
to
ebdf323
Compare
I am not sure about the context of the ISR callbacks, so had 2 questions:
This, am not sure is the right approach. Guess, the callbacks need to be called from some work, rather than cascading the calls. |
drop ISR safe event mechanism handling from step_dir_common Signed-off-by: Jilay Pandya <jilay.pandya@outlook.com>
Yes, you are right, i have refactored the event handling out to a seperate module called stepper_event_handler, so that other drivers can benefit from it as well. Could you give a second look at the way i am using Iterable Sections? |
6c5cf91
to
44c61e5
Compare
Event handling mechanism was hardcoded in step-dir drivers. This commit refactors the event handling in a dedicated module. Signed-off-by: Jilay Pandya <jilay.pandya@outlook.com>
44c61e5
to
4549a11
Compare
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.
Pull Request Overview
This PR extracts the ISR-safe event queuing logic from the step_dir
common code into a dedicated event_handler
module and updates all stepper drivers to use the new stepper_post_event
API.
- Moved message‐queue and work handler logic into a standalone
stepper_event_handler
module - Added
stepper_post_event
function and iterable‐section registrations for each device - Updated all drivers and sample code to call
stepper_post_event
and useSTEPPER_DEVICE_DT_DEFINE
Reviewed Changes
Copilot reviewed 26 out of 26 changed files in this pull request and generated no comments.
Show a summary per file
File | Description |
---|---|
samples/drivers/stepper/generic/src/main.c | Added debug log for STEPPER_EVENT_STEPS_COMPLETED |
include/zephyr/drivers/stepper.h | Introduced macros and structs for STEPPER_EVENT_HANDLER |
drivers/stepper/ti/Kconfig.drv84xx | Removed old ISR-safe event select |
drivers/stepper/ti/drv84xx.c | Switched to STEPPER_DEVICE_DT_INST_DEFINE |
drivers/stepper/step_dir/step_dir_stepper_common.h | Removed inlined ISR-safe event fields |
drivers/stepper/step_dir/step_dir_stepper_common.c | Replaced local ISR dispatch with stepper_post_event |
drivers/stepper/step_dir/Kconfig | Dropped legacy event-template include |
drivers/stepper/gpio_stepper_controller.c | Switched to stepper_post_event calls and DT define |
drivers/stepper/fake_stepper_controller.c | Switched to STEPPER_DEVICE_DT_INST_DEFINE |
drivers/stepper/allegro/a4979.c | Switched to STEPPER_DEVICE_DT_INST_DEFINE |
drivers/stepper/adi_tmc/tmc22xx.c | Switched to STEPPER_DEVICE_DT_INST_DEFINE |
drivers/stepper/event_handler/stepper_event_handler.h | New public header for event handler API |
drivers/stepper/event_handler/stepper_event_handler.c | New implementation of queued ISR-safe event dispatch |
drivers/stepper/event_handler/iterables.ld | Linker script for iterable sections |
drivers/stepper/event_handler/Kconfig | Kconfig for enabling/configuring the event handler |
drivers/stepper/event_handler/CMakeLists.txt | CMake rules to build the event handler module |
drivers/stepper/Kconfig | Hooked in new event_handler Kconfig |
drivers/stepper/CMakeLists.txt | Added subdirectory for event_handler |
Comments suppressed due to low confidence (4)
drivers/stepper/ti/Kconfig.drv84xx:9
- After removing the old config, the TI driver no longer selects the new STEPPER_EVENT_HANDLER option. You should add
select STEPPER_EVENT_HANDLER
to ensure the event handler is enabled.
- select STEPPER_STEP_DIR_GENERATE_ISR_SAFE_EVENTS
drivers/stepper/event_handler/stepper_event_handler.h:6
- The header guard does not match the directory hierarchy. It should be
ZEPHYR_DRIVERS_STEPPER_EVENT_HANDLER_H_
to align with the include path.
#ifndef ZEPHYR_DRIVER_STEPPER_STEPPER_EVENT_HANDLER_H_
include/zephyr/drivers/stepper.h:543
- The macros use STRUCT_SECTION_ITERABLE but this header does not include <zephyr/sys/iterable_sections.h>, which can lead to compilation errors. Add the necessary include.
#ifdef CONFIG_STEPPER_EVENT_HANDLER
drivers/stepper/step_dir/step_dir_stepper_common.c:6
- [nitpick] Use a project‐style include path (e.g., <zephyr/drivers/stepper/event_handler/stepper_event_handler.h>) instead of a relative path for consistency.
#include "../event_handler/stepper_event_handler.h"
|
Refactor ISR safe event handling mechanism from step_dir common to a dedicated module .