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

Allow STM32/STM32F1 pins to be set as Open Drain (OD) #27616

Merged
merged 3 commits into from
Jan 9, 2025

Conversation

RedEchidnaUK
Copy link
Contributor

Description

This is a feature update to add the ability to set pins on the STM32/STM32F1 processors to Open Drain (OD).

I noticed that the code to actually set a pin to OD is already present, it's just not exposed as a define. It is defined for the the SAMD family, but not for the RP2040, so I'm not sure if this is a deliberate design decision or not... I have deliberately not included changes for the RP2040 (although the code should be the same) as I don't have a mainboard with that processor to test with.

Requirements

A mainboard with an STM32/STM32F1 processor. It should also work for the STM32 clones (I am using it on a Creality 4.2.2 mainboard with an STM32 clone)

Benefits

This allows you to re-purpose an input pin on a STM32 based mainboard as an output pin without having to remove resistors and/or cut traces on the PCB.

As a bit of background, I'm personally using it on a project to change the Z limit switch on a Creality 4.2.2 mainboard from an input pin to an output pin, which is then connected to an IC on a custom daughterboard. With this firmware change, the mod can easily be fully reversed should the need arise.

Configurations

None

Related Issues

None

@classicrocker883
Copy link
Contributor

is this related to #define BLTOUCH_SET_5V_MODE in Marlin/Configuration_adv.h or what is an example of using this?

@RedEchidnaUK
Copy link
Contributor Author

No it's not related to #define BLTOUCH_SET_5V_MODE.

I'm using it on a project (it will be open source once finished) I'm developing to allow for dual independent z-axis control without having to do any soldering/PCB changes. The mod requires 3 output pins, two of which can come from the unused programming header and the third makes use of what was the z endstop (my mod presumes you are using a CR/BL touch) and converts the input to an output using the above change. Obviously there are more code changes required in Marlin, but I'm not sure if they would be welcome in core Marlin as people might think you can have dual independent z-axis control without anything other than a code change. Of course if they were welcome I would be more than happy for them to be incorporated. I believe you are the maintainer of the Aquila branch of the mriscoc firmware (nice work), which might be a better location for this feature if you would be happy to accept it, but would completely understand if you didn't.

@thinkyhead thinkyhead added PR: Improvement T: HAL & APIs Topic related to the HAL and internal APIs. A: STM32 labels Jan 9, 2025
@thinkyhead
Copy link
Member

Happy 2025!
Looks good, thanks for the patch!

@thinkyhead thinkyhead merged commit 63bc413 into MarlinFirmware:bugfix-2.1.x Jan 9, 2025
64 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A: STM32 PR: Improvement T: HAL & APIs Topic related to the HAL and internal APIs.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants