Struct atmega32u4_hal::global::Global[][src]

pub struct Global<T>(_);

A global variable store

Safe abstraction for global variables

Example

static MY_GLOBAL: atmega32u4_hal::Global<u64> = atmega32u4_hal::Global::new();

fn main() {
    MY_GLOBAL.set(0xC0FFEE);

    loop { }
}

interrupt!(INT1, int1_isr);
fn int1_isr() {
    MY_GLOBAL.get(|v| {
        // Do something
    }).expect("Interrupt fired before initialisation!");
}

Methods

impl<T> Global<T>
[src]

Create a new global variable

Set this global to some value

Used for initialization

Get the value of this global

Will execute f with the value of the global if the global has been initialized. If it hasn't been, return Err(()).

While the closure is executed, interrupts are disabled.

Trait Implementations

impl<T> Sync for Global<T>
[src]

Auto Trait Implementations

impl<T> Send for Global<T> where
    T: Send