Skip to content

Commit 2d8d882

Browse files
authored
Merge pull request #693 from quartiq/feature/embedded-storage-update
Updating to embedded-storage 0.3
2 parents a7406b6 + 0b6fa71 commit 2d8d882

File tree

3 files changed

+21
-5
lines changed

3 files changed

+21
-5
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
1212
- complete and rework Dma Stream API [#666]
1313
- SPI bidi takes 2 pins [#526]
1414
- `Fast Read Quad I/O (EBh)` in `qspi-w25q` example now matches W25QXX datasheet. [#682]
15+
- `embedded-storage` version bumped to 0.3
1516

1617
### Fixed
1718

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ fugit-timer = "0.1.3"
4747
rtic-monotonic = { version = "1.0", optional = true }
4848
systick-monotonic = { version = "1.0", optional = true }
4949
bitflags = "2.2"
50-
embedded-storage = "0.2"
50+
embedded-storage = "0.3"
5151
vcell = "0.1.3"
5252

5353
[dependencies.time]

src/flash.rs

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
use embedded_storage::nor_flash::{MultiwriteNorFlash, NorFlash, ReadNorFlash};
1+
use embedded_storage::nor_flash::{
2+
ErrorType, MultiwriteNorFlash, NorFlash, NorFlashError, NorFlashErrorKind, ReadNorFlash,
3+
};
24

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

360-
impl ReadNorFlash for LockedFlash {
362+
impl NorFlashError for Error {
363+
fn kind(&self) -> NorFlashErrorKind {
364+
match self {
365+
Error::ProgrammingAlignment => NorFlashErrorKind::NotAligned,
366+
_ => NorFlashErrorKind::Other,
367+
}
368+
}
369+
}
370+
371+
impl ErrorType for LockedFlash {
372+
type Error = Error;
373+
}
374+
375+
impl ErrorType for UnlockedFlash<'_> {
361376
type Error = Error;
377+
}
362378

379+
impl ReadNorFlash for LockedFlash {
363380
const READ_SIZE: usize = 1;
364381

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

376393
impl<'a> ReadNorFlash for UnlockedFlash<'a> {
377-
type Error = Error;
378-
379394
const READ_SIZE: usize = 1;
380395

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

0 commit comments

Comments
 (0)