[][src]Function cortex_m_rt_macros::entry

pub fn entry(args: TokenStream, input: TokenStream) -> TokenStream

Attribute to declare the entry point of the program

IMPORTANT: This attribute must be used once in the dependency graph and must be used on a reachable item (i.e. there must be no private modules between the item and the root of the crate). If the item is in the root of the crate you'll be fine.

The specified function will be called by the reset handler after RAM has been initialized. In the case of the thumbv7em-none-eabihf target the FPU will also be enabled before the function is called.

The type of the specified function must be [unsafe] fn() -> ! (never ending function)

Properties

The entry point will be called by the reset handler. The program can't reference to the entry point, much less invoke it.

static mut variables declared within the entry point are safe to access. The compiler can't prove this is safe so the attribute will help by making a transformation to the source code: for this reason a variable like static mut FOO: u32 will become let FOO: &'static mut u32;. Note that &'static mut references have move semantics.

Examples

#[entry]
fn main() -> ! {
    loop {
        /* .. */
    }
}
#[entry]
fn main() -> ! {
    static mut FOO: u32 = 0;

    let foo: &'static mut u32 = FOO;
    assert_eq!(*foo, 0);
    *foo = 1;
    assert_eq!(*foo, 1);

    loop {
        /* .. */
    }
}