aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Adam Greig <adam@adamgreig.com> 2022-02-24 23:26:09 +0000
committerGravatar Adam Greig <adam@adamgreig.com> 2022-02-24 23:26:09 +0000
commitf2feeb2595fe8f281a50d63055c65d6ac064ae11 (patch)
tree27cd5fc7911950d4bdc52cd84bfae24e2207f9f5
parentdb8bea29e61d4659942539f8da7fe4f39c02729f (diff)
downloadcortex-m-f2feeb2595fe8f281a50d63055c65d6ac064ae11.tar.gz
cortex-m-f2feeb2595fe8f281a50d63055c65d6ac064ae11.tar.zst
cortex-m-f2feeb2595fe8f281a50d63055c65d6ac064ae11.zip
Tweaks to enable building and doctesting on host platform
-rw-r--r--cortex-m-rt/src/lib.rs9
-rw-r--r--src/peripheral/mod.rs3
2 files changed, 7 insertions, 5 deletions
diff --git a/cortex-m-rt/src/lib.rs b/cortex-m-rt/src/lib.rs
index 5034983..793b928 100644
--- a/cortex-m-rt/src/lib.rs
+++ b/cortex-m-rt/src/lib.rs
@@ -439,13 +439,14 @@
extern crate cortex_m_rt_macros as macros;
-use core::arch::global_asm;
use core::fmt;
-use core::sync::atomic::{self, Ordering};
+#[cfg(cortex_m)]
+use core::arch::global_asm;
// HardFault exceptions are bounced through this trampoline which grabs the stack pointer at
// the time of the exception and passes it to th euser's HardFault handler in r0.
// Depending on the stack mode in EXC_RETURN, fetches stack from either MSP or PSP.
+#[cfg(cortex_m)]
global_asm!(
".cfi_sections .debug_frame
.section .HardFaultTrampoline, \"ax\"
@@ -468,6 +469,7 @@ global_asm!(
);
/// Parse cfg attributes inside a global_asm call.
+#[cfg(cortex_m)]
macro_rules! cfg_global_asm {
{@inner, [$($x:tt)*], } => {
global_asm!{$($x)*}
@@ -490,6 +492,7 @@ macro_rules! cfg_global_asm {
// Calls an optional user-provided __pre_init and then initialises RAM.
// If the target has an FPU, it is enabled.
// Finally jumsp to the user main function.
+#[cfg(cortex_m)]
cfg_global_asm! {
".cfi_sections .debug_frame
.section .Reset, \"ax\"
@@ -1048,12 +1051,14 @@ pub static __RESET_VECTOR: unsafe extern "C" fn() -> ! = Reset;
#[cfg_attr(cortex_m, link_section = ".HardFault.default")]
#[no_mangle]
pub unsafe extern "C" fn HardFault_(ef: &ExceptionFrame) -> ! {
+ #[allow(clippy::empty_loop)]
loop {}
}
#[doc(hidden)]
#[no_mangle]
pub unsafe extern "C" fn DefaultHandler_() -> ! {
+ #[allow(clippy::empty_loop)]
loop {}
}
diff --git a/src/peripheral/mod.rs b/src/peripheral/mod.rs
index d1dfb6a..56b663e 100644
--- a/src/peripheral/mod.rs
+++ b/src/peripheral/mod.rs
@@ -59,8 +59,6 @@
use core::marker::PhantomData;
use core::ops;
-
-#[cfg(cortex_m)]
use crate::interrupt;
#[cfg(cm7)]
@@ -164,7 +162,6 @@ static mut TAKEN: bool = false;
impl Peripherals {
/// Returns all the core peripherals *once*
- #[cfg(cortex_m)]
#[inline]
pub fn take() -> Option<Self> {
interrupt::free(|_| {