diff options
author | 2023-12-06 08:49:38 +0100 | |
---|---|---|
committer | 2023-12-06 07:49:38 +0000 | |
commit | 89160b7cb9b3623e0a50f6745296d470fa7ea79d (patch) | |
tree | 1409920c1fe8dec4857cd1e73f2f02485229fcad /examples/nrf52840_blinky/src/lib.rs | |
parent | 1622f6b953c93c3a680769636b60733f281f1ac0 (diff) | |
download | rtic-89160b7cb9b3623e0a50f6745296d470fa7ea79d.tar.gz rtic-89160b7cb9b3623e0a50f6745296d470fa7ea79d.tar.zst rtic-89160b7cb9b3623e0a50f6745296d470fa7ea79d.zip |
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
Diffstat (limited to 'examples/nrf52840_blinky/src/lib.rs')
-rw-r--r-- | examples/nrf52840_blinky/src/lib.rs | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/examples/nrf52840_blinky/src/lib.rs b/examples/nrf52840_blinky/src/lib.rs new file mode 100644 index 00000000..7795f2da --- /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); + } +} |