Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setup panics if RX FIFO is not empty #16

Open
jannic opened this issue Sep 5, 2022 · 2 comments
Open

Setup panics if RX FIFO is not empty #16

jannic opened this issue Sep 5, 2022 · 2 comments

Comments

@jannic
Copy link
Member

jannic commented Sep 5, 2022

As noticed here, setup will panic if self.rx is not empty. This could happen after an error condition in finish.

@ithinuel
Copy link
Member

ithinuel commented Sep 5, 2022

If finish is called while an error condition has been detected, resume_after_error flushes the tx fifo and restarts the SM, and wait_idle waits until the SM has stalled on the first OUT instruction.
stop only sends instructions and therefore cannot generate an error condition (=no ack).

In case of error during a read operation, the data in the buffer are unreliable, there's no feed back to caller as to how many bytes were received before the error. A caller may rely on pattern matching to detect that? 🤷

read should empty the rx fifo before exiting to drain all the success fully clocked in bytes.
write already flushes the RX firo before exiting, as any rx bytes are to be ignored.

This'd effectively ensure that finish is always called with an empty RX FIFO (possibly in case of error, with a non-empty TX fifo to be drained by resume_after_error).

@ithinuel
Copy link
Member

ithinuel commented Sep 9, 2022

This should be fixed by #17.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants