Skip to content

rp2/machine_pin: Add support for setting pin drive strength & slew rate #17906

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

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

Conversation

picmaster
Copy link

Summary

Currently when micropython uses GPIO pins as outputs, their actual configuration for pin drive strength and slew rate is the default one, which was set at power-on/reset (4mA, slow slew rate). There's no way to change these pin configurations in the micropython environment (other than low-level hacks with mem32[]).

This patch adds the ability to explicitly configure rp2040/rp2350 output pins' drive strength and slew rate, if/when needed, like this:

pin1 = Pin(1, Pin.OUT, drive=Pin.DRIVE_12, slew=Pin.SLEW_FAST)

As the new drive/slew parameters are optional kwargs, all existing code and examples will still work as expected, like this:

pin2 = Pin(2, Pin.OUT)

All relevant documentation files are updated.

Testing

Tested on rpi-pico and rpi-pico2 boards.

…rate

Currently when micropython uses GPIO pins as outputs, their actual
configuration for pin drive strength and slew rate is the default one,
which was set at power-on/reset (4mA, slow slew rate). There's no way to
change these pin configurations in the micropython environment (other
than low-level hacks with mem32[]).

This patch adds the ability to explicitly configure rp2040/rp2350 output
pins' drive strength and slew rate, if/when needed, like this:

    pin1 = Pin(1, Pin.OUT, drive=Pin.DRIVE_12, slew=Pin.SLEW_FAST)

As the new drive/slew parameters are optional kwargs, all existing code
and examples will still work as expected, like this:

    pin2 = Pin(2, Pin.OUT)

All relevant documentation files are updated.

Tested on rpi-pico and rpi-pico2 boards.

Signed-off-by: Nikolay Dimitrov <nikolay.dimitrov@retrohub.org>
Copy link

Code size report:

   bare-arm:    +0 +0.000% 
minimal x86:    +0 +0.000% 
   unix x64:    +0 +0.000% standard
      stm32:    +0 +0.000% PYBV10
     mimxrt:    +0 +0.000% TEENSY40
        rp2:  +432 +0.047% RPI_PICO_W
       samd:    +0 +0.000% ADAFRUIT_ITSYBITSY_M4_EXPRESS
  qemu rv32:    +0 +0.000% VIRT_RV32

@picmaster
Copy link
Author

Related to issue #14068.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants