-
-
Notifications
You must be signed in to change notification settings - Fork 8.2k
ESP32: add pin drive strength #8313
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
ESP32: add pin drive strength #8313
Conversation
I have verified all four drive strengths on real ESP32 hardware. The IDF docs suggest that the same drive strength values apply to S2, S3 and C3 variants, but I have no real hardware to test this on. The maximum source/sink currents come from note 8 in table 24 of the ESP32 Datasheet; the approximate internal resistances come from my own tests and this useful forum post. The drivers are non-linear so pushing them to the limit results in much higher apparent resistance. I've gone with roughly where they stand when running at the maximum recommended current. I've included these rough internal resistances in the docs because they can make a big difference to circuit design – e.g., in terms of resistor choice when driving an LED. |
4c8c373
to
57ad52a
Compare
57ad52a
to
ed15d7b
Compare
Thanks for this, the feature looks good. The only problem is the name of the drive constants:
There was a discussion of the drive/power constants for mimxrt, but I'm not sure why it ended up being different to the docs. Probably because there are many values and it's hard to name them with low/med/high etc and understand the ordering. I do actually prefer the names It would be good to make all of this consistent. Here is my suggestion: use constants @robert-hh what do you think? |
@dpgeorge It is always favorable to have a common API, and I can go with any name, shorter being better. I'll discuss it with @alphaFred, because that part was made by him. |
Hi @dpgeorge |
Add support for configuring drive strength of output pins with `drive` keyword argument and `DRIVE_*` constants.
Add brief documentation of the new `drive` keyword argument.
Update documents with new common names for the drive strength constants.
ed15d7b
to
59ffb6b
Compare
Sounds good to me! I've updated my code and docs, and added a bonus commit updating the |
OK, so we go with |
Yes. I will provide a PR for mimxrt soon, too. |
Add support for setting the ESP32 GPIO drive strength. There are four supported strengths:
Pin.DRIVE_WEAK
: 5mA (max source/sink current) / 130 ohm (approx internal resistance)Pin.DRIVE_LOW
: 10mA / 60 ohmPin.DRIVE_MED
: 20mA / 30 ohmPin.DRIVE_HIGH
: 40mA / 15 ohmI've used the standard 3 documented drive strength constant names from the
machine.Pin
module docs and addedDRIVE_WEAK
for the extra one that the ESP32 supports – decided to put it at the weaker end rather than having aDRIVE_HIGHEST
constant as the ESP32 default is2
and that seems to match most naturally toDRIVE_MED
.This was previously bundled up in PR #8284, but having used this functionality for a bit I've decided that it is sufficiently useful to be pulled out on its own and not tied to that (more controversial) PR.
Fixes #8315.