diff --git a/examples/flash.rs b/examples/flash.rs index 89edfe4..bce973b 100644 --- a/examples/flash.rs +++ b/examples/flash.rs @@ -222,3 +222,6 @@ fn main() -> ! { continue; } } + +#[cfg(feature = "littlefs")] +lpc55_hal::littlefs2_filesystem!(InternalFilesystem: (0, 10)); diff --git a/src/drivers/flash.rs b/src/drivers/flash.rs index 3f325c3..ad362bd 100644 --- a/src/drivers/flash.rs +++ b/src/drivers/flash.rs @@ -439,27 +439,27 @@ macro_rules! littlefs2_filesystem { type LOOKAHEAD_SIZE = $crate::drivers::flash::littlefs_params::LOOKAHEAD_SIZE; - fn read(&mut self, off: usize, buf: &mut [u8]) -> LfsResult { + fn read(&mut self, off: usize, buf: &mut [u8]) -> littlefs2::io::Result { <$crate::drivers::flash::FlashGordon as $crate::traits::flash::Read<$crate::drivers::flash::U16>> ::read(&self.flash_gordon, Self::BASE_OFFSET + off, buf); Ok(buf.len()) } - fn write(&mut self, off: usize, data: &[u8]) -> LfsResult { + fn write(&mut self, off: usize, data: &[u8]) -> littlefs2::io::Result { let ret = <$crate::drivers::flash::FlashGordon as $crate::traits::flash::WriteErase<$crate::drivers::flash::U512, $crate::drivers::flash::U512>> ::write(&mut self.flash_gordon, Self::BASE_OFFSET + off, data); ret .map(|_| data.len()) - .map_err(|_| littlefs2::io::Error::Io) + .map_err(|_| littlefs2::io::Error::IO) } - fn erase(&mut self, off: usize, len: usize) -> LfsResult { + fn erase(&mut self, off: usize, len: usize) -> littlefs2::io::Result { let first_page = (Self::BASE_OFFSET + off) / 512; let pages = len / 512; for i in 0..pages { <$crate::drivers::flash::FlashGordon as $crate::traits::flash::WriteErase<$crate::drivers::flash::U512, $crate::drivers::flash::U512>> ::erase_page(&mut self.flash_gordon, first_page + i) - .map_err(|_| littlefs2::io::Error::Io)?; + .map_err(|_| littlefs2::io::Error::IO)?; } Ok(512 * len) } @@ -523,7 +523,7 @@ macro_rules! littlefs2_prince_filesystem { type LOOKAHEAD_SIZE = $crate::drivers::flash::littlefs_params::LOOKAHEAD_SIZE; - fn read(&mut self, off: usize, buf: &mut [u8]) -> LfsResult { + fn read(&mut self, off: usize, buf: &mut [u8]) -> littlefs2::io::Result { self.prince.enable_region_2_for(||{ let flash: *const u8 = (Self::BASE_OFFSET + off) as *const u8; for i in 0 .. buf.len() { @@ -533,7 +533,7 @@ macro_rules! littlefs2_prince_filesystem { Ok(buf.len()) } - fn write(&mut self, off: usize, data: &[u8]) -> LfsResult { + fn write(&mut self, off: usize, data: &[u8]) -> littlefs2::io::Result { let prince = &mut self.prince; let flash_gordon = &mut self.flash_gordon; let ret = prince.write_encrypted(|prince| { @@ -545,17 +545,17 @@ macro_rules! littlefs2_prince_filesystem { }); ret .map(|_| data.len()) - .map_err(|_| littlefs2::io::Error::Io) + .map_err(|_| littlefs2::io::Error::IO) } - fn erase(&mut self, off: usize, len: usize) -> LfsResult { + fn erase(&mut self, off: usize, len: usize) -> littlefs2::io::Result { let first_page = (Self::BASE_OFFSET + off) / 512; let pages = len / 512; for i in 0..pages { <$crate::drivers::flash::FlashGordon as $crate::traits::flash::WriteErase<$crate::drivers::flash::U512, $crate::drivers::flash::U512>> ::erase_page(&mut self.flash_gordon, first_page + i) - .map_err(|_| littlefs2::io::Error::Io)?; + .map_err(|_| littlefs2::io::Error::IO)?; } Ok(512 * len) }