-
Notifications
You must be signed in to change notification settings - Fork 232
sdmmc: add HAL traits for SD/MMC peripherals #662
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
base: master
Are you sure you want to change the base?
Conversation
Adds the initial implementation of the `embedded-hal` SD/MMC traits. Includes types and traits useful for handling SD/MMC peripherals.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you! I started reviewing, but I think this PR needs a bit more work.
Did you get a chance to read https://github.com/rust-embedded/embedded-hal/blob/master/docs/how-to-add-a-new-trait.md?
This PR is missing some background work, and demonstration that it can be implemented on at least two targets.
Finally, is this worth abstracting over in eh? This feels like it could be a really great addition to the ecosystem, but equally how sure are we that we're going to cover every controller operation (and the fact you're trying to cover SPI commands here too) with these abstractions?
Perhaps a more worthwhile abstraction for eh would be a block device trait?
This PR might be better as a stand alone crate, at least initially, to demonstrate its viability.
embedded-hal/src/mmc.rs
Outdated
type Error; | ||
|
||
/// Gets whether the device is a MMC card. | ||
fn is_mmc(&self) -> bool; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Imo all these bools should be enums, like CardType::Sd
and TransportMode::Spi
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright, I also prefer new-types, so I'll make those changes.
Not yet, I missed it before opening the PR. Going over it now.
I'm currently implementing it on one platform that uses a DesignWare MMC controller. Should the second platform use a different controller type to meet the requirements?
I think so, but I'm open to differing opinions. SD/MMC controllers are common on SBC boards, and some other microcontrollers. Are there any examples of SD/MMC drivers that implement an e-h block device trait for a SD/MMC peripheral in a non-SPI mode?
That's not exactly the intention. How I imagine it working is that users will implement the SPI trait(s) for the controller/peripheral, and use those methods to implement the
I am currently working on the traits in the jh71xx-hal crate, and the driver crate that builds on that work in sdmmc-driver. |
Adds the `CardType` enum to represent the device type for a SD/MMC perpipheral.
The |
Adds the `CardMode` enum to represent the device mode for a SD/MMC perpipheral.
Adds the initial implementation of the
embedded-hal
SD/MMC traits.Includes types and traits useful for handling SD/MMC peripherals.