From 6d51d1bef327549b656cce6d2df67fbd6194fa27 Mon Sep 17 00:00:00 2001 From: Alissa Rao Date: Tue, 16 Aug 2022 19:20:15 -0700 Subject: [PATCH] Rework a simpler example to use agb::sync instead of bare_metal. --- agb/examples/output.rs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/agb/examples/output.rs b/agb/examples/output.rs index 88b60519..0869f382 100644 --- a/agb/examples/output.rs +++ b/agb/examples/output.rs @@ -1,19 +1,17 @@ #![no_std] #![no_main] -use core::cell::RefCell; - -use bare_metal::{CriticalSection, Mutex}; +use agb::sync::Static; #[agb::entry] fn main(_gba: agb::Gba) -> ! { - let count = Mutex::new(RefCell::new(0)); + let count = Static::new(0); let _a = agb::interrupt::add_interrupt_handler( agb::interrupt::Interrupt::VBlank, - |key: CriticalSection| { - let mut count = count.borrow(key).borrow_mut(); - agb::println!("Hello, world, frame = {}", *count); - *count += 1; + |_| { + let cur_count = count.read(); + agb::println!("Hello, world, frame = {}", cur_count); + count.write(cur_count + 1); }, ); loop {}