Add storage ReadWrite trait, and helper structs, traits and iterators #248
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I would like to propose an alternative solution to #28 .
There is currently one solution in #241, this is an alternative and simpler approach, highly inspired by the blog series by Cuervo in https://www.ecorax.net/as-above-so-below-1/ and https://www.ecorax.net/as-above-so-below-2/
The traits are implemented here (still working on the documentation): https://github.com/MathiasKoch/is25xp
and here: https://github.com/MathiasKoch/stm32l4xx-hal/blob/factbird-mini-1.0/src/flash.rs
I think this makes it MUCH easier for driver authors to make use of such a trait, compared to the solution given in #241 with a total of 5 traits. Also the helper iterators makes it much easier to handle optimizing for NOR flashes where writing
1
s is not an option, without just defaulting to writing everything, as explained in above blog series.EDIT:
After having used this for a while, there are a couple of notes and pain points to be addressed/discussed.
try_erase
function is close to useless as it is currently, as it does only allow erasing the full memory range, as opposed to sections/regions/range. Any suggestions for a better approach? One possible could be to take a range (fn try_erase(&mut self, range: (Address, Address))
orfn try_erase(&mut self, from: Address, to: Address)
)?trait Read
and atrait ReadWrite: Read
, to support read-only memory? I have never encountered write-only, so i guessReadWrite
would make perfectly sense?Any feedback is welcommed!
Closes #28