Skip to content

UART init/deinit/flush/sendbreak/txdone need new HAL primitives (PyMCU/PyMCU#451); irq() done #16

Description

@begeistert

Update 2026-09-15: irq() done, the other four named precisely at PyMCU/PyMCU#451

machine.UART.irq(handler, trigger=0, hard=0) is implemented, wrapping the HAL's own
UART.irq() (which already existed: RXCIE0 + global interrupts + compile_isr, the same
primitive Pin.irq/Timer.irq already use). trigger=/hard= are accepted and ignored --
this chip's USART has one real interrupt source and every ISR here is already a true
hardware interrupt. The stub declares handler/trigger/hard positional-only
(self, handler=None, trigger=0, hard=False, /), so the signature stays blocked on
PyMCU/pymcu-micropython#12 (moved the allowlist entry there, alongside PWM's and
Pin.value's identically-shaped setters).

init()/deinit()/flush()/sendbreak()/txdone() genuinely need new HAL primitives (the
existing uart_write()'s busy-wait is on the wrong flag for flush/txdone: UDRE0, "ready
for the next byte", not TXC0, "the last byte finished"). Named exactly at
PyMCU/PyMCU#451 (milestone Peripherals): uart_reinit/uart_flush/uart_tx_done/
uart_deinit, plus a note that sendbreak() is real additional work (baud-rate-relative
pin-level timing, no native break mode on this USART) and that most of init()'s stub
keywords (tx=/rx=/txbuf=/rxbuf=/timeout=/timeout_char=/invert=/flow=/rts=/
cts=) describe hardware this USART does not have.

Original report

machine.UART only offers __init__, write, read, readline, readinto, any and
three PyMCU-only helpers (write_str, println, print_byte). Compared against
micropython-rp2-stubs, init()/deinit()/flush()/irq()/sendbreak()/txdone() were
missing.

Repo choice

irq() closed in src/pymcu_micropython/machine.py. The rest: PyMCU/PyMCU#451 (HAL), then
thin wrappers here.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions