RP: add pio program to drive bipolar steppers through driver board#5808
Open
1-rafael-1 wants to merge 4 commits intoembassy-rs:mainfrom
Open
RP: add pio program to drive bipolar steppers through driver board#58081-rafael-1 wants to merge 4 commits intoembassy-rs:mainfrom
1-rafael-1 wants to merge 4 commits intoembassy-rs:mainfrom
Conversation
with stepper drivers like TMC2209.
namingrefinements, touch up the example
There was a problem hiding this comment.
Pull request overview
This PR introduces a new step_dir PIO program/driver in embassy-rp for generating STEP pulses via PIO plus a software-controlled DIR GPIO, along with duplicated usage examples for RP2040 (rp) and RP235x (rp235x) boards.
Changes:
- Added
embassy_rp::pio_programs::step_dirwith configurable STEP pulse timing and frequency control. - Added
pio_step_dir.rsexamples for bothrpandrp235x. - Exported the new module from
embassy-rp/src/pio_programs/mod.rs.
Reviewed changes
Copilot reviewed 2 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| examples/rp235x/src/bin/pio_step_dir.rs | Adds an rp235x example demonstrating the new step/dir driver usage. |
| examples/rp/src/bin/pio_step_dir.rs | Adds an rp2040 example demonstrating the new step/dir driver usage. |
| embassy-rp/src/pio_programs/step_dir.rs | Implements the step/dir PIO program wrapper and API (timing, frequency, move, stop). |
| embassy-rp/src/pio_programs/mod.rs | Exposes the new step_dir module. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds a pio program
step_dirthat can be used to drive a 4-wire bipolar stepper motor using a driver board. It includes one example (duplicated for rp and rp23).The pio program has three modes, depending on how low a frequency one needs for driving the motor. It uses two gpio, one is just the direction control and uses normal gpio toggling and the other is driven by a pio program to generate the pulses.
This PR has been coded with AI assistance. I have undertaken these following steps to verify the viability of this contribution:
Here is the LA output for 10 dedicated steps at 2Khz frequency using default setup. See pulses and measurements: this should work as expected.

Here is the test setup with hardware, working as expected:

I am happy to change/adapt code if concerns arise :-). I am equally happy to run/demonstrate other tests if requested.