[][src]Macro svd2rust::interrupt

macro_rules! interrupt {
    ($NAME:ident, $path:path) => { ... };
    ($NAME:ident, $path:path, locals: {
        $($lvar:ident: $lty:ty = $lval:expr;)+
    }) => { ... };

Assigns a handler to an interrupt

NOTE The interrupt! macro on Cortex-M device crates is closer in syntax to the exception! macro. This documentation doesn't apply to it. For the exact syntax of this macro check the documentation of the device crate you are using.

This macro takes two arguments: the name of an interrupt and the path to the function that will be used as the handler of that interrupt. That function must have signature fn().

Optionally, a third argument may be used to declare interrupt local data. The handler will have exclusive access to these local variables on each invocation. If the third argument is used then the signature of the handler function must be fn(&mut $NAME::Locals) where $NAME is the first argument passed to the macro.


This example is not tested
interrupt!(TIM2, periodic);

fn periodic() {

interrupt!(TIM3, tick, locals: {
    tick: bool = false;

fn tick(locals: &mut TIM3::Locals) {
    locals.tick = !locals.tick;

    if locals.tick {
    } else {