diff options
Diffstat (limited to 'embassy-embedded-hal/src/flash/partition/mod.rs')
| -rw-r--r-- | embassy-embedded-hal/src/flash/partition/mod.rs | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/embassy-embedded-hal/src/flash/partition/mod.rs b/embassy-embedded-hal/src/flash/partition/mod.rs new file mode 100644 index 000000000..a12e49ce1 --- /dev/null +++ b/embassy-embedded-hal/src/flash/partition/mod.rs | |||
| @@ -0,0 +1,30 @@ | |||
| 1 | //! Flash Partition utilities | ||
| 2 | |||
| 3 | use embedded_storage::nor_flash::{NorFlashError, NorFlashErrorKind}; | ||
| 4 | |||
| 5 | #[cfg(feature = "nightly")] | ||
| 6 | mod asynch; | ||
| 7 | mod blocking; | ||
| 8 | |||
| 9 | #[cfg(feature = "nightly")] | ||
| 10 | pub use asynch::Partition; | ||
| 11 | pub use blocking::BlockingPartition; | ||
| 12 | |||
| 13 | /// Partition error | ||
| 14 | #[derive(Debug)] | ||
| 15 | #[cfg_attr(feature = "defmt", derive(defmt::Format))] | ||
| 16 | pub enum Error<T> { | ||
| 17 | /// The requested flash area is outside the partition | ||
| 18 | OutOfBounds, | ||
| 19 | /// Underlying flash error | ||
| 20 | Flash(T), | ||
| 21 | } | ||
| 22 | |||
| 23 | impl<T: NorFlashError> NorFlashError for Error<T> { | ||
| 24 | fn kind(&self) -> NorFlashErrorKind { | ||
| 25 | match self { | ||
| 26 | Error::OutOfBounds => NorFlashErrorKind::OutOfBounds, | ||
| 27 | Error::Flash(f) => f.kind(), | ||
| 28 | } | ||
| 29 | } | ||
| 30 | } | ||
