Skip to content

Commit

Permalink
Merge pull request #693 from quartiq/feature/embedded-storage-update
Browse files Browse the repository at this point in the history
Updating to embedded-storage 0.3
  • Loading branch information
burrbull authored Nov 16, 2023
2 parents a7406b6 + 0b6fa71 commit 2d8d882
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- complete and rework Dma Stream API [#666]
- SPI bidi takes 2 pins [#526]
- `Fast Read Quad I/O (EBh)` in `qspi-w25q` example now matches W25QXX datasheet. [#682]
- `embedded-storage` version bumped to 0.3

### Fixed

Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ fugit-timer = "0.1.3"
rtic-monotonic = { version = "1.0", optional = true }
systick-monotonic = { version = "1.0", optional = true }
bitflags = "2.2"
embedded-storage = "0.2"
embedded-storage = "0.3"
vcell = "0.1.3"

[dependencies.time]
Expand Down
23 changes: 19 additions & 4 deletions src/flash.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
use embedded_storage::nor_flash::{MultiwriteNorFlash, NorFlash, ReadNorFlash};
use embedded_storage::nor_flash::{
ErrorType, MultiwriteNorFlash, NorFlash, NorFlashError, NorFlashErrorKind, ReadNorFlash,
};

use crate::pac::FLASH;
use crate::signature::FlashSize;
Expand Down Expand Up @@ -357,9 +359,24 @@ pub fn flash_sectors(flash_size: usize, dual_bank: bool) -> impl Iterator<Item =
}
}

impl ReadNorFlash for LockedFlash {
impl NorFlashError for Error {
fn kind(&self) -> NorFlashErrorKind {
match self {
Error::ProgrammingAlignment => NorFlashErrorKind::NotAligned,
_ => NorFlashErrorKind::Other,
}
}
}

impl ErrorType for LockedFlash {
type Error = Error;
}

impl ErrorType for UnlockedFlash<'_> {
type Error = Error;
}

impl ReadNorFlash for LockedFlash {
const READ_SIZE: usize = 1;

fn read(&mut self, offset: u32, bytes: &mut [u8]) -> Result<(), Self::Error> {
Expand All @@ -374,8 +391,6 @@ impl ReadNorFlash for LockedFlash {
}

impl<'a> ReadNorFlash for UnlockedFlash<'a> {
type Error = Error;

const READ_SIZE: usize = 1;

fn read(&mut self, offset: u32, bytes: &mut [u8]) -> Result<(), Self::Error> {
Expand Down

0 comments on commit 2d8d882

Please sign in to comment.