Skip to content
Snippets Groups Projects
Select Git revision
  • 7bbafc3358933fea38ac1c696616e6e15515efa1
  • master default protected
  • experimental
  • itm_trace
4 results

bare0.rs

Blame
  • bare0.rs 663 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;
    
    static mut X: u32 = 10;
    fn main() {
        let mut x = unsafe { X };
    
        loop {
            x += 1;
            unsafe {
                X += 1;
                assert!(x == X);
            }
        }
    }
    
    // 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() {}