From 55aebb5db2d4458cbf1e056057d5f890914ea696 Mon Sep 17 00:00:00 2001 From: Hexa Dust Date: Fri, 18 Jul 2025 20:31:23 +0100 Subject: [PATCH] use 115200 baud and print panic over serial --- .cargo/config.toml | 2 +- Cargo.lock | 11 +++++++---- Cargo.toml | 2 +- src/main.rs | 14 +++++++++++++- 4 files changed, 22 insertions(+), 7 deletions(-) diff --git a/.cargo/config.toml b/.cargo/config.toml index 5bf870f..1bf783e 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -2,7 +2,7 @@ target = "avr-specs/avr-atmega328p.json" [target.'cfg(target_arch = "avr")'] -runner = "ravedude nano-new -cb 57600" +runner = "ravedude nano-new -cb 115200" [unstable] build-std = ["core"] diff --git a/Cargo.lock b/Cargo.lock index 16ad6f8..4dddcb0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -32,7 +32,7 @@ dependencies = [ "arduino-hal", "embedded-hal 1.0.0", "nb 1.1.0", - "panic-halt", + "panic-serial", "proc-macro2", "ufmt", ] @@ -142,10 +142,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8d5439c4ad607c3c23abf66de8c8bf57ba8adcd1f129e699851a6e43935d339d" [[package]] -name = "panic-halt" -version = "0.2.0" +name = "panic-serial" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de96540e0ebde571dc55c73d60ef407c653844e6f9a1e2fdbd40c07b9252d812" +checksum = "c3afc60d58b0825ea32dd8d8a2796098f7b87ad3b9392cace3b6dc79e450afd9" +dependencies = [ + "ufmt", +] [[package]] name = "paste" diff --git a/Cargo.toml b/Cargo.toml index 7080caa..db67986 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,10 +11,10 @@ test = false bench = false [dependencies] -panic-halt = "0.2.0" ufmt = "0.2.0" nb = "1.1.0" embedded-hal = "1.0" +panic-serial = { version = "0.1.2", features = ["full"] } [dependencies.arduino-hal] git = "https://github.com/rahix/avr-hal" diff --git a/src/main.rs b/src/main.rs index 7a6a7ba..027694d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,7 +1,15 @@ #![no_std] #![no_main] -use panic_halt as _; +use arduino_hal::prelude::*; + +panic_serial::impl_panic_handler!( + arduino_hal::usart::Usart< + arduino_hal::pac::USART0, + arduino_hal::port::Pin, + arduino_hal::port::Pin + > +); #[arduino_hal::entry] fn main() -> ! { @@ -19,6 +27,10 @@ fn main() -> ! { */ let mut led = pins.d13.into_output(); + let serial = arduino_hal::default_serial!(dp, pins, 115200); + let mut serial = share_serial_port_with_panic(serial); + + ufmt::uwriteln!(&mut serial, "Hello from Arduino!").unwrap_infallible(); loop { led.toggle();