Skip to content
Snippets Groups Projects
Select Git revision
  • 3c6aef08e4aed4eeaede18a66a45c793c33a07f2
  • master default protected
2 results

r

Blame
  • bare0.rs 775 B
    //! bare0.rs
    //! Simple bare metal application
    
    // feature to ensure symbols to be linked
    #![feature(used)]
    // build without the Rust standard library
    #![no_std]
    
    // Minimal runtime / startup for Cortex-M microcontrollers
    extern crate cortex_m_rt;
    
    const X_INIT: u32 = 10;
    
    static mut X: u32 = X_INIT;
    static mut Y: u32 = 0;
    
    #[inline(never)]
    fn main() {
        let mut x = unsafe { X };
    
        loop {
            x += 1;
            unsafe {
                X += 1;
                Y = X;
                assert!(x == X && X == Y);
            }
        }
    }
    
    // As we are not using interrupts, we just register a dummy catch all handler
    #[link_section = ".vector_table.interrupts"]
    #[used]
    static INTERRUPTS: [extern "C" fn(); 240] = [default_handler; 240];
    
    extern "C" fn default_handler() {
        loop {}
    }