diff options
| author | Rasmus Melchior Jacobsen <[email protected]> | 2023-05-25 21:46:26 +0200 |
|---|---|---|
| committer | Rasmus Melchior Jacobsen <[email protected]> | 2023-05-25 21:46:26 +0200 |
| commit | 9eca19b49d462e57308e8b13f7ff03e10cfb0557 (patch) | |
| tree | 5c2f0e8f11d3044b718db1360922792594a99def | |
| parent | 860b519f9993bd8991849c680aae058558aadfbd (diff) | |
*_blocking -> blocking_*
| -rw-r--r-- | embassy-stm32/src/flash/asynch.rs | 4 | ||||
| -rw-r--r-- | embassy-stm32/src/flash/common.rs | 42 | ||||
| -rw-r--r-- | embassy-stm32/src/flash/f0.rs | 10 | ||||
| -rw-r--r-- | embassy-stm32/src/flash/f3.rs | 10 | ||||
| -rw-r--r-- | embassy-stm32/src/flash/f4.rs | 18 | ||||
| -rw-r--r-- | embassy-stm32/src/flash/f7.rs | 10 | ||||
| -rw-r--r-- | embassy-stm32/src/flash/h7.rs | 10 | ||||
| -rw-r--r-- | embassy-stm32/src/flash/l.rs | 10 | ||||
| -rw-r--r-- | embassy-stm32/src/flash/other.rs | 4 |
9 files changed, 59 insertions, 59 deletions
diff --git a/embassy-stm32/src/flash/asynch.rs b/embassy-stm32/src/flash/asynch.rs index 74c54ff33..de53f6c8f 100644 --- a/embassy-stm32/src/flash/asynch.rs +++ b/embassy-stm32/src/flash/asynch.rs | |||
| @@ -4,7 +4,7 @@ use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex; | |||
| 4 | use embassy_sync::mutex::Mutex; | 4 | use embassy_sync::mutex::Mutex; |
| 5 | 5 | ||
| 6 | use super::{ | 6 | use super::{ |
| 7 | ensure_sector_aligned, family, get_sector, read_blocking, Async, Error, Flash, FlashLayout, FLASH_BASE, FLASH_SIZE, | 7 | blocking_read, ensure_sector_aligned, family, get_sector, Async, Error, Flash, FlashLayout, FLASH_BASE, FLASH_SIZE, |
| 8 | MAX_ERASE_SIZE, READ_SIZE, WRITE_SIZE, | 8 | MAX_ERASE_SIZE, READ_SIZE, WRITE_SIZE, |
| 9 | }; | 9 | }; |
| 10 | 10 | ||
| @@ -112,7 +112,7 @@ foreach_flash_region! { | |||
| 112 | ($type_name:ident, $write_size:literal, $erase_size:literal) => { | 112 | ($type_name:ident, $write_size:literal, $erase_size:literal) => { |
| 113 | impl crate::_generated::flash_regions::$type_name<'_, Async> { | 113 | impl crate::_generated::flash_regions::$type_name<'_, Async> { |
| 114 | pub async fn read(&mut self, offset: u32, bytes: &mut [u8]) -> Result<(), Error> { | 114 | pub async fn read(&mut self, offset: u32, bytes: &mut [u8]) -> Result<(), Error> { |
| 115 | read_blocking(self.0.base, self.0.size, offset, bytes) | 115 | blocking_read(self.0.base, self.0.size, offset, bytes) |
| 116 | } | 116 | } |
| 117 | 117 | ||
| 118 | pub async fn write(&mut self, offset: u32, bytes: &[u8]) -> Result<(), Error> { | 118 | pub async fn write(&mut self, offset: u32, bytes: &[u8]) -> Result<(), Error> { |
diff --git a/embassy-stm32/src/flash/common.rs b/embassy-stm32/src/flash/common.rs index 8ae72ebcb..54c8d6812 100644 --- a/embassy-stm32/src/flash/common.rs +++ b/embassy-stm32/src/flash/common.rs | |||
| @@ -54,12 +54,12 @@ impl<'d, MODE> Flash<'d, MODE> { | |||
| 54 | } | 54 | } |
| 55 | 55 | ||
| 56 | pub fn read(&mut self, offset: u32, bytes: &mut [u8]) -> Result<(), Error> { | 56 | pub fn read(&mut self, offset: u32, bytes: &mut [u8]) -> Result<(), Error> { |
| 57 | read_blocking(FLASH_BASE as u32, FLASH_SIZE as u32, offset, bytes) | 57 | blocking_read(FLASH_BASE as u32, FLASH_SIZE as u32, offset, bytes) |
| 58 | } | 58 | } |
| 59 | 59 | ||
| 60 | pub fn write_blocking(&mut self, offset: u32, bytes: &[u8]) -> Result<(), Error> { | 60 | pub fn blocking_write(&mut self, offset: u32, bytes: &[u8]) -> Result<(), Error> { |
| 61 | unsafe { | 61 | unsafe { |
| 62 | write_blocking( | 62 | blocking_write( |
| 63 | FLASH_BASE as u32, | 63 | FLASH_BASE as u32, |
| 64 | FLASH_SIZE as u32, | 64 | FLASH_SIZE as u32, |
| 65 | offset, | 65 | offset, |
| @@ -69,8 +69,8 @@ impl<'d, MODE> Flash<'d, MODE> { | |||
| 69 | } | 69 | } |
| 70 | } | 70 | } |
| 71 | 71 | ||
| 72 | pub fn erase_blocking(&mut self, from: u32, to: u32) -> Result<(), Error> { | 72 | pub fn blocking_erase(&mut self, from: u32, to: u32) -> Result<(), Error> { |
| 73 | unsafe { erase_blocking(FLASH_BASE as u32, from, to, erase_sector_unlocked) } | 73 | unsafe { blocking_erase(FLASH_BASE as u32, from, to, erase_sector_unlocked) } |
| 74 | } | 74 | } |
| 75 | } | 75 | } |
| 76 | 76 | ||
| @@ -83,7 +83,7 @@ impl interrupt::Handler<crate::interrupt::FLASH> for InterruptHandler { | |||
| 83 | } | 83 | } |
| 84 | } | 84 | } |
| 85 | 85 | ||
| 86 | pub(super) fn read_blocking(base: u32, size: u32, offset: u32, bytes: &mut [u8]) -> Result<(), Error> { | 86 | pub(super) fn blocking_read(base: u32, size: u32, offset: u32, bytes: &mut [u8]) -> Result<(), Error> { |
| 87 | if offset + bytes.len() as u32 > size { | 87 | if offset + bytes.len() as u32 > size { |
| 88 | return Err(Error::Size); | 88 | return Err(Error::Size); |
| 89 | } | 89 | } |
| @@ -97,7 +97,7 @@ pub(super) fn read_blocking(base: u32, size: u32, offset: u32, bytes: &mut [u8]) | |||
| 97 | Ok(()) | 97 | Ok(()) |
| 98 | } | 98 | } |
| 99 | 99 | ||
| 100 | pub(super) unsafe fn write_blocking( | 100 | pub(super) unsafe fn blocking_write( |
| 101 | base: u32, | 101 | base: u32, |
| 102 | size: u32, | 102 | size: u32, |
| 103 | offset: u32, | 103 | offset: u32, |
| @@ -135,14 +135,14 @@ pub(super) unsafe fn write_chunk_unlocked(address: u32, chunk: &[u8]) -> Result< | |||
| 135 | family::lock(); | 135 | family::lock(); |
| 136 | }); | 136 | }); |
| 137 | 137 | ||
| 138 | family::write_blocking(address, chunk.try_into().unwrap()) | 138 | family::blocking_write(address, chunk.try_into().unwrap()) |
| 139 | } | 139 | } |
| 140 | 140 | ||
| 141 | pub(super) unsafe fn write_chunk_with_critical_section(address: u32, chunk: &[u8]) -> Result<(), Error> { | 141 | pub(super) unsafe fn write_chunk_with_critical_section(address: u32, chunk: &[u8]) -> Result<(), Error> { |
| 142 | critical_section::with(|_| write_chunk_unlocked(address, chunk)) | 142 | critical_section::with(|_| write_chunk_unlocked(address, chunk)) |
| 143 | } | 143 | } |
| 144 | 144 | ||
| 145 | pub(super) unsafe fn erase_blocking( | 145 | pub(super) unsafe fn blocking_erase( |
| 146 | base: u32, | 146 | base: u32, |
| 147 | from: u32, | 147 | from: u32, |
| 148 | to: u32, | 148 | to: u32, |
| @@ -174,7 +174,7 @@ pub(super) unsafe fn erase_sector_unlocked(sector: &FlashSector) -> Result<(), E | |||
| 174 | 174 | ||
| 175 | let _on_drop = OnDrop::new(|| family::lock()); | 175 | let _on_drop = OnDrop::new(|| family::lock()); |
| 176 | 176 | ||
| 177 | family::erase_sector_blocking(§or) | 177 | family::blocking_erase_sector(§or) |
| 178 | } | 178 | } |
| 179 | 179 | ||
| 180 | pub(super) unsafe fn erase_sector_with_critical_section(sector: &FlashSector) -> Result<(), Error> { | 180 | pub(super) unsafe fn erase_sector_with_critical_section(sector: &FlashSector) -> Result<(), Error> { |
| @@ -246,29 +246,29 @@ impl<MODE> embedded_storage::nor_flash::NorFlash for Flash<'_, MODE> { | |||
| 246 | const ERASE_SIZE: usize = MAX_ERASE_SIZE; | 246 | const ERASE_SIZE: usize = MAX_ERASE_SIZE; |
| 247 | 247 | ||
| 248 | fn write(&mut self, offset: u32, bytes: &[u8]) -> Result<(), Self::Error> { | 248 | fn write(&mut self, offset: u32, bytes: &[u8]) -> Result<(), Self::Error> { |
| 249 | self.write_blocking(offset, bytes) | 249 | self.blocking_write(offset, bytes) |
| 250 | } | 250 | } |
| 251 | 251 | ||
| 252 | fn erase(&mut self, from: u32, to: u32) -> Result<(), Self::Error> { | 252 | fn erase(&mut self, from: u32, to: u32) -> Result<(), Self::Error> { |
| 253 | self.erase_blocking(from, to) | 253 | self.blocking_erase(from, to) |
| 254 | } | 254 | } |
| 255 | } | 255 | } |
| 256 | 256 | ||
| 257 | foreach_flash_region! { | 257 | foreach_flash_region! { |
| 258 | ($type_name:ident, $write_size:literal, $erase_size:literal) => { | 258 | ($type_name:ident, $write_size:literal, $erase_size:literal) => { |
| 259 | impl<MODE> crate::_generated::flash_regions::$type_name<'_, MODE> { | 259 | impl<MODE> crate::_generated::flash_regions::$type_name<'_, MODE> { |
| 260 | pub fn read_blocking(&mut self, offset: u32, bytes: &mut [u8]) -> Result<(), Error> { | 260 | pub fn blocking_read(&mut self, offset: u32, bytes: &mut [u8]) -> Result<(), Error> { |
| 261 | read_blocking(self.0.base, self.0.size, offset, bytes) | 261 | blocking_read(self.0.base, self.0.size, offset, bytes) |
| 262 | } | 262 | } |
| 263 | } | 263 | } |
| 264 | 264 | ||
| 265 | impl crate::_generated::flash_regions::$type_name<'_, Blocking> { | 265 | impl crate::_generated::flash_regions::$type_name<'_, Blocking> { |
| 266 | pub fn write_blocking(&mut self, offset: u32, bytes: &[u8]) -> Result<(), Error> { | 266 | pub fn blocking_write(&mut self, offset: u32, bytes: &[u8]) -> Result<(), Error> { |
| 267 | unsafe { write_blocking(self.0.base, self.0.size, offset, bytes, write_chunk_with_critical_section) } | 267 | unsafe { blocking_write(self.0.base, self.0.size, offset, bytes, write_chunk_with_critical_section) } |
| 268 | } | 268 | } |
| 269 | 269 | ||
| 270 | pub fn erase_blocking(&mut self, from: u32, to: u32) -> Result<(), Error> { | 270 | pub fn blocking_erase(&mut self, from: u32, to: u32) -> Result<(), Error> { |
| 271 | unsafe { erase_blocking(self.0.base, from, to, erase_sector_with_critical_section) } | 271 | unsafe { blocking_erase(self.0.base, from, to, erase_sector_with_critical_section) } |
| 272 | } | 272 | } |
| 273 | } | 273 | } |
| 274 | 274 | ||
| @@ -280,7 +280,7 @@ foreach_flash_region! { | |||
| 280 | const READ_SIZE: usize = READ_SIZE; | 280 | const READ_SIZE: usize = READ_SIZE; |
| 281 | 281 | ||
| 282 | fn read(&mut self, offset: u32, bytes: &mut [u8]) -> Result<(), Self::Error> { | 282 | fn read(&mut self, offset: u32, bytes: &mut [u8]) -> Result<(), Self::Error> { |
| 283 | self.read_blocking(offset, bytes) | 283 | self.blocking_read(offset, bytes) |
| 284 | } | 284 | } |
| 285 | 285 | ||
| 286 | fn capacity(&self) -> usize { | 286 | fn capacity(&self) -> usize { |
| @@ -293,11 +293,11 @@ foreach_flash_region! { | |||
| 293 | const ERASE_SIZE: usize = $erase_size; | 293 | const ERASE_SIZE: usize = $erase_size; |
| 294 | 294 | ||
| 295 | fn write(&mut self, offset: u32, bytes: &[u8]) -> Result<(), Self::Error> { | 295 | fn write(&mut self, offset: u32, bytes: &[u8]) -> Result<(), Self::Error> { |
| 296 | self.write_blocking(offset, bytes) | 296 | self.blocking_write(offset, bytes) |
| 297 | } | 297 | } |
| 298 | 298 | ||
| 299 | fn erase(&mut self, from: u32, to: u32) -> Result<(), Self::Error> { | 299 | fn erase(&mut self, from: u32, to: u32) -> Result<(), Self::Error> { |
| 300 | self.erase_blocking(from, to) | 300 | self.blocking_erase(from, to) |
| 301 | } | 301 | } |
| 302 | } | 302 | } |
| 303 | }; | 303 | }; |
diff --git a/embassy-stm32/src/flash/f0.rs b/embassy-stm32/src/flash/f0.rs index cd17486e6..9adf3fab2 100644 --- a/embassy-stm32/src/flash/f0.rs +++ b/embassy-stm32/src/flash/f0.rs | |||
| @@ -36,7 +36,7 @@ pub(crate) unsafe fn disable_blocking_write() { | |||
| 36 | pac::FLASH.cr().write(|w| w.set_pg(false)); | 36 | pac::FLASH.cr().write(|w| w.set_pg(false)); |
| 37 | } | 37 | } |
| 38 | 38 | ||
| 39 | pub(crate) unsafe fn write_blocking(start_address: u32, buf: &[u8; WRITE_SIZE]) -> Result<(), Error> { | 39 | pub(crate) unsafe fn blocking_write(start_address: u32, buf: &[u8; WRITE_SIZE]) -> Result<(), Error> { |
| 40 | let mut address = start_address; | 40 | let mut address = start_address; |
| 41 | for chunk in buf.chunks(2) { | 41 | for chunk in buf.chunks(2) { |
| 42 | write_volatile(address as *mut u16, u16::from_le_bytes(chunk.try_into().unwrap())); | 42 | write_volatile(address as *mut u16, u16::from_le_bytes(chunk.try_into().unwrap())); |
| @@ -46,10 +46,10 @@ pub(crate) unsafe fn write_blocking(start_address: u32, buf: &[u8; WRITE_SIZE]) | |||
| 46 | fence(Ordering::SeqCst); | 46 | fence(Ordering::SeqCst); |
| 47 | } | 47 | } |
| 48 | 48 | ||
| 49 | wait_ready_blocking() | 49 | blocking_wait_ready() |
| 50 | } | 50 | } |
| 51 | 51 | ||
| 52 | pub(crate) unsafe fn erase_sector_blocking(sector: &FlashSector) -> Result<(), Error> { | 52 | pub(crate) unsafe fn blocking_erase_sector(sector: &FlashSector) -> Result<(), Error> { |
| 53 | pac::FLASH.cr().modify(|w| { | 53 | pac::FLASH.cr().modify(|w| { |
| 54 | w.set_per(true); | 54 | w.set_per(true); |
| 55 | }); | 55 | }); |
| @@ -60,7 +60,7 @@ pub(crate) unsafe fn erase_sector_blocking(sector: &FlashSector) -> Result<(), E | |||
| 60 | w.set_strt(true); | 60 | w.set_strt(true); |
| 61 | }); | 61 | }); |
| 62 | 62 | ||
| 63 | let mut ret: Result<(), Error> = wait_ready_blocking(); | 63 | let mut ret: Result<(), Error> = blocking_wait_ready(); |
| 64 | 64 | ||
| 65 | if !pac::FLASH.sr().read().eop() { | 65 | if !pac::FLASH.sr().read().eop() { |
| 66 | trace!("FLASH: EOP not set"); | 66 | trace!("FLASH: EOP not set"); |
| @@ -92,7 +92,7 @@ pub(crate) unsafe fn clear_all_err() { | |||
| 92 | }); | 92 | }); |
| 93 | } | 93 | } |
| 94 | 94 | ||
| 95 | unsafe fn wait_ready_blocking() -> Result<(), Error> { | 95 | unsafe fn blocking_wait_ready() -> Result<(), Error> { |
| 96 | loop { | 96 | loop { |
| 97 | let sr = pac::FLASH.sr().read(); | 97 | let sr = pac::FLASH.sr().read(); |
| 98 | 98 | ||
diff --git a/embassy-stm32/src/flash/f3.rs b/embassy-stm32/src/flash/f3.rs index 4ce391288..b052b4d41 100644 --- a/embassy-stm32/src/flash/f3.rs +++ b/embassy-stm32/src/flash/f3.rs | |||
| @@ -36,7 +36,7 @@ pub(crate) unsafe fn disable_blocking_write() { | |||
| 36 | pac::FLASH.cr().write(|w| w.set_pg(false)); | 36 | pac::FLASH.cr().write(|w| w.set_pg(false)); |
| 37 | } | 37 | } |
| 38 | 38 | ||
| 39 | pub(crate) unsafe fn write_blocking(start_address: u32, buf: &[u8; WRITE_SIZE]) -> Result<(), Error> { | 39 | pub(crate) unsafe fn blocking_write(start_address: u32, buf: &[u8; WRITE_SIZE]) -> Result<(), Error> { |
| 40 | let mut address = start_address; | 40 | let mut address = start_address; |
| 41 | for chunk in buf.chunks(2) { | 41 | for chunk in buf.chunks(2) { |
| 42 | write_volatile(address as *mut u16, u16::from_le_bytes(chunk.try_into().unwrap())); | 42 | write_volatile(address as *mut u16, u16::from_le_bytes(chunk.try_into().unwrap())); |
| @@ -46,10 +46,10 @@ pub(crate) unsafe fn write_blocking(start_address: u32, buf: &[u8; WRITE_SIZE]) | |||
| 46 | fence(Ordering::SeqCst); | 46 | fence(Ordering::SeqCst); |
| 47 | } | 47 | } |
| 48 | 48 | ||
| 49 | wait_ready_blocking() | 49 | blocking_wait_ready() |
| 50 | } | 50 | } |
| 51 | 51 | ||
| 52 | pub(crate) unsafe fn erase_sector_blocking(sector: &FlashSector) -> Result<(), Error> { | 52 | pub(crate) unsafe fn blocking_erase_sector(sector: &FlashSector) -> Result<(), Error> { |
| 53 | pac::FLASH.cr().modify(|w| { | 53 | pac::FLASH.cr().modify(|w| { |
| 54 | w.set_per(true); | 54 | w.set_per(true); |
| 55 | }); | 55 | }); |
| @@ -60,7 +60,7 @@ pub(crate) unsafe fn erase_sector_blocking(sector: &FlashSector) -> Result<(), E | |||
| 60 | w.set_strt(true); | 60 | w.set_strt(true); |
| 61 | }); | 61 | }); |
| 62 | 62 | ||
| 63 | let mut ret: Result<(), Error> = wait_ready_blocking(); | 63 | let mut ret: Result<(), Error> = blocking_wait_ready(); |
| 64 | 64 | ||
| 65 | if !pac::FLASH.sr().read().eop() { | 65 | if !pac::FLASH.sr().read().eop() { |
| 66 | trace!("FLASH: EOP not set"); | 66 | trace!("FLASH: EOP not set"); |
| @@ -92,7 +92,7 @@ pub(crate) unsafe fn clear_all_err() { | |||
| 92 | }); | 92 | }); |
| 93 | } | 93 | } |
| 94 | 94 | ||
| 95 | unsafe fn wait_ready_blocking() -> Result<(), Error> { | 95 | unsafe fn blocking_wait_ready() -> Result<(), Error> { |
| 96 | loop { | 96 | loop { |
| 97 | let sr = pac::FLASH.sr().read(); | 97 | let sr = pac::FLASH.sr().read(); |
| 98 | 98 | ||
diff --git a/embassy-stm32/src/flash/f4.rs b/embassy-stm32/src/flash/f4.rs index 875bb912b..5e0e96204 100644 --- a/embassy-stm32/src/flash/f4.rs +++ b/embassy-stm32/src/flash/f4.rs | |||
| @@ -108,15 +108,15 @@ mod alt_regions { | |||
| 108 | macro_rules! foreach_altflash_region { | 108 | macro_rules! foreach_altflash_region { |
| 109 | ($type_name:ident, $region:ident) => { | 109 | ($type_name:ident, $region:ident) => { |
| 110 | impl<MODE> $type_name<'_, MODE> { | 110 | impl<MODE> $type_name<'_, MODE> { |
| 111 | pub fn read_blocking(&mut self, offset: u32, bytes: &mut [u8]) -> Result<(), Error> { | 111 | pub fn blocking_read(&mut self, offset: u32, bytes: &mut [u8]) -> Result<(), Error> { |
| 112 | crate::flash::common::read_blocking(self.0.base, self.0.size, offset, bytes) | 112 | crate::flash::common::blocking_read(self.0.base, self.0.size, offset, bytes) |
| 113 | } | 113 | } |
| 114 | } | 114 | } |
| 115 | 115 | ||
| 116 | #[cfg(feature = "nightly")] | 116 | #[cfg(feature = "nightly")] |
| 117 | impl $type_name<'_, Async> { | 117 | impl $type_name<'_, Async> { |
| 118 | pub async fn read(&mut self, offset: u32, bytes: &mut [u8]) -> Result<(), Error> { | 118 | pub async fn read(&mut self, offset: u32, bytes: &mut [u8]) -> Result<(), Error> { |
| 119 | self.read_blocking(offset, bytes) | 119 | self.blocking_read(offset, bytes) |
| 120 | } | 120 | } |
| 121 | 121 | ||
| 122 | pub async fn write(&mut self, offset: u32, bytes: &[u8]) -> Result<(), Error> { | 122 | pub async fn write(&mut self, offset: u32, bytes: &[u8]) -> Result<(), Error> { |
| @@ -138,7 +138,7 @@ mod alt_regions { | |||
| 138 | const READ_SIZE: usize = crate::flash::READ_SIZE; | 138 | const READ_SIZE: usize = crate::flash::READ_SIZE; |
| 139 | 139 | ||
| 140 | fn read(&mut self, offset: u32, bytes: &mut [u8]) -> Result<(), Self::Error> { | 140 | fn read(&mut self, offset: u32, bytes: &mut [u8]) -> Result<(), Self::Error> { |
| 141 | self.read_blocking(offset, bytes) | 141 | self.blocking_read(offset, bytes) |
| 142 | } | 142 | } |
| 143 | 143 | ||
| 144 | fn capacity(&self) -> usize { | 144 | fn capacity(&self) -> usize { |
| @@ -299,9 +299,9 @@ pub(crate) async unsafe fn write(start_address: u32, buf: &[u8; WRITE_SIZE]) -> | |||
| 299 | wait_ready().await | 299 | wait_ready().await |
| 300 | } | 300 | } |
| 301 | 301 | ||
| 302 | pub(crate) unsafe fn write_blocking(start_address: u32, buf: &[u8; WRITE_SIZE]) -> Result<(), Error> { | 302 | pub(crate) unsafe fn blocking_write(start_address: u32, buf: &[u8; WRITE_SIZE]) -> Result<(), Error> { |
| 303 | write_start(start_address, buf); | 303 | write_start(start_address, buf); |
| 304 | wait_ready_blocking() | 304 | blocking_wait_ready() |
| 305 | } | 305 | } |
| 306 | 306 | ||
| 307 | unsafe fn write_start(start_address: u32, buf: &[u8; WRITE_SIZE]) { | 307 | unsafe fn write_start(start_address: u32, buf: &[u8; WRITE_SIZE]) { |
| @@ -340,7 +340,7 @@ pub(crate) async unsafe fn erase_sector(sector: &FlashSector) -> Result<(), Erro | |||
| 340 | ret | 340 | ret |
| 341 | } | 341 | } |
| 342 | 342 | ||
| 343 | pub(crate) unsafe fn erase_sector_blocking(sector: &FlashSector) -> Result<(), Error> { | 343 | pub(crate) unsafe fn blocking_erase_sector(sector: &FlashSector) -> Result<(), Error> { |
| 344 | save_data_cache_state(); | 344 | save_data_cache_state(); |
| 345 | 345 | ||
| 346 | pac::FLASH.cr().modify(|w| { | 346 | pac::FLASH.cr().modify(|w| { |
| @@ -352,7 +352,7 @@ pub(crate) unsafe fn erase_sector_blocking(sector: &FlashSector) -> Result<(), E | |||
| 352 | w.set_strt(true); | 352 | w.set_strt(true); |
| 353 | }); | 353 | }); |
| 354 | 354 | ||
| 355 | let ret: Result<(), Error> = wait_ready_blocking(); | 355 | let ret: Result<(), Error> = blocking_wait_ready(); |
| 356 | clear_all_err(); | 356 | clear_all_err(); |
| 357 | restore_data_cache_state(); | 357 | restore_data_cache_state(); |
| 358 | ret | 358 | ret |
| @@ -386,7 +386,7 @@ pub(crate) async unsafe fn wait_ready() -> Result<(), Error> { | |||
| 386 | .await | 386 | .await |
| 387 | } | 387 | } |
| 388 | 388 | ||
| 389 | unsafe fn wait_ready_blocking() -> Result<(), Error> { | 389 | unsafe fn blocking_wait_ready() -> Result<(), Error> { |
| 390 | loop { | 390 | loop { |
| 391 | let sr = pac::FLASH.sr().read(); | 391 | let sr = pac::FLASH.sr().read(); |
| 392 | 392 | ||
diff --git a/embassy-stm32/src/flash/f7.rs b/embassy-stm32/src/flash/f7.rs index ab518bf89..f0c6bf81d 100644 --- a/embassy-stm32/src/flash/f7.rs +++ b/embassy-stm32/src/flash/f7.rs | |||
| @@ -38,7 +38,7 @@ pub(crate) unsafe fn disable_blocking_write() { | |||
| 38 | pac::FLASH.cr().write(|w| w.set_pg(false)); | 38 | pac::FLASH.cr().write(|w| w.set_pg(false)); |
| 39 | } | 39 | } |
| 40 | 40 | ||
| 41 | pub(crate) unsafe fn write_blocking(start_address: u32, buf: &[u8; WRITE_SIZE]) -> Result<(), Error> { | 41 | pub(crate) unsafe fn blocking_write(start_address: u32, buf: &[u8; WRITE_SIZE]) -> Result<(), Error> { |
| 42 | let mut address = start_address; | 42 | let mut address = start_address; |
| 43 | for val in buf.chunks(4) { | 43 | for val in buf.chunks(4) { |
| 44 | write_volatile(address as *mut u32, u32::from_le_bytes(val.try_into().unwrap())); | 44 | write_volatile(address as *mut u32, u32::from_le_bytes(val.try_into().unwrap())); |
| @@ -48,10 +48,10 @@ pub(crate) unsafe fn write_blocking(start_address: u32, buf: &[u8; WRITE_SIZE]) | |||
| 48 | fence(Ordering::SeqCst); | 48 | fence(Ordering::SeqCst); |
| 49 | } | 49 | } |
| 50 | 50 | ||
| 51 | wait_ready_blocking() | 51 | blocking_wait_ready() |
| 52 | } | 52 | } |
| 53 | 53 | ||
| 54 | pub(crate) unsafe fn erase_sector_blocking(sector: &FlashSector) -> Result<(), Error> { | 54 | pub(crate) unsafe fn blocking_erase_sector(sector: &FlashSector) -> Result<(), Error> { |
| 55 | pac::FLASH.cr().modify(|w| { | 55 | pac::FLASH.cr().modify(|w| { |
| 56 | w.set_ser(true); | 56 | w.set_ser(true); |
| 57 | w.set_snb(sector.index_in_bank) | 57 | w.set_snb(sector.index_in_bank) |
| @@ -61,7 +61,7 @@ pub(crate) unsafe fn erase_sector_blocking(sector: &FlashSector) -> Result<(), E | |||
| 61 | w.set_strt(true); | 61 | w.set_strt(true); |
| 62 | }); | 62 | }); |
| 63 | 63 | ||
| 64 | let ret: Result<(), Error> = wait_ready_blocking(); | 64 | let ret: Result<(), Error> = blocking_wait_ready(); |
| 65 | pac::FLASH.cr().modify(|w| w.set_ser(false)); | 65 | pac::FLASH.cr().modify(|w| w.set_ser(false)); |
| 66 | clear_all_err(); | 66 | clear_all_err(); |
| 67 | ret | 67 | ret |
| @@ -87,7 +87,7 @@ pub(crate) unsafe fn clear_all_err() { | |||
| 87 | }); | 87 | }); |
| 88 | } | 88 | } |
| 89 | 89 | ||
| 90 | unsafe fn wait_ready_blocking() -> Result<(), Error> { | 90 | unsafe fn blocking_wait_ready() -> Result<(), Error> { |
| 91 | loop { | 91 | loop { |
| 92 | let sr = pac::FLASH.sr().read(); | 92 | let sr = pac::FLASH.sr().read(); |
| 93 | 93 | ||
diff --git a/embassy-stm32/src/flash/h7.rs b/embassy-stm32/src/flash/h7.rs index d6818d594..ee824ed2b 100644 --- a/embassy-stm32/src/flash/h7.rs +++ b/embassy-stm32/src/flash/h7.rs | |||
| @@ -43,7 +43,7 @@ pub(crate) unsafe fn enable_blocking_write() { | |||
| 43 | 43 | ||
| 44 | pub(crate) unsafe fn disable_blocking_write() {} | 44 | pub(crate) unsafe fn disable_blocking_write() {} |
| 45 | 45 | ||
| 46 | pub(crate) unsafe fn write_blocking(start_address: u32, buf: &[u8; WRITE_SIZE]) -> Result<(), Error> { | 46 | pub(crate) unsafe fn blocking_write(start_address: u32, buf: &[u8; WRITE_SIZE]) -> Result<(), Error> { |
| 47 | // We cannot have the write setup sequence in begin_write as it depends on the address | 47 | // We cannot have the write setup sequence in begin_write as it depends on the address |
| 48 | let bank = if start_address < BANK1_REGION.end() { | 48 | let bank = if start_address < BANK1_REGION.end() { |
| 49 | pac::FLASH.bank(0) | 49 | pac::FLASH.bank(0) |
| @@ -64,7 +64,7 @@ pub(crate) unsafe fn write_blocking(start_address: u32, buf: &[u8; WRITE_SIZE]) | |||
| 64 | write_volatile(address as *mut u32, u32::from_le_bytes(val.try_into().unwrap())); | 64 | write_volatile(address as *mut u32, u32::from_le_bytes(val.try_into().unwrap())); |
| 65 | address += val.len() as u32; | 65 | address += val.len() as u32; |
| 66 | 66 | ||
| 67 | res = Some(wait_ready_blocking(bank)); | 67 | res = Some(blocking_wait_ready(bank)); |
| 68 | bank.sr().modify(|w| { | 68 | bank.sr().modify(|w| { |
| 69 | if w.eop() { | 69 | if w.eop() { |
| 70 | w.set_eop(true); | 70 | w.set_eop(true); |
| @@ -84,7 +84,7 @@ pub(crate) unsafe fn write_blocking(start_address: u32, buf: &[u8; WRITE_SIZE]) | |||
| 84 | res.unwrap() | 84 | res.unwrap() |
| 85 | } | 85 | } |
| 86 | 86 | ||
| 87 | pub(crate) unsafe fn erase_sector_blocking(sector: &FlashSector) -> Result<(), Error> { | 87 | pub(crate) unsafe fn blocking_erase_sector(sector: &FlashSector) -> Result<(), Error> { |
| 88 | let bank = pac::FLASH.bank(sector.bank as usize); | 88 | let bank = pac::FLASH.bank(sector.bank as usize); |
| 89 | bank.cr().modify(|w| { | 89 | bank.cr().modify(|w| { |
| 90 | w.set_ser(true); | 90 | w.set_ser(true); |
| @@ -95,7 +95,7 @@ pub(crate) unsafe fn erase_sector_blocking(sector: &FlashSector) -> Result<(), E | |||
| 95 | w.set_start(true); | 95 | w.set_start(true); |
| 96 | }); | 96 | }); |
| 97 | 97 | ||
| 98 | let ret: Result<(), Error> = wait_ready_blocking(bank); | 98 | let ret: Result<(), Error> = blocking_wait_ready(bank); |
| 99 | bank.cr().modify(|w| w.set_ser(false)); | 99 | bank.cr().modify(|w| w.set_ser(false)); |
| 100 | bank_clear_all_err(bank); | 100 | bank_clear_all_err(bank); |
| 101 | ret | 101 | ret |
| @@ -142,7 +142,7 @@ unsafe fn bank_clear_all_err(bank: pac::flash::Bank) { | |||
| 142 | }); | 142 | }); |
| 143 | } | 143 | } |
| 144 | 144 | ||
| 145 | unsafe fn wait_ready_blocking(bank: pac::flash::Bank) -> Result<(), Error> { | 145 | unsafe fn blocking_wait_ready(bank: pac::flash::Bank) -> Result<(), Error> { |
| 146 | loop { | 146 | loop { |
| 147 | let sr = bank.sr().read(); | 147 | let sr = bank.sr().read(); |
| 148 | 148 | ||
diff --git a/embassy-stm32/src/flash/l.rs b/embassy-stm32/src/flash/l.rs index c2394e0c9..76cad6d15 100644 --- a/embassy-stm32/src/flash/l.rs +++ b/embassy-stm32/src/flash/l.rs | |||
| @@ -57,7 +57,7 @@ pub(crate) unsafe fn disable_blocking_write() { | |||
| 57 | pac::FLASH.cr().write(|w| w.set_pg(false)); | 57 | pac::FLASH.cr().write(|w| w.set_pg(false)); |
| 58 | } | 58 | } |
| 59 | 59 | ||
| 60 | pub(crate) unsafe fn write_blocking(start_address: u32, buf: &[u8; WRITE_SIZE]) -> Result<(), Error> { | 60 | pub(crate) unsafe fn blocking_write(start_address: u32, buf: &[u8; WRITE_SIZE]) -> Result<(), Error> { |
| 61 | let mut address = start_address; | 61 | let mut address = start_address; |
| 62 | for val in buf.chunks(4) { | 62 | for val in buf.chunks(4) { |
| 63 | write_volatile(address as *mut u32, u32::from_le_bytes(val.try_into().unwrap())); | 63 | write_volatile(address as *mut u32, u32::from_le_bytes(val.try_into().unwrap())); |
| @@ -67,10 +67,10 @@ pub(crate) unsafe fn write_blocking(start_address: u32, buf: &[u8; WRITE_SIZE]) | |||
| 67 | fence(Ordering::SeqCst); | 67 | fence(Ordering::SeqCst); |
| 68 | } | 68 | } |
| 69 | 69 | ||
| 70 | wait_ready_blocking() | 70 | blocking_wait_ready() |
| 71 | } | 71 | } |
| 72 | 72 | ||
| 73 | pub(crate) unsafe fn erase_sector_blocking(sector: &FlashSector) -> Result<(), Error> { | 73 | pub(crate) unsafe fn blocking_erase_sector(sector: &FlashSector) -> Result<(), Error> { |
| 74 | #[cfg(any(flash_l0, flash_l1))] | 74 | #[cfg(any(flash_l0, flash_l1))] |
| 75 | { | 75 | { |
| 76 | pac::FLASH.pecr().modify(|w| { | 76 | pac::FLASH.pecr().modify(|w| { |
| @@ -100,7 +100,7 @@ pub(crate) unsafe fn erase_sector_blocking(sector: &FlashSector) -> Result<(), E | |||
| 100 | }); | 100 | }); |
| 101 | } | 101 | } |
| 102 | 102 | ||
| 103 | let ret: Result<(), Error> = wait_ready_blocking(); | 103 | let ret: Result<(), Error> = blocking_wait_ready(); |
| 104 | 104 | ||
| 105 | #[cfg(any(flash_wl, flash_wb, flash_l4))] | 105 | #[cfg(any(flash_wl, flash_wb, flash_l4))] |
| 106 | pac::FLASH.cr().modify(|w| w.set_per(false)); | 106 | pac::FLASH.cr().modify(|w| w.set_per(false)); |
| @@ -153,7 +153,7 @@ pub(crate) unsafe fn clear_all_err() { | |||
| 153 | }); | 153 | }); |
| 154 | } | 154 | } |
| 155 | 155 | ||
| 156 | unsafe fn wait_ready_blocking() -> Result<(), Error> { | 156 | unsafe fn blocking_wait_ready() -> Result<(), Error> { |
| 157 | loop { | 157 | loop { |
| 158 | let sr = pac::FLASH.sr().read(); | 158 | let sr = pac::FLASH.sr().read(); |
| 159 | 159 | ||
diff --git a/embassy-stm32/src/flash/other.rs b/embassy-stm32/src/flash/other.rs index e569951f9..c007f1178 100644 --- a/embassy-stm32/src/flash/other.rs +++ b/embassy-stm32/src/flash/other.rs | |||
| @@ -24,10 +24,10 @@ pub(crate) unsafe fn enable_blocking_write() { | |||
| 24 | pub(crate) unsafe fn disable_blocking_write() { | 24 | pub(crate) unsafe fn disable_blocking_write() { |
| 25 | unimplemented!(); | 25 | unimplemented!(); |
| 26 | } | 26 | } |
| 27 | pub(crate) unsafe fn write_blocking(_start_address: u32, _buf: &[u8; WRITE_SIZE]) -> Result<(), Error> { | 27 | pub(crate) unsafe fn blocking_write(_start_address: u32, _buf: &[u8; WRITE_SIZE]) -> Result<(), Error> { |
| 28 | unimplemented!(); | 28 | unimplemented!(); |
| 29 | } | 29 | } |
| 30 | pub(crate) unsafe fn erase_sector_blocking(_sector: &FlashSector) -> Result<(), Error> { | 30 | pub(crate) unsafe fn blocking_erase_sector(_sector: &FlashSector) -> Result<(), Error> { |
| 31 | unimplemented!(); | 31 | unimplemented!(); |
| 32 | } | 32 | } |
| 33 | pub(crate) unsafe fn clear_all_err() { | 33 | pub(crate) unsafe fn clear_all_err() { |
