-
Notifications
You must be signed in to change notification settings - Fork 293
sdio: initial SDIO HAL implementation #3503
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: main
Are you sure you want to change the base?
Conversation
esp-hal/src/sdio/esp32c6.rs
Outdated
} | ||
|
||
/// Releases the inner SDIO peripherals back to the caller. | ||
pub const fn release(self) -> (SLC, SLCHOST) { |
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.
FYI this pattern goes against our guidelines in esp-hal: https://github.com/esp-rs/esp-hal/blob/main/documentation/DEVELOPER-GUIDELINES.md.
We use peripheral singletons with lifetime parameters, you can "borrow" (our method is called reborrow
, but now I'm wondering if borrow
makes more sense cc: @bugadani) a peripheral to allow drivers to automatically "release" the peripheral singleton again once the driver has been dropped.
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.
I almost completely refactored using your advice, and the developer guidelines. Also took a look at some other peripheral implementations, and hopefully got closer to the intended style of esp-hal
.
Still more to implement for the Info
structs, and will likely add State
+ Configuration
structs. Though, I'm not sure if those would find a better home inside the Sdio
struct, or the peripheral Slc*
structs.
esp-hal/src/sdio/result.rs
Outdated
//! Error and result types for SDIO peripherals. | ||
|
||
/// Convenience alias for the SDIO peripheral [Result](core::result::Result) type. | ||
pub type Result<T> = core::result::Result<T, Error>; |
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.
I don't think this is something that we want, if you need it for the eh impl then please inline it close to where the eh impl will live
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.
I removed the Result
alias, but did keep the Error
type. Error
currently only holds one variant, but the plan is to implement more for specific failure conditions for the hal::mmc
implementation.
b7eeb4c
to
2142d4d
Compare
esp-hal/src/sdio.rs
Outdated
|
||
impl core::error::Error for Error {} | ||
|
||
impl<'d> MmcOps for Sdio<'d> { |
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.
Something is not quite right here. MmcOps
is meant for the master side of this protocol, but you've implemented this on the slave peripheral.
I think you want the SD/MMC peripheral (#1928) and not the SDIO peripheral, right?
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.
Something is not quite right here.
MmcOps
is meant for the master side of this protocol, but you've implemented this on the slave peripheral.I think you want the SD/MMC peripheral (#1928) and not the SDIO peripheral, right?
Correct, the MmcOps
trait is currently for the host, and I need to split the trait into potentially three traits:
MmcCommon
MmcHost
MmcDevice
I'll keep working on the e-h trait along with the work in this pull request. Thanks for the review.
dddf388
to
c3a7b0d
Compare
Running the As I get closer to a full implementation, I may need to bring in the What's strange is that running I'll keep debugging. |
It would be best to not block this PR on embedded-hal, as it'll likely take months to stabilize a new set of traits. You should instead demonstrate new functionality in a new crate, like That way you wouldn't have to patch around the dependency issues with multiple embedded-hal versions in the same project. |
To expand on @bugadani's comment, we can't merge this with git dependencies, so I would take the suggestion to split this into a separate crate and then work on upstreaming to eh proper. Feel free to iterate here in the mean time, but if you want this merged it won't be with a fork of embedded-hal. |
This sounds like a good plan. I'll bring it up in next week's meeting, and see what the rest of the HAL team thinks.
Right, I had no intention of trying to get this PR merged with the git dependency. My original thought process was to prove the implementation here and in However, the solution discussed above sounds like a better plan. We could do a Without trying to bikeshed too much, we would probably need to call it |
Uses the experimental `embedded-hal-sdmmc` crate for SD/MMC traits. See discussion for reasoning: - <esp-rs#3503 (comment)> - <esp-rs#3503 (comment)> - <esp-rs#3503 (comment)>
Provides the initial skeleton for the `embedded_hal::mmc::MmcOps` implementation for the SDIO peripherals on the ESP32C6 microcontroller.
Adds `Pins` + `Mode` type for SDIO GPIO pin configuration.
Adds the `State` type to represent the SDIO states + transitions.
Uses the experimental `embedded-hal-sdmmc` crate for SD/MMC traits. See discussion for reasoning: - <esp-rs#3503 (comment)> - <esp-rs#3503 (comment)> - <esp-rs#3503 (comment)>
Uses the experimental `embedded-hal-sdmmc` crate for SD/MMC traits. See discussion for reasoning: - <esp-rs#3503 (comment)> - <esp-rs#3503 (comment)> - <esp-rs#3503 (comment)>
Uses the experimental `embedded-hal-sdmmc` crate for SD/MMC traits. See discussion for reasoning: - <esp-rs#3503 (comment)> - <esp-rs#3503 (comment)> - <esp-rs#3503 (comment)>
Uses the experimental `embedded-hal-sdmmc` crate for SD/MMC traits. See discussion for reasoning: - <esp-rs#3503 (comment)> - <esp-rs#3503 (comment)> - <esp-rs#3503 (comment)>
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 📝
cargo xtask fmt-packages
command to ensure that all changed code is formatted correctly.CHANGELOG.md
in the proper section.Extra:
Pull Request Details 📖
Description
Provides the initial skeleton for the
embedded_hal::mmc::MmcOps
implementation for the SDIO peripherals on the ESP32C6 microcontroller.Testing
Doc tests for now.
Integration tests via
examples
program is WIP.