mirror of
https://github.com/italicsjenga/agb.git
synced 2024-12-23 08:11:33 +11:00
delay cell
This commit is contained in:
parent
9fbd420089
commit
10575f28a6
|
@ -47,8 +47,8 @@ fn issue_flash_command(c2: u8) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A simple thing to avoid excessive bank switches
|
/// A simple thing to avoid excessive bank switches
|
||||||
static CURRENT_BANK: AtomicU8 = AtomicU8::new(!0);
|
|
||||||
fn set_bank(bank: u8) -> Result<(), Error> {
|
fn set_bank(bank: u8) -> Result<(), Error> {
|
||||||
|
static CURRENT_BANK: AtomicU8 = AtomicU8::new(!0);
|
||||||
if bank == 0xFF {
|
if bank == 0xFF {
|
||||||
Err(Error::OutOfBounds)
|
Err(Error::OutOfBounds)
|
||||||
} else if bank != CURRENT_BANK.load(Ordering::SeqCst) {
|
} 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> {
|
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
|
CHIP_INFO
|
||||||
.get_or_try_init(|| -> Result<_, Error> { Ok(FlashChipType::detect()?.chip_info()) })
|
.get_or_try_init(|| -> Result<_, Error> { Ok(FlashChipType::detect()?.chip_info()) })
|
||||||
.cloned()
|
.cloned()
|
||||||
|
|
Loading…
Reference in a new issue