Skip to content

I2C/SoftI2C primitives mostly done; init/deinit need PyMCU/PyMCU#455, writevto/I2CTarget remain #15

Description

@begeistert

Update 2026-09-15: most of this is done

Implemented for both machine.I2C and machine.SoftI2C: start(), stop(), write(buf),
readinto(buf, nack=1), writeto_mem(addr, memaddr, buf, *, addrsize=8),
readfrom_mem_into(addr, memaddr, buf, *, addrsize=8), plus a readfrom_mem(addr, memaddr, buf, n) caller-buffer extension. I2C already had writeto_mem/readfrom_mem ready-made in
the HAL; SoftI2C's equivalents are sequenced directly from start()/write()/read(),
which turned out to already be real HAL methods on both _I2C and _SoftI2C -- just never
wired to machine.py. SoftI2C.deinit() is a true no-op (bit-banged, nothing to release),
matching SoftSPI.deinit(). All of the above match the real stub except the trailing
positional-only /, so they're allowlisted at PyMCU/pymcu-micropython#12, not closed
outright.

Remaining, now precisely named:

Original report

MicroPython's machine.I2C/SoftI2C expose a lower-level primitive API (init, deinit,
start, stop, write, readinto) for manual bus sequencing, register-style helpers
(readfrom_mem, readfrom_mem_into, writeto_mem, writevto), and a target/slave mode
(machine.I2CTarget). None of it existed.

Repo choice

init()/deinit(): PyMCU/PyMCU#455 (and #453 for SoftI2C.init()). writevto/
I2CTarget: real, separate work, repo undetermined until scoped.

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