From 10575f28a6942b29e6e76abde2dd6932d4dd3b56 Mon Sep 17 00:00:00 2001 From: Corwin Date: Sat, 17 Feb 2024 16:25:09 +0000 Subject: [PATCH] delay cell --- agb/src/save/flash.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/agb/src/save/flash.rs b/agb/src/save/flash.rs index 95e7d5e7..f0b0f65b 100644 --- a/agb/src/save/flash.rs +++ b/agb/src/save/flash.rs @@ -47,8 +47,8 @@ fn issue_flash_command(c2: u8) { } /// A simple thing to avoid excessive bank switches -static CURRENT_BANK: AtomicU8 = AtomicU8::new(!0); fn set_bank(bank: u8) -> Result<(), Error> { + static CURRENT_BANK: AtomicU8 = AtomicU8::new(!0); if bank == 0xFF { Err(Error::OutOfBounds) } else if bank != CURRENT_BANK.load(Ordering::SeqCst) { @@ -242,9 +242,13 @@ impl FlashChipType { } } -static CHIP_INFO: OnceCell<&'static ChipInfo> = OnceCell::new(); - fn cached_chip_info() -> Result<&'static ChipInfo, Error> { + static CHIP_INFO: OnceCell<&'static ChipInfo> = OnceCell::new(); + + for _ in 0..100 { + unsafe { core::arch::asm!("nop") }; + } + CHIP_INFO .get_or_try_init(|| -> Result<_, Error> { Ok(FlashChipType::detect()?.chip_info()) }) .cloned()