aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Finomnis <finomnis@gmail.com> 2023-11-04 00:04:19 +0100
committerGravatar Emil Fresk <emil.fresk@gmail.com> 2023-11-08 19:43:09 +0000
commitb5f9579b90baf3d77ef942cf30a65fabfa73bb1d (patch)
tree1b6466d078c0a95f2a5602eba718a2c0bca19bcd
parent2fd3b3c4042dd7bffc5387f589a6aef3cf44a8cb (diff)
downloadrtic-b5f9579b90baf3d77ef942cf30a65fabfa73bb1d.tar.gz
rtic-b5f9579b90baf3d77ef942cf30a65fabfa73bb1d.tar.zst
rtic-b5f9579b90baf3d77ef942cf30a65fabfa73bb1d.zip
Use imxrt-uart-panic crate instead of custom panic handler
-rw-r--r--examples/teensy4_blinky/Cargo.lock15
-rw-r--r--examples/teensy4_blinky/Cargo.toml1
-rw-r--r--examples/teensy4_blinky/examples/common/mod.rs42
-rw-r--r--examples/teensy4_blinky/examples/with_logs.rs4
4 files changed, 17 insertions, 45 deletions
diff --git a/examples/teensy4_blinky/Cargo.lock b/examples/teensy4_blinky/Cargo.lock
index 8253a71b..daec54f7 100644
--- a/examples/teensy4_blinky/Cargo.lock
+++ b/examples/teensy4_blinky/Cargo.lock
@@ -194,6 +194,7 @@ version = "0.1.0"
dependencies = [
"embedded-hal 0.2.7",
"imxrt-log",
+ "imxrt-uart-panic",
"log",
"nb 1.1.0",
"rtic",
@@ -279,6 +280,19 @@ dependencies = [
]
[[package]]
+name = "imxrt-uart-panic"
+version = "0.1.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "fbec2a318caf77dd2299f23982a2cc3435af8cc0b99787eaba3dbff711efc1d3"
+dependencies = [
+ "cortex-m",
+ "embedded-hal 0.2.7",
+ "imxrt-hal",
+ "imxrt-ral",
+ "nb 1.1.0",
+]
+
+[[package]]
name = "imxrt-usbd"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -434,7 +448,6 @@ dependencies = [
"embedded-hal 1.0.0-rc.1",
"fugit",
"imxrt-ral",
- "log",
"rtic-time",
]
diff --git a/examples/teensy4_blinky/Cargo.toml b/examples/teensy4_blinky/Cargo.toml
index 800ad58b..a81a155a 100644
--- a/examples/teensy4_blinky/Cargo.toml
+++ b/examples/teensy4_blinky/Cargo.toml
@@ -32,6 +32,7 @@ imxrt-log = { version = "0.1.1", default-features = false, features = [
"lpuart",
] }
log = "0.4.20"
+imxrt-uart-panic = "0.1.1"
# this lets you use `cargo fix`!
[[bin]]
diff --git a/examples/teensy4_blinky/examples/common/mod.rs b/examples/teensy4_blinky/examples/common/mod.rs
deleted file mode 100644
index 9851feab..00000000
--- a/examples/teensy4_blinky/examples/common/mod.rs
+++ /dev/null
@@ -1,42 +0,0 @@
-macro_rules! uart_panic_handler {
- ($uart: ident, $tx_pin: ident, $rx_pin: ident, $baud: expr) => {
- #[panic_handler]
- fn panic(info: &::core::panic::PanicInfo) -> ! {
- use ::core::fmt::Write as _;
- use ::embedded_hal::serial::Write as _;
-
- let ::teensy4_bsp::board::Resources {
- $uart: uart, pins, ..
- } = ::teensy4_bsp::board::t40(unsafe { ::teensy4_bsp::ral::Instances::instances() });
-
- let uart = ::teensy4_bsp::board::lpuart(uart, pins.$tx_pin, pins.$rx_pin, $baud);
-
- struct UartWriter<P, const N: u8> {
- uart: ::teensy4_bsp::hal::lpuart::Lpuart<P, N>,
- }
- impl<P, const N: u8> ::core::fmt::Write for UartWriter<P, N> {
- fn write_str(&mut self, s: &str) -> ::core::fmt::Result {
- for &b in s.as_bytes() {
- if b == b'\n' {
- let _ = ::nb::block!(self.uart.write(b'\r'));
- }
- let _ = ::nb::block!(self.uart.write(b));
- }
- Ok(())
- }
- }
-
- let mut uart = UartWriter { uart };
-
- ::core::writeln!(uart).ok();
- ::core::writeln!(uart, "{}", info).ok();
- ::core::writeln!(uart).ok();
-
- let _ = ::nb::block!(uart.uart.flush());
-
- ::teensy4_panic::sos()
- }
- };
-}
-
-pub(crate) use uart_panic_handler;
diff --git a/examples/teensy4_blinky/examples/with_logs.rs b/examples/teensy4_blinky/examples/with_logs.rs
index dd4fef0b..cdf0315e 100644
--- a/examples/teensy4_blinky/examples/with_logs.rs
+++ b/examples/teensy4_blinky/examples/with_logs.rs
@@ -3,8 +3,8 @@
#![no_std]
#![feature(type_alias_impl_trait)]
-mod common;
-common::uart_panic_handler!(lpuart6, p1, p0, 115200);
+use bsp::pins::common::{P0, P1};
+imxrt_uart_panic::register!(LPUART6, P1, P0, 115200, teensy4_panic::sos);
use teensy4_bsp as bsp;