Registers: mmio.read and mmio.write
One direct request to a register named in the SVD snapshot, with access-right and effect checks.
since 0.5.0
Methods
| Entry | Signature | Available since | API 3 |
|---|---|---|---|
mmio.read, mmio.write | mmio.read(name, *, allow_effects=False) -> int; mmio.write(name, value, *, allow_effects=False) -> dict | 0.5.0 | new |
API 3 changes (0.5.0)
New in 0.5.0, no await. Needs [mmio] svd in session.toml; read and write effects require allow_effects=True.
Recommended
Atomic set through BSRR; W1C flags with an explicit mask. For modeled input check source → IDR → firmware consumption, neighbour and restoration (tests/modeled-gpio).
idr = t.mmio.read("GPIOC.IDR") # int, one direct read
ack = t.mmio.write("GPIOC.BSRR", 1 << 13) # atomic set, no RMW
t.check("acknowledged", ack["acknowledged"], True)
flags = t.mmio.read("DMA2.LISR")
t.mmio.write("DMA2.LIFCR", flags & 0x3D, allow_effects=True) # W1C: only stream 0 bitsAvoid
A whole-register RMW loses atomicity; reading a register with an effect without consent is refused. No retry after a lost ACK. Override cannot make IDR writable; an ACK for an ignored write is not evidence of stimulus.
t.mmio.write("GPIOC.ODR", t.mmio.read("GPIOC.ODR") | (1 << 13)) # RMW: not atomic
data = t.mmio.read("USART2.DR") # readAction in the SVD: effect_consent_required
try:
data = t.mmio.read("USART2.DR", allow_effects=True)
except ApiError:
data = t.mmio.read("USART2.DR", allow_effects=True) # retry: the FIFO may be drainedThe fragments show refused or discouraged patterns, not a working recipe.
Fragments for a scenario body; firmware symbols are illustrative.