Skip to content

Commit 8748b5c

Browse files
committed
Updating to embedded-storage 0.3
1 parent a7406b6 commit 8748b5c

File tree

2 files changed

+20
-5
lines changed

2 files changed

+20
-5
lines changed

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)