diff options
author | 2017-06-28 21:10:35 -0500 | |
---|---|---|
committer | 2017-06-30 18:08:28 -0500 | |
commit | c05f8f1974ae28da6aff612417bf5defc92e28b4 (patch) | |
tree | 02f15ab6783d1a31e9e6146f7ab003a44888b031 | |
parent | a396a68a43e684b4388cfdcaa0caacbe0dcc4b71 (diff) | |
download | cortex-m-c05f8f1974ae28da6aff612417bf5defc92e28b4.tar.gz cortex-m-c05f8f1974ae28da6aff612417bf5defc92e28b4.tar.zst cortex-m-c05f8f1974ae28da6aff612417bf5defc92e28b4.zip |
drop unused feature gates, rename StackedRegisters to StackFrame
-rw-r--r-- | src/exception.rs | 30 | ||||
-rw-r--r-- | src/lib.rs | 3 |
2 files changed, 14 insertions, 19 deletions
diff --git a/src/exception.rs b/src/exception.rs index 36bf320..17a493b 100644 --- a/src/exception.rs +++ b/src/exception.rs @@ -1,25 +1,23 @@ //! Exceptions -#![allow(non_camel_case_types)] - -/// Enumeration of all exceptions +/// Enumeration of all the exception types #[derive(Clone, Copy, Debug, Eq, PartialEq)] pub enum Exception { /// Non-maskable interrupt Nmi, - /// All class of fault. + /// Other type of faults and unhandled faults HardFault, - /// Memory management. + /// Memory protection related fault MenManage, - /// Pre-fetch fault, memory access fault. + /// Pre-fetch or memory access fault BusFault, - /// Undefined instruction or illegal state. + /// Fault due to undefined instruction or illegal state UsageFault, - /// System service call via SWI instruction + /// Supervisor call Svcall, - /// Pendable request for system service + /// Pendable request for system-level service Pendsv, - /// System tick timer + /// System timer exception SysTick, /// An interrupt Interrupt(u8), @@ -29,15 +27,15 @@ pub enum Exception { } impl Exception { - /// Returns the kind of exception that's currently being serviced + /// Returns the type of the exception that's currently active + /// + /// Returns `None` if no exception is currently active pub fn active() -> Option<Exception> { // NOTE(safe) atomic read let icsr = unsafe { (*::peripheral::SCB.get()).icsr.read() }; - if icsr == 0 { - return None; - } Some(match icsr as u8 { + 0 => return None, 2 => Exception::Nmi, 3 => Exception::HardFault, 4 => Exception::MenManage, @@ -52,10 +50,10 @@ impl Exception { } } -/// Registers stacked during an exception +/// Registers stacked (pushed into the stack) during an exception #[derive(Clone, Copy, Debug)] #[repr(C)] -pub struct StackedRegisters { +pub struct StackFrame { /// (General purpose) Register 0 pub r0: u32, /// (General purpose) Register 1 @@ -12,9 +12,6 @@ #![deny(warnings)] #![feature(asm)] #![feature(const_fn)] -#![feature(linkage)] -#![feature(naked_functions)] -#![feature(used)] #![no_std] extern crate aligned; |