Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #![feature(global_asm)]
- #![no_main]
- #![no_std]
- const LED_ADDRESS: u32 = 0x0300_0000;
- use panic_abort;
- // The reset handler
- #[no_mangle]
- #[link_section = ".Premain"]
- pub unsafe extern "C" fn Premain() -> ! {
- r0::zero_bss(&mut _sbss, &mut _ebss);
- r0::init_data(&mut _sdata, &mut _edata, &_sidata);
- main()
- }
- fn main() -> ! {
- loop {
- for _ in 0..256 {
- unsafe { core::ptr::write_volatile(LED_ADDRESS as *mut u32, 0xffff_ffff); }
- }
- }
- }
- extern "C" {
- // Boundaries of the .bss section
- static mut _ebss: u32;
- static mut _sbss: u32;
- // Boundaries of the .data section
- static mut _edata: u32;
- static mut _sdata: u32;
- // Initial values of the .data section (stored in Flash)
- static _sidata: u32;
- }
- // Make sure there is an abort when linking
- #[cfg(target_arch = "riscv32")]
- global_asm!(r#"
- .section .text
- global Reset
- Reset:
- .option rvc
- c.j Premain
- .globl abort
- abort:
- jal zero, abort
- "#);
Add Comment
Please, Sign In to add comment