Add example for custom error handler
diff --git a/Makefile b/Makefile index d912813..34d223e 100644 --- a/Makefile +++ b/Makefile
@@ -43,6 +43,7 @@ PLATFORM=nrf52 cargo build --release --target=thumbv7em-none-eabi --examples PLATFORM=nrf52 cargo build --release --target=thumbv7em-none-eabi --examples --features=alloc PLATFORM=opentitan cargo build --release --target=riscv32imc-unknown-none-elf --examples + cd core && cargo build --release --target=thumbv7em-none-eabi --examples --features=custom_panic_handler && cd .. .PHONY: test test:
diff --git a/core/Cargo.toml b/core/Cargo.toml index 64fa96e..f0477eb 100644 --- a/core/Cargo.toml +++ b/core/Cargo.toml
@@ -11,3 +11,8 @@ [dependencies] linked_list_allocator = { optional = true, version = "=0.6.5", default-features = false } + +[[example]] +name = "custom_panic" +path = "examples/custom_handler.rs" +required-features = ["custom_panic_handler"] \ No newline at end of file
diff --git a/core/examples/custom_handler.rs b/core/examples/custom_handler.rs new file mode 100644 index 0000000..8cccca9 --- /dev/null +++ b/core/examples/custom_handler.rs
@@ -0,0 +1,12 @@ +#![no_std] + +use libtock_core::result::CommandError; + +fn main() -> Result<(), CommandError> { + panic!("Bye world!"); +} + +#[panic_handler] +unsafe fn panic_handler(_info: &core::panic::PanicInfo) -> ! { + loop {} +}