summaryrefslogtreecommitdiffstats
path: root/ble
diff options
context:
space:
mode:
authorBrian Cully <bjc@kublai.com>2019-08-12 12:13:21 -0400
committerBrian Cully <bjc@kublai.com>2019-08-13 15:33:41 -0400
commit7d64ea99fdbb04f93f23abbc9d0470e77ce9e1b5 (patch)
treedfaa2b5ccd9d7059611963037445d9a165bd8b47 /ble
parentb3e48318159257db6233671f66667c5358f27267 (diff)
downloadbleusb-7d64ea99fdbb04f93f23abbc9d0470e77ce9e1b5.tar.gz
bleusb-7d64ea99fdbb04f93f23abbc9d0470e77ce9e1b5.zip
Add HardFault handler.
Diffstat (limited to 'ble')
-rw-r--r--ble/src/main.rs16
1 files changed, 13 insertions, 3 deletions
diff --git a/ble/src/main.rs b/ble/src/main.rs
index 6f167a5..0fed859 100644
--- a/ble/src/main.rs
+++ b/ble/src/main.rs
@@ -10,7 +10,7 @@ mod rtc;
use clint::HandlerArray;
use core::mem;
use cortex_m::asm::wfi;
-use cortex_m_rt::entry;
+use cortex_m_rt::{entry, exception, ExceptionFrame};
use log::{info, trace, LevelFilter};
#[allow(unused_imports)]
@@ -47,12 +47,12 @@ fn main() -> ! {
let mut nvic = nrf52.NVIC;
let mut rtc_handler = rtc::setup(Rtc::new(nrf52.RTC0), Clocks::new(nrf52.CLOCK));
- logln_now!("logln_now?");
HANDLERS.with_overrides(|hs| {
hs.register(0, &mut rtc_handler);
nvic.enable(Interrupt::RTC0);
info!("Bootstrap complete.");
+
let mut last_tick = rtc::millis();
last_tick -= last_tick % 1024;
loop {
@@ -68,7 +68,17 @@ fn main() -> ! {
unreachable!();
}
-// TODO: RTC0/1/2 exist. See which is best, if it matters.
+#[exception]
+fn HardFault(ef: &ExceptionFrame) -> ! {
+ log::logger().flush();
+ logln_now!("!!! Hard Fault - ef: {:?} !!!", ef);
+ logln_now!("flushing log");
+ loop {
+ log::logger().flush();
+ wfi()
+ }
+}
+
#[interrupt]
fn RTC0() {
HANDLERS.call(0);