From 89160b7cb9b3623e0a50f6745296d470fa7ea79d Mon Sep 17 00:00:00 2001 From: Finomnis Date: Wed, 6 Dec 2023 08:49:38 +0100 Subject: Fix nrf monotonics (#852) * Fix nrf::timer * Bootstrap nrf52840-blinky example * More work on nrf blinky example * Fix README * Add asserts for correct timer functionality * Add correctness check to other monotonics as well * Update Changelog * Fix potential timing issues * Fix race condition in nrf::rtc * Add changelog * Add rtc blinky example * Change rtc example to RC lf clock source * Add changelog to rtic-time * Add changelog * Attempt to fix CI * Update teensy4-blinky Cargo.lock --- examples/nrf52840_blinky/src/lib.rs | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 examples/nrf52840_blinky/src/lib.rs (limited to 'examples/nrf52840_blinky/src/lib.rs') diff --git a/examples/nrf52840_blinky/src/lib.rs b/examples/nrf52840_blinky/src/lib.rs new file mode 100644 index 0000000..7795f2d --- /dev/null +++ b/examples/nrf52840_blinky/src/lib.rs @@ -0,0 +1,37 @@ +#![no_main] +#![no_std] + +use cortex_m_semihosting::debug; + +use defmt_rtt as _; // global logger + +pub use nrf52840_hal as hal; // memory layout + +use panic_probe as _; + +// same panicking *behavior* as `panic-probe` but doesn't print a panic message +// this prevents the panic message being printed *twice* when `defmt::panic` is invoked +#[defmt::panic_handler] +fn panic() -> ! { + cortex_m::asm::udf() +} + +/// Terminates the application and makes a semihosting-capable debug tool exit +/// with status code 0. +pub fn exit() -> ! { + loop { + debug::exit(debug::EXIT_SUCCESS); + } +} + +/// Hardfault handler. +/// +/// Terminates the application and makes a semihosting-capable debug tool exit +/// with an error. This seems better than the default, which is to spin in a +/// loop. +#[cortex_m_rt::exception] +unsafe fn HardFault(_frame: &cortex_m_rt::ExceptionFrame) -> ! { + loop { + debug::exit(debug::EXIT_FAILURE); + } +} -- cgit v1.2.3