aboutsummaryrefslogtreecommitdiff
path: root/embassy-stm32/src/flash/common.rs
diff options
context:
space:
mode:
authorRasmus Melchior Jacobsen <[email protected]>2023-05-25 21:52:35 +0200
committerRasmus Melchior Jacobsen <[email protected]>2023-05-25 21:52:35 +0200
commit983f01016becd0ab51fb542ec2c1ca6745df60cc (patch)
treebe88b8b023d2a7614fd808f96a14bcd1fd9eb079 /embassy-stm32/src/flash/common.rs
parent9eca19b49d462e57308e8b13f7ff03e10cfb0557 (diff)
parentc02759ad91994191944b4fd1a4b47cd310416c04 (diff)
Merge branch 'async-flash' of https://github.com/rmja/embassy into async-flash
Diffstat (limited to 'embassy-stm32/src/flash/common.rs')
-rw-r--r--embassy-stm32/src/flash/common.rs21
1 files changed, 15 insertions, 6 deletions
diff --git a/embassy-stm32/src/flash/common.rs b/embassy-stm32/src/flash/common.rs
index 54c8d6812..1ea65c0b6 100644
--- a/embassy-stm32/src/flash/common.rs
+++ b/embassy-stm32/src/flash/common.rs
@@ -83,7 +83,16 @@ impl interrupt::Handler<crate::interrupt::FLASH> for InterruptHandler {
83 } 83 }
84} 84}
85 85
86pub(super) fn blocking_read(base: u32, size: u32, offset: u32, bytes: &mut [u8]) -> Result<(), Error> { 86/// Interrupt handler
87pub struct InterruptHandler;
88
89impl interrupt::Handler<crate::interrupt::FLASH> for InterruptHandler {
90 unsafe fn on_interrupt() {
91 family::on_interrupt();
92 }
93}
94
95pub(super) fn read_blocking(base: u32, size: u32, offset: u32, bytes: &mut [u8]) -> Result<(), Error> {
87 if offset + bytes.len() as u32 > size { 96 if offset + bytes.len() as u32 > size {
88 return Err(Error::Size); 97 return Err(Error::Size);
89 } 98 }
@@ -246,11 +255,11 @@ impl<MODE> embedded_storage::nor_flash::NorFlash for Flash<'_, MODE> {
246 const ERASE_SIZE: usize = MAX_ERASE_SIZE; 255 const ERASE_SIZE: usize = MAX_ERASE_SIZE;
247 256
248 fn write(&mut self, offset: u32, bytes: &[u8]) -> Result<(), Self::Error> { 257 fn write(&mut self, offset: u32, bytes: &[u8]) -> Result<(), Self::Error> {
249 self.blocking_write(offset, bytes) 258 self.write_blocking(offset, bytes)
250 } 259 }
251 260
252 fn erase(&mut self, from: u32, to: u32) -> Result<(), Self::Error> { 261 fn erase(&mut self, from: u32, to: u32) -> Result<(), Self::Error> {
253 self.blocking_erase(from, to) 262 self.erase_blocking(from, to)
254 } 263 }
255} 264}
256 265
@@ -280,7 +289,7 @@ foreach_flash_region! {
280 const READ_SIZE: usize = READ_SIZE; 289 const READ_SIZE: usize = READ_SIZE;
281 290
282 fn read(&mut self, offset: u32, bytes: &mut [u8]) -> Result<(), Self::Error> { 291 fn read(&mut self, offset: u32, bytes: &mut [u8]) -> Result<(), Self::Error> {
283 self.blocking_read(offset, bytes) 292 self.read_blocking(offset, bytes)
284 } 293 }
285 294
286 fn capacity(&self) -> usize { 295 fn capacity(&self) -> usize {
@@ -293,11 +302,11 @@ foreach_flash_region! {
293 const ERASE_SIZE: usize = $erase_size; 302 const ERASE_SIZE: usize = $erase_size;
294 303
295 fn write(&mut self, offset: u32, bytes: &[u8]) -> Result<(), Self::Error> { 304 fn write(&mut self, offset: u32, bytes: &[u8]) -> Result<(), Self::Error> {
296 self.blocking_write(offset, bytes) 305 self.write_blocking(offset, bytes)
297 } 306 }
298 307
299 fn erase(&mut self, from: u32, to: u32) -> Result<(), Self::Error> { 308 fn erase(&mut self, from: u32, to: u32) -> Result<(), Self::Error> {
300 self.blocking_erase(from, to) 309 self.erase_blocking(from, to)
301 } 310 }
302 } 311 }
303 }; 312 };