This commit is contained in:
Corwin Kuiper 2021-08-06 23:21:50 +01:00
parent 1b971b8993
commit da6ff40a32

View file

@ -242,6 +242,18 @@ pub fn add_interrupt<'a>(interrupt: Pin<&'a InterruptClosureBounded<'a>>) {
} }
#[macro_export] #[macro_export]
/// Creates a new interrupt handler in the current scope, when this scope drops
/// the interrupt handler is removed. Note that this returns nothing, but some
/// stack space is used. The interrupt handler is of the form `Fn(Key) + Send +
/// Sync` where Key can be used to unlock a mutex without checking whether
/// interrupts need to be disabled, as during an interrupt interrupts are
/// disabled.
///
/// # Usage
/// ```
/// add_interrupt_handler!(Interrupt::VBlank, |key| agb::println!("hello world!"));
/// ```
///
macro_rules! add_interrupt_handler { macro_rules! add_interrupt_handler {
($interrupt: expr, $handler: expr) => { ($interrupt: expr, $handler: expr) => {
let a = $handler; let a = $handler;