NathanY3G / rp2040-pio-emulator

RP2040 emulator for the testing and debugging of PIO programs
Apache License 2.0
40 stars 7 forks source link

How do I specify the contents of the TX Fifo prior to running a program? #121

Closed dgnuff closed 10 months ago

dgnuff commented 11 months ago

Title pretty much says it all. I've looked at the two documents I can find, the Quick start guide, and the Tour, and neither of them say anything about how to specify the contents of the TX Fifo prior to starting execution. I know it's supported, otherwise the OUT instruction would not be able to work properly.

NathanY3G commented 11 months ago

Hi @dgnuff :wave:

It should be possible to pass the TX FIFO into emulate() via the optional initial_state parameter. For example:

from collections import deque
from pioemu import emulate, State

initial_state = State(transmit_fifo=deque([1, 2, 3]))
opcodes = [0x80a0, 0x6060]

for before, after in emulate(opcodes, initial_state=initial_state, stop_when=...):
    pass # etc.

However, if this doesn't work for you please let me know.

dgnuff commented 10 months ago

That works - thanks for the help.

Closing this issue.

NathanY3G commented 10 months ago

Thanks @dgnuff. If you find this mechanism doesn't scale to your needs then please just raise another issue!