Skip to content

Commit

Permalink
Merge pull request #79 from quartiq/feature/panic-handler
Browse files Browse the repository at this point in the history
Adding custom panic handler
  • Loading branch information
ryan-summers authored Oct 3, 2020
2 parents 9ed3cad + e12c366 commit 5332dfe
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ version = "0.1.0"
[dependencies]
cortex-m = "0.6.3"
cortex-m-rt = "0.6.10"
panic-halt = "0.2.0"
cortex-m-rtic = "0.5.3"
embedded-hal = "0.2.4"
enum-iterator = "0.6.0"
Expand Down
1 change: 0 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ use core::fmt::Write;
use enum_iterator::IntoEnumIterator;
use heapless::String;
use minimq::QoS;
use panic_halt as _;
use stm32f4xx_hal as hal;

use hal::prelude::*;
Expand Down
13 changes: 13 additions & 0 deletions src/platform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,19 @@ use super::hal;

use embedded_hal::{blocking::delay::DelayUs, digital::v2::OutputPin};

#[panic_handler]
fn panic(info: &core::panic::PanicInfo) -> ! {
// Shutdown all of the RF channels.
shutdown_channels();

// Reset the device in `release` configuration.
#[cfg(not(debug_assertions))]
cortex_m::peripheral::SCB::sys_reset();

#[cfg(debug_assertions)]
loop {}
}

/// Unconditionally disable and power-off all channels.
pub fn shutdown_channels() {
let gpiod = unsafe { &*hal::stm32::GPIOD::ptr() };
Expand Down

0 comments on commit 5332dfe

Please sign in to comment.