delay cell

This commit is contained in:
Corwin 2024-02-17 16:25:09 +00:00
parent 9fbd420089
commit 10575f28a6
No known key found for this signature in database

View file

@ -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()