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

Async implementation for both I2C and SPI #26

Open
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

yanshay
Copy link
Contributor

@yanshay yanshay commented Dec 20, 2024

This is a first version of Async, surely needs some fine tuning, but it's working.
Was tested on ESP32S3. The I2C has been working for quite some time w/o any issues. SPI is newer.

Some notes:

  1. Uses maybe_async to avoid code duplications, ~~ therefore at this time default is async and need to set feature is_sync to make it sync (the default for maybe_async). Might want to revisit this for backwards compatibility and make sync the default. default is is_sync and need to use default-features=false for async.
  2. SInce Countdown Error type was lately removed and replaced by a specific error type (nb), I used embassy-time TimeoutError instead of an error type supplied by the user which I think would have been more elegant, not sure if it's good approach. For embedded probably yes since embassy is the de-facto standard and it makes life easier.
  3. Currently async doesn't support IRQ mode. Will probably want to add as a next step. (added)
  4. Needs cleanups for sure, I kept some remarks to remind me of what was before/some alternatives/etc.
  5. Along the way also added wake_up to get SPI to work (for both sync and async).

@yanshay
Copy link
Contributor Author

yanshay commented Jan 4, 2025

@dimpolo A question which you may be able to answer: I implemented Async for SPI. Initially w/o IRQ and it worked as expected. Then I added support for IRQ which was about waiting for the IRQ to be low instead of poll for READY.
It works, except I also see that the device doesn't send an Ack immediately after sending at least the INLIST_ONE_ISO_A_TARGET request. So once time pass the error I get is on Ack not arriving rather than on Timeout. While with the non IRQ code Ack did arrive immediately even when no tag was found within the timeout.
Is that how it's supposed to work in case of using IRQ?

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

Successfully merging this pull request may close these issues.

1 participant