Skip to content
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

add callback function to TMC2208/TMC2209 #291

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

vector76
Copy link

I had a problem using TMCStepper from Marlin where Marlin controls a multiplexer to route the serial line to the appropriate stepper. This is similar in spirit to the SSwitch multiplexing that is used by TMC2208Stepper, except that the pins are not Arduino pins, but are extended pins available only to Marlin. (Specifically, it uses the I2S output of the ESP32 and shift register to generate several more output pins.)

To achieve the appropriate multiplexer switching in preReadCommunication and preWriteCommunication, I have added a callback function. Ordinarily the callback function is null and has no effect, but if a callback function and callback parameters are passed to the constructor, then it invokes the function during preReadCommunication and preWriteCommunication.

The parameters cb_vala and cb_valb are opaque to TMCStepper, but the callback function unpacks the values to know which pins and what values need to be assigned to the multiplexer pins.


What are your thoughts on whether this can be merged into the TMCStepper library? Eventually I am hoping the Marlin code that uses the callback can also be merged into the Marlin code, but for that to work, this would be a prerequisite.

…eCommunication

this is useful for switching a mux controlled by the caller
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant