Upgrade to embedded-storage 0.3.0
This commit is contained in:
@ -8,7 +8,9 @@ use core::ptr;
|
||||
use core::slice;
|
||||
use embassy::util::Unborrow;
|
||||
use embassy_hal_common::unborrow;
|
||||
use embedded_storage::nor_flash::{MultiwriteNorFlash, NorFlash, ReadNorFlash};
|
||||
use embedded_storage::nor_flash::{
|
||||
ErrorType, MultiwriteNorFlash, NorFlash, NorFlashError, NorFlashErrorKind, ReadNorFlash,
|
||||
};
|
||||
|
||||
pub const PAGE_SIZE: usize = 4096;
|
||||
pub const FLASH_SIZE: usize = crate::chip::FLASH_SIZE;
|
||||
@ -20,6 +22,15 @@ pub enum Error {
|
||||
Unaligned,
|
||||
}
|
||||
|
||||
impl NorFlashError for Error {
|
||||
fn kind(&self) -> NorFlashErrorKind {
|
||||
match self {
|
||||
Self::OutOfBounds => NorFlashErrorKind::OutOfBounds,
|
||||
Self::Unaligned => NorFlashErrorKind::NotAligned,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct Nvmc<'d> {
|
||||
_p: PhantomData<&'d NVMC>,
|
||||
}
|
||||
@ -43,9 +54,11 @@ impl<'d> Nvmc<'d> {
|
||||
|
||||
impl<'d> MultiwriteNorFlash for Nvmc<'d> {}
|
||||
|
||||
impl<'d> ReadNorFlash for Nvmc<'d> {
|
||||
impl<'d> ErrorType for Nvmc<'d> {
|
||||
type Error = Error;
|
||||
}
|
||||
|
||||
impl<'d> ReadNorFlash for Nvmc<'d> {
|
||||
const READ_SIZE: usize = 1;
|
||||
|
||||
fn read(&mut self, offset: u32, bytes: &mut [u8]) -> Result<(), Self::Error> {
|
||||
|
Reference in New Issue
Block a user