Skip to content

start adding argument and response module#232

Merged
thejpster merged 4 commits into
rust-embedded-community:developfrom
robamu:argument-response-module
May 9, 2026
Merged

start adding argument and response module#232
thejpster merged 4 commits into
rust-embedded-community:developfrom
robamu:argument-response-module

Conversation

@robamu
Copy link
Copy Markdown
Contributor

@robamu robamu commented Mar 2, 2026

Nice types for SD mode arguments and responses using bitbybit

@robamu robamu force-pushed the argument-response-module branch from 2e7bd36 to 1ba799f Compare March 2, 2026 21:50
Comment thread src/sdcard/mod.rs Outdated
@robamu robamu force-pushed the argument-response-module branch 2 times, most recently from c0d50f5 to b9d7961 Compare March 3, 2026 15:42
@thejpster
Copy link
Copy Markdown
Member

Looks good, but I see these types aren't yet used. Is there a plan to use them?

@robamu
Copy link
Copy Markdown
Contributor Author

robamu commented Mar 4, 2026

for now, these can be used for implementing SD drivers in separate crates. Implementing a generic SD driver which use these inside the library could work, but a generic transport trait to send CMDs/ACMDS is required first and I am not fully sure how well that works.

@robamu robamu force-pushed the argument-response-module branch 3 times, most recently from d322f44 to 9300e6a Compare March 9, 2026 15:36
@robamu robamu force-pushed the argument-response-module branch from 9300e6a to f1bb923 Compare March 29, 2026 21:28
@robamu robamu requested a review from thejpster March 29, 2026 21:30
@robamu robamu force-pushed the argument-response-module branch 3 times, most recently from 1320605 to d5b63d9 Compare April 1, 2026 12:36
@robamu
Copy link
Copy Markdown
Contributor Author

robamu commented Apr 1, 2026

rebased again

Comment thread src/sdcard/argument.rs Outdated
@thejpster
Copy link
Copy Markdown
Member

Looks ok, but I think we need some kind of example to show how to use them. How hard would it be to build a fake SD Card with an API to send requests and get responses that an example can drive in a similar way to how you would initialise an actual SD Card?

@robamu
Copy link
Copy Markdown
Contributor Author

robamu commented May 4, 2026

hmm. probably okay? For most responses, it is relatively clear what the SD card needs to send back, or at the very least what is relevant. I can look into this. If we do something like that, we should write to so it can be re-used for tests.

@robamu robamu force-pushed the argument-response-module branch 2 times, most recently from 249f68e to f086ce3 Compare May 9, 2026 14:23
@robamu robamu force-pushed the argument-response-module branch from f086ce3 to da26567 Compare May 9, 2026 14:25
@robamu
Copy link
Copy Markdown
Contributor Author

robamu commented May 9, 2026

I added a SdCardMock which is basically a virtualized SD card. currently, I only implemented the internal state machine to allow performing the SD card initialization with it.

@robamu
Copy link
Copy Markdown
Contributor Author

robamu commented May 9, 2026

In the SD card example, we could still implement the primary SD driver traits.. this makes it a bit clearer how everything fits together I suppose.

@robamu robamu requested a review from thejpster May 9, 2026 14:34
@robamu
Copy link
Copy Markdown
Contributor Author

robamu commented May 9, 2026

The initialization sequence I implemented is really similar to the ones I implemented for the SAM9G20 SD controller and the Z7 SD controller. the only thing i strongly simplified is that I do not handle the case of pre V2 SD cards where there is not CMD8 reply. for that, I would have to add some sort of way to simulate CMD timeouts.

Comment thread src/sdcard/mock.rs Outdated
Comment thread src/sdcard/mock.rs Outdated
Comment thread src/sdcard/mock.rs Outdated
Comment thread src/sdcard/mock.rs Outdated
Comment thread src/sdcard/mock.rs
Comment thread src/sdcard/mock.rs Outdated
Co-authored-by: Jonathan 'theJPster' Pallant <github@thejpster.org.uk>
@thejpster thejpster enabled auto-merge May 9, 2026 15:21
@robamu
Copy link
Copy Markdown
Contributor Author

robamu commented May 9, 2026

I am onto adding support for alternative mockinng modes (SD1, SD2, SDHC) :)

@thejpster
Copy link
Copy Markdown
Member

Looks comprehensive, thanks!

@thejpster thejpster added this pull request to the merge queue May 9, 2026
Merged via the queue into rust-embedded-community:develop with commit 03f08e5 May 9, 2026
7 checks passed
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.

2 participants