Merge branch 'async-flash' of https://github.com/rmja/embassy into async-flash
This commit is contained in:
		
						commit
						983f01016b
					
				| @ -83,7 +83,16 @@ impl interrupt::Handler<crate::interrupt::FLASH> for InterruptHandler { | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| pub(super) fn blocking_read(base: u32, size: u32, offset: u32, bytes: &mut [u8]) -> Result<(), Error> { | ||||
| /// Interrupt handler
 | ||||
| pub struct InterruptHandler; | ||||
| 
 | ||||
| impl interrupt::Handler<crate::interrupt::FLASH> for InterruptHandler { | ||||
|     unsafe fn on_interrupt() { | ||||
|         family::on_interrupt(); | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| pub(super) fn read_blocking(base: u32, size: u32, offset: u32, bytes: &mut [u8]) -> Result<(), Error> { | ||||
|     if offset + bytes.len() as u32 > size { | ||||
|         return Err(Error::Size); | ||||
|     } | ||||
| @ -246,11 +255,11 @@ impl<MODE> embedded_storage::nor_flash::NorFlash for Flash<'_, MODE> { | ||||
|     const ERASE_SIZE: usize = MAX_ERASE_SIZE; | ||||
| 
 | ||||
|     fn write(&mut self, offset: u32, bytes: &[u8]) -> Result<(), Self::Error> { | ||||
|         self.blocking_write(offset, bytes) | ||||
|         self.write_blocking(offset, bytes) | ||||
|     } | ||||
| 
 | ||||
|     fn erase(&mut self, from: u32, to: u32) -> Result<(), Self::Error> { | ||||
|         self.blocking_erase(from, to) | ||||
|         self.erase_blocking(from, to) | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| @ -280,7 +289,7 @@ foreach_flash_region! { | ||||
|             const READ_SIZE: usize = READ_SIZE; | ||||
| 
 | ||||
|             fn read(&mut self, offset: u32, bytes: &mut [u8]) -> Result<(), Self::Error> { | ||||
|                 self.blocking_read(offset, bytes) | ||||
|                 self.read_blocking(offset, bytes) | ||||
|             } | ||||
| 
 | ||||
|             fn capacity(&self) -> usize { | ||||
| @ -293,11 +302,11 @@ foreach_flash_region! { | ||||
|             const ERASE_SIZE: usize = $erase_size; | ||||
| 
 | ||||
|             fn write(&mut self, offset: u32, bytes: &[u8]) -> Result<(), Self::Error> { | ||||
|                 self.blocking_write(offset, bytes) | ||||
|                 self.write_blocking(offset, bytes) | ||||
|             } | ||||
| 
 | ||||
|             fn erase(&mut self, from: u32, to: u32) -> Result<(), Self::Error> { | ||||
|                 self.blocking_erase(from, to) | ||||
|                 self.erase_blocking(from, to) | ||||
|             } | ||||
|         } | ||||
|     }; | ||||
|  | ||||
| @ -36,7 +36,7 @@ pub(crate) unsafe fn disable_blocking_write() { | ||||
|     pac::FLASH.cr().write(|w| w.set_pg(false)); | ||||
| } | ||||
| 
 | ||||
| pub(crate) unsafe fn blocking_write(start_address: u32, buf: &[u8; WRITE_SIZE]) -> Result<(), Error> { | ||||
| pub(crate) unsafe fn write_blocking(start_address: u32, buf: &[u8; WRITE_SIZE]) -> Result<(), Error> { | ||||
|     let mut address = start_address; | ||||
|     for chunk in buf.chunks(2) { | ||||
|         write_volatile(address as *mut u16, u16::from_le_bytes(chunk.try_into().unwrap())); | ||||
| @ -46,10 +46,10 @@ pub(crate) unsafe fn blocking_write(start_address: u32, buf: &[u8; WRITE_SIZE]) | ||||
|         fence(Ordering::SeqCst); | ||||
|     } | ||||
| 
 | ||||
|     blocking_wait_ready() | ||||
|     wait_ready_blocking() | ||||
| } | ||||
| 
 | ||||
| pub(crate) unsafe fn blocking_erase_sector(sector: &FlashSector) -> Result<(), Error> { | ||||
| pub(crate) unsafe fn erase_sector_blocking(sector: &FlashSector) -> Result<(), Error> { | ||||
|     pac::FLASH.cr().modify(|w| { | ||||
|         w.set_per(true); | ||||
|     }); | ||||
| @ -60,7 +60,7 @@ pub(crate) unsafe fn blocking_erase_sector(sector: &FlashSector) -> Result<(), E | ||||
|         w.set_strt(true); | ||||
|     }); | ||||
| 
 | ||||
|     let mut ret: Result<(), Error> = blocking_wait_ready(); | ||||
|     let mut ret: Result<(), Error> = wait_ready_blocking(); | ||||
| 
 | ||||
|     if !pac::FLASH.sr().read().eop() { | ||||
|         trace!("FLASH: EOP not set"); | ||||
| @ -92,7 +92,7 @@ pub(crate) unsafe fn clear_all_err() { | ||||
|     }); | ||||
| } | ||||
| 
 | ||||
| unsafe fn blocking_wait_ready() -> Result<(), Error> { | ||||
| unsafe fn wait_ready_blocking() -> Result<(), Error> { | ||||
|     loop { | ||||
|         let sr = pac::FLASH.sr().read(); | ||||
| 
 | ||||
|  | ||||
| @ -36,7 +36,7 @@ pub(crate) unsafe fn disable_blocking_write() { | ||||
|     pac::FLASH.cr().write(|w| w.set_pg(false)); | ||||
| } | ||||
| 
 | ||||
| pub(crate) unsafe fn blocking_write(start_address: u32, buf: &[u8; WRITE_SIZE]) -> Result<(), Error> { | ||||
| pub(crate) unsafe fn write_blocking(start_address: u32, buf: &[u8; WRITE_SIZE]) -> Result<(), Error> { | ||||
|     let mut address = start_address; | ||||
|     for chunk in buf.chunks(2) { | ||||
|         write_volatile(address as *mut u16, u16::from_le_bytes(chunk.try_into().unwrap())); | ||||
| @ -46,10 +46,10 @@ pub(crate) unsafe fn blocking_write(start_address: u32, buf: &[u8; WRITE_SIZE]) | ||||
|         fence(Ordering::SeqCst); | ||||
|     } | ||||
| 
 | ||||
|     blocking_wait_ready() | ||||
|     wait_ready_blocking() | ||||
| } | ||||
| 
 | ||||
| pub(crate) unsafe fn blocking_erase_sector(sector: &FlashSector) -> Result<(), Error> { | ||||
| pub(crate) unsafe fn erase_sector_blocking(sector: &FlashSector) -> Result<(), Error> { | ||||
|     pac::FLASH.cr().modify(|w| { | ||||
|         w.set_per(true); | ||||
|     }); | ||||
| @ -60,7 +60,7 @@ pub(crate) unsafe fn blocking_erase_sector(sector: &FlashSector) -> Result<(), E | ||||
|         w.set_strt(true); | ||||
|     }); | ||||
| 
 | ||||
|     let mut ret: Result<(), Error> = blocking_wait_ready(); | ||||
|     let mut ret: Result<(), Error> = wait_ready_blocking(); | ||||
| 
 | ||||
|     if !pac::FLASH.sr().read().eop() { | ||||
|         trace!("FLASH: EOP not set"); | ||||
| @ -92,7 +92,7 @@ pub(crate) unsafe fn clear_all_err() { | ||||
|     }); | ||||
| } | ||||
| 
 | ||||
| unsafe fn blocking_wait_ready() -> Result<(), Error> { | ||||
| unsafe fn wait_ready_blocking() -> Result<(), Error> { | ||||
|     loop { | ||||
|         let sr = pac::FLASH.sr().read(); | ||||
| 
 | ||||
|  | ||||
| @ -57,7 +57,7 @@ pub(crate) unsafe fn disable_blocking_write() { | ||||
|     pac::FLASH.cr().write(|w| w.set_pg(false)); | ||||
| } | ||||
| 
 | ||||
| pub(crate) unsafe fn blocking_write(start_address: u32, buf: &[u8; WRITE_SIZE]) -> Result<(), Error> { | ||||
| pub(crate) unsafe fn write_blocking(start_address: u32, buf: &[u8; WRITE_SIZE]) -> Result<(), Error> { | ||||
|     let mut address = start_address; | ||||
|     for val in buf.chunks(4) { | ||||
|         write_volatile(address as *mut u32, u32::from_le_bytes(val.try_into().unwrap())); | ||||
| @ -67,10 +67,10 @@ pub(crate) unsafe fn blocking_write(start_address: u32, buf: &[u8; WRITE_SIZE]) | ||||
|         fence(Ordering::SeqCst); | ||||
|     } | ||||
| 
 | ||||
|     blocking_wait_ready() | ||||
|     wait_ready_blocking() | ||||
| } | ||||
| 
 | ||||
| pub(crate) unsafe fn blocking_erase_sector(sector: &FlashSector) -> Result<(), Error> { | ||||
| pub(crate) unsafe fn erase_sector_blocking(sector: &FlashSector) -> Result<(), Error> { | ||||
|     #[cfg(any(flash_l0, flash_l1))] | ||||
|     { | ||||
|         pac::FLASH.pecr().modify(|w| { | ||||
| @ -100,7 +100,7 @@ pub(crate) unsafe fn blocking_erase_sector(sector: &FlashSector) -> Result<(), E | ||||
|         }); | ||||
|     } | ||||
| 
 | ||||
|     let ret: Result<(), Error> = blocking_wait_ready(); | ||||
|     let ret: Result<(), Error> = wait_ready_blocking(); | ||||
| 
 | ||||
|     #[cfg(any(flash_wl, flash_wb, flash_l4))] | ||||
|     pac::FLASH.cr().modify(|w| w.set_per(false)); | ||||
| @ -153,7 +153,7 @@ pub(crate) unsafe fn clear_all_err() { | ||||
|     }); | ||||
| } | ||||
| 
 | ||||
| unsafe fn blocking_wait_ready() -> Result<(), Error> { | ||||
| unsafe fn wait_ready_blocking() -> Result<(), Error> { | ||||
|     loop { | ||||
|         let sr = pac::FLASH.sr().read(); | ||||
| 
 | ||||
|  | ||||
| @ -24,10 +24,10 @@ pub(crate) unsafe fn enable_blocking_write() { | ||||
| pub(crate) unsafe fn disable_blocking_write() { | ||||
|     unimplemented!(); | ||||
| } | ||||
| pub(crate) unsafe fn blocking_write(_start_address: u32, _buf: &[u8; WRITE_SIZE]) -> Result<(), Error> { | ||||
| pub(crate) unsafe fn write_blocking(_start_address: u32, _buf: &[u8; WRITE_SIZE]) -> Result<(), Error> { | ||||
|     unimplemented!(); | ||||
| } | ||||
| pub(crate) unsafe fn blocking_erase_sector(_sector: &FlashSector) -> Result<(), Error> { | ||||
| pub(crate) unsafe fn erase_sector_blocking(_sector: &FlashSector) -> Result<(), Error> { | ||||
|     unimplemented!(); | ||||
| } | ||||
| pub(crate) unsafe fn clear_all_err() { | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user