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

Make the SPI FIFO a separate object from the master driver #1579

Closed
wants to merge 11 commits into from

Conversation

Dominaezzz
Copy link
Collaborator

@Dominaezzz Dominaezzz commented May 23, 2024

Thank you for your contribution!

We appreciate the time and effort you've put into this pull request.
To help us review it efficiently, please ensure you've gone through the following checklist:

Submission Checklist 📝

  • I have updated existing examples or added new ones (if applicable).
  • I have used cargo xtask fmt-packages command to ensure that all changed code is formatted correctly.
  • My changes were added to the CHANGELOG.md in the proper section.
  • My changes are in accordance to the esp-rs API guidelines

Extra:

Pull Request Details 📖

Description

The title says it all but basically this PR makes it so that when you create an Spi driver you get a separate FIFO object as well.
The main advantage of this being you can split the FIFO in two and prepare one half of it whilst the other is being used in an active transfer.
There's other advantages and I've outlined then in this comment.

Testing

I ran the new and existing examples on my M5Stack CoreS3.
My new example isn't quite working, I fear I may have hit a hardware bug https://www.esp32.com/viewtopic.php?f=14&t=31389 . If I can't figure it out then I'll remove the FIFO splitting feature. No hardware bug, apparently the async fifos need to also be cleared in FIFO mode, which the existing code didn't do, so I've added that and the example works.

esp-hal/src/spi/master.rs Outdated Show resolved Hide resolved
Comment on lines 364 to 367
pub struct WholeFifo;
pub struct HalfFifo {
is_high_part: bool,
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I initially had an additional LowerHalfFifo and UpperHalfFifo types, that could be downgraded into a HalfFifo, but I figured no one would really care in practice and this would be excessive generics/type state.

# Conflicts:
#	examples/src/bin/spi_eh1_device_loopback.rs
#	examples/src/bin/spi_eh1_loopback.rs
@MabezDev
Copy link
Member

MabezDev commented Jun 3, 2024

Sorry for not getting to this yet, I will make some time this week to look at this and your proposal in the original issue.

@Dominaezzz Dominaezzz force-pushed the spi_fifo branch 2 times, most recently from 5b787eb to db942a8 Compare June 5, 2024 22:50
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.

3 participants