Skip to content

Conversation

VynDragon
Copy link
Contributor

Introduce Dynamic pinctrl to micropython zephyr port.

same as #18016 but closer to other ports

Summary

Testing

rp2040, rp2350, bl602, bl702, bl616

Trade-offs and Alternatives

Some Pin-related things were changed and added, like IN and OUT really meaning IN and OUT now

@VynDragon
Copy link
Contributor Author

@dpgeorge Updated version that does pins.

usage:

import machine rx = machine.Pin(None, "UART1_RX_P7", mode=machine.Pin.IN) tx = machine.Pin(None, alt="UART1_TX_P6", mode=machine.Pin.OUT) ser = machine.UART("uart1", rx=rx, tx=tx) ser.write("Hello world\n")
import machine tx = machine.Pin(None, alt="GPIO14_UART1_TX", mode=0) ser = machine.UART("uart1", tx=tx) ser.write("Hello world\n")

Please check if this matches expectations and validate the way it has been implement in UART so i can do the same implementation for the other peripherals.

@VynDragon VynDragon force-pushed the zephyr_dynpinctrl_Pin branch 2 times, most recently from f1b2017 to 2af92c6 Compare October 12, 2025 22:30
Introduce Dynamic pinctrl to micropython zephyr port. Signed-off-by: Vdragon <mail@massdriver.space>
Enables Dynamic Pinctrl on RP2 boards. Signed-off-by: Vdragon <mail@massdriver.space>
Adds some bflb boards that support dynamic pinctrl Signed-off-by: Vdragon <mail@massdriver.space>
Comment on lines +233 to +235
mp_map_t kw_args;
mp_map_init_fixed_table(&kw_args, n_kw, args + n_args);
machine_pin_pinctrl_obj_init_helper(pin, n_args - 1, args + 1, &kw_args);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be interesting to move this after the if { ... } else if { ... } else { ... }?

AFAIU, currently:

pin = Pin(("gpioA", 3)) # allowed pin = Pin(Null, alt="SET_PIN_A3_TO_GPIO") # allowed pin = Pin(("gpioA", 3), alt="SET_PIN_A3_TO_GPIO") # refused

The latter could be handy if pins are moved back and forth between GPIO and other function, or if the board default is not GPIO.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will gather time to test it and make a complete review, and also if I can, add doc but can't guarantee ETAs on that yet.

Copy link
Contributor Author

@VynDragon VynDragon Oct 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is intended, the later can cause several issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

3 participants