//! Low level access to Cortex-M processors //! //! This crate provides access to: //! //! - Core peripherals like NVIC, SCB and SysTick. //! - Core registers like CONTROL, MSP and PSR. //! - Interrupt manipulation mechanisms //! - Data structures like the vector table //! - Miscellaneous assembly instructions like `bkpt` #![cfg_attr(feature = "semihosting", feature(macro_reexport))] #![cfg_attr(target_arch = "arm", feature(core_intrinsics))] #![deny(missing_docs)] #![deny(warnings)] #![feature(asm)] #![feature(const_fn)] #![feature(naked_functions)] #![no_std] #[cfg(feature = "semihosting")] pub extern crate cortex_m_semihosting as semihosting; extern crate volatile_register; #[macro_use] mod macros; #[macro_use] pub mod asm; pub mod exception; pub mod interrupt; pub mod peripheral; pub mod register; /// Stack frame #[repr(C)] pub struct StackFrame { /// (General purpose) Register 0 pub r0: u32, /// (General purpose) Register 1 pub r1: u32, /// (General purpose) Register 2 pub r2: u32, /// (General purpose) Register 3 pub r3: u32, /// (General purpose) Register 12 pub r12: u32, /// Linker Register pub lr: u32, /// Program Counter pub pc: u32, /// Program Status Register pub xpsr: u32, } /// Vector Table /// /// # References /// /// - ARMv7-M Architecture Reference Manual (issue E.b) - Section B1.5 - ARMv7-M exception model #[repr(C)] pub struct VectorTable { /// Reset value of the Main Stack Pointer (MSP) pub sp_main: &'static (), /// Reset pub reset: extern "C" fn() -> !, /// Non Maskable Interrupt pub nmi: Option, /// Hard Fault pub hard_fault: Option, /// Memory Management pub mem_manage: Option, /// Bus Fault pub bus_fault: Option, /// Usage Fault pub usage_fault: Option, reserved0: [u32; 4], /// Supervisor Call pub svcall: Option, /// Debug Monitor pub debug_monitor: Option, reserved1: u32, /// PendSV pub pendsv: Option, /// SysTick pub sys_tick: Option, /// Interrupts. An IMPLEMENTATION DEFINED number of them. pub interrupts: [Option; 0], } /// A reserved spot in the vector table #[derive(Clone, Copy)] #[repr(u32)] pub enum Reserved { /// Reserved Vector = 0, } /// Exception/Interrupt Handler pub type Handler = unsafe extern "C" fn(); /// Returns the vector table pub fn vector_table() -> &'static VectorTable { unsafe { deref(peripheral::scb().vtor.read() as usize) } } #[cfg(test)] fn address(r: &T) -> usize { r as *const T as usize } unsafe fn deref(a: usize) -> &'static T { &*(a as *const T) } unsafe fn deref_mut(a: usize) -> &'static mut T { &mut *(a as *mut T) } on> Unnamed repository; edit this file 'description' to name the repository.
aboutsummaryrefslogtreecommitdiff
AgeCommit message (Expand)AuthorFilesLines
2022-06-22Update index.d.tsGravatar Jarred Sumner 1-0/+1
2022-06-22types for `bun:jsc`Gravatar Jarred Sumner 2-1/+37
2022-06-22Slightly customize the `events` polyfill so it uses ESMGravatar Jarred Sumner 1-1/+522
2022-06-22Fix memory bugs in escapeHTML & arrayBufferToStringGravatar Jarred Sumner 1-65/+61