#![deny(missing_docs)]
#![deny(warnings)]
#![feature(asm)]
#![no_std]
extern crate volatile_register;
pub mod asm;
pub mod interrupt;
pub mod peripheral;
pub mod register;
#[repr(C)]
pub struct StackFrame {
pub r0: u32,
pub r1: u32,
pub r2: u32,
pub r3: u32,
pub r12: u32,
pub lr: u32,
pub pc: u32,
pub xpsr: u32,
}
#[repr(C)]
pub struct VectorTable {
pub sp_main: &'static (),
pub reset: extern "C" fn() -> !,
pub nmi: Option<Handler>,
pub hard_fault: Option<Handler>,
pub mem_manage: Option<Handler>,
pub bus_fault: Option<Handler>,
pub usage_fault: Option<Handler>,
reserved0: [u32; 4],
pub svcall: Option<Handler>,
pub debug_monitor: Option<Handler>,
reserved1: u32,
pub pendsv: Option<Handler>,
pub sys_tick: Option<Handler>,
pub interrupts: [Option<Handler>; 0],
}
pub fn vector_table() -> &'static VectorTable {
unsafe { deref(peripheral::scb().vtor.read() as usize) }
}
pub type Handler = unsafe extern "C" fn();
#[cfg(test)]
fn address<T>(r: &T) -> usize {
r as *const T as usize
}
unsafe fn deref<T>(a: usize) -> &'static T {
&*(a as *const T)
}
unsafe fn deref_mut<T>(a: usize) -> &'static mut T {
&mut *(a as *mut T)
}