Check the bank setup when required
This commit is contained in:
		
							parent
							
								
									7259f20fe2
								
							
						
					
					
						commit
						19351c374a
					
				| @ -20,6 +20,10 @@ pub struct Flash<'d, MODE = Async> { | ||||
| impl<'d> Flash<'d, Blocking> { | ||||
|     /// Create a new flash driver, usable in blocking mode.
 | ||||
|     pub fn new_blocking(p: Peri<'d, FLASH>) -> Self { | ||||
|         #[cfg(bank_setup_configurable)] | ||||
|         // Check if the configuration matches the embassy setup
 | ||||
|         super::check_bank_setup(); | ||||
| 
 | ||||
|         Self { | ||||
|             inner: p, | ||||
|             _mode: PhantomData, | ||||
|  | ||||
| @ -109,3 +109,13 @@ fn wait_busy() { | ||||
| fn wait_busy() { | ||||
|     while pac::FLASH.sr().read().bsy() {} | ||||
| } | ||||
| 
 | ||||
| #[cfg(bank_setup_configurable)] | ||||
| pub(crate) fn check_bank_setup() { | ||||
|     if cfg!(feature = "single-bank") && pac::FLASH.optr().read().dbank() { | ||||
|         panic!("Embassy is configured as single-bank, but the hardware is running in dual-bank mode. Change the hardware by changing the dbank value in the user option bytes or configure embassy to use dual-bank config"); | ||||
|     } | ||||
|     if cfg!(feature = "dual-bank") && !pac::FLASH.optr().read().dbank() { | ||||
|         panic!("Embassy is configured as dual-bank, but the hardware is running in single-bank mode. Change the hardware by changing the dbank value in the user option bytes or configure embassy to use single-bank config"); | ||||
|     } | ||||
| } | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user