async def main():
assembly = HardwareAssembly()
assembly.use_voltage({"A": 3.3, "B": 3.3})
spi_rom_iface = Memory25xInterface(logger, assembly,
cs="A0", sck="A1", io="A2:5")
uart_iface = UARTInterface(logger, assembly,
rx="B0", tx="B1")
gpio_iface = GPIOInterface(logger, assembly,
pins="B2")
async with assembly:
await spi_rom_iface.qspi.clock.set_frequency(1_000_000)
await uart_iface.set_baud(115200)
# Pretend to program the Flash.
# (Actual production code would likely use `.erase_program(...)` here.)
await gpio_iface.output(0, True)
mfg_id, dev_id = await spi_rom_iface.read_manufacturer_long_device_id()
print(f"flash ID: {mfg_id:02x},{dev_id:04x}")
data = await spi_rom_iface.fast_read(0x1000, 0x10)
print(f"program memory: {data.hex()}")
# Talk to the SoC.
await gpio_iface.output(0, False)
await asyncio.sleep(10e-3)
await uart_iface.write(b"INIT?")
reply = await uart_iface.read(2)
print(reply.hex()) # b"OK"