Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ jobs:
cargo install cargo-binutils
rustup component add llvm-tools-preview
- name: Check
run: cargo check --target thumbv7em-none-eabi
run: cargo check --features cortex-m --target thumbv7em-none-eabi
- name: Clippy
run: cargo clippy --target thumbv7em-none-eabi
run: cargo clippy --features cortex-m --target thumbv7em-none-eabi
- name: Format
run: cargo fmt
2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@ default = ["erase-chip", "panic-handler"]
erase-chip = []
panic-handler = []
verify = []
cortex-m = []
risc-v = []
9 changes: 9 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,20 @@
#![no_main]
#![macro_use]

#[cfg(all(
not(any(feature = "cortex-m", feature = "risc-v")),
all(not(test), feature = "panic-handler")
))]
compile_error!("Enable either the cortex-m or risc-v feature");

#[cfg(all(not(test), feature = "panic-handler"))]
#[panic_handler]
fn panic(_info: &core::panic::PanicInfo) -> ! {
unsafe {
#[cfg(feature = "cortex-m")]
core::arch::asm!("udf #0");
#[cfg(feature = "risc-v")]
core::arch::asm!("UNIMP");
core::hint::unreachable_unchecked();
}
}
Expand Down