Skip to content

Add rp2 override_invert#19336

Open
HighImp wants to merge 2 commits into
micropython:masterfrom
HighImp:topic/add_deep_invert
Open

Add rp2 override_invert#19336
HighImp wants to merge 2 commits into
micropython:masterfrom
HighImp:topic/add_deep_invert

Conversation

@HighImp

@HighImp HighImp commented Jun 12, 2026

Copy link
Copy Markdown

Summary

For some applications, inversion will be a hardware solution for otherwise inverted logic, avoiding software-side inversion and related issues (buttons, low-side LEDs, etc.), as described in the RST. However, I love the fact that it will also affect alternative functions. For example, hardware-side inversion will allow half-duplex UART communication with open-collector and an N-channel low-side driver without any restrictions, based on the hardware UART.

Testing

I added a simple test that checks input and output with and without inversion.

Trade-offs and Alternatives

I am not sure about the code increase; however, this is a local change for the RP2xxx, and will not affect very small controllers. It is worth it because it will make the code for some common hardware designs much easier.
It would be possible to split it further into invert_in and invert_out, but i think the total inversion is much more common than just one direction.

Generative AI

I used generative AI tools when creating this PR, but a human has checked the code and is responsible for the code and the description above. I built it locally and ran the test on my hardware. I did run this through a spellchecker, though, but this is handwritten. ;-)

@codecov

codecov Bot commented Jun 12, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.51%. Comparing base (d901e98) to head (39dc0ed).

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #19336   +/-   ##
=======================================
  Coverage   98.51%   98.51%           
=======================================
  Files         176      176           
  Lines       22903    22903           
=======================================
  Hits        22562    22562           
  Misses        341      341           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions

github-actions Bot commented Jun 12, 2026

Copy link
Copy Markdown

Code size report:

Reference:  unix/README: Update the supported targets list. [d901e98]
Comparison: docs: Document rp2 Pin invert kwarg. [merge of 9c4b9fd]
  mpy-cross:    +0 +0.000% 
   bare-arm:    +0 +0.000% 
minimal x86:    +0 +0.000% 
   unix x64:    +0 +0.000% standard
      stm32:    +0 +0.000% PYBV10
      esp32:    +0 +0.000% ESP32_GENERIC
     mimxrt:    +0 +0.000% TEENSY40
        rp2:  +144 +0.016% RPI_PICO_W
       samd:    +0 +0.000% ADAFRUIT_ITSYBITSY_M4_EXPRESS
  qemu rv32:    +0 +0.000% VIRT_RV32

@HighImp HighImp force-pushed the topic/add_deep_invert branch 2 times, most recently from 39dc0ed to 2a61d4e Compare June 12, 2026 21:48
Sebastian Koell added 2 commits June 12, 2026 23:49
Add Pin.init(invert=...) support that sets gpio_set_inover() and
gpio_set_outover() together.  Includes a regression test.

Signed-off-by: Sebastian Koell <Seb.Koell@gmail.com>
Signed-off-by: Sebastian Koell <Seb.Koell@gmail.com>
@HighImp HighImp force-pushed the topic/add_deep_invert branch from 2a61d4e to 9c4b9fd Compare June 12, 2026 21:49
@octoprobe-bot

Copy link
Copy Markdown

Octoprobe PR report

Test Tests
passed
Tests
skipped
Tests
xfailed
Tests
failed
format flash 5
run-tests.py 4725 565 7
run-tests.py --via-mpy --emit native 4662 630 5
run-tests.py --via-mpy 4725 567 5
run-perfbench.py 120
run-natmodtests.py 180 23 2
run-tests.py --test-dirs=extmod_hardware 9 30 11
run-tests.py --test-dirs=extmod_hardware --emit-native 9 30 11
Total 14435 1845 24 17
Failures

Group: run-tests.py

Test rp2
5334-
RPI_PICO2
rp2
5334-
RPI_PICO2-
RISCV
rp2
552b-
RPI_PICO2_W
rp2
5f2c-
RPI_PICO_W
rp2
6038-
RPI_PICO_W
extmod/select_poll_eintr.py skip skip pass FAIL pass
extmod/select_poll_udp.py skip skip pass FAIL pass
ports/rp2/pin_invert.py FAIL FAIL FAIL FAIL FAIL

Group: run-tests.py --via-mpy --emit native

Test rp2
5334-
RPI_PICO2
rp2
5334-
RPI_PICO2-
RISCV
rp2
552b-
RPI_PICO2_W
rp2
5f2c-
RPI_PICO_W
rp2
6038-
RPI_PICO_W
ports/rp2/pin_invert.py FAIL FAIL FAIL FAIL FAIL

Group: run-tests.py --via-mpy

Test rp2
5334-
RPI_PICO2
rp2
5334-
RPI_PICO2-
RISCV
rp2
552b-
RPI_PICO2_W
rp2
5f2c-
RPI_PICO_W
rp2
6038-
RPI_PICO_W
ports/rp2/pin_invert.py FAIL FAIL FAIL FAIL FAIL

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.

3 participants