From b34c8e3eb1f3adab3e28c3b0b8ae3ab4c339c33b Mon Sep 17 00:00:00 2001 From: Corey Schuhen Date: Mon, 11 Dec 2023 21:25:05 +1000 Subject: [PATCH] Update formatting. --- examples/stm32f1/src/bin/can.rs | 27 ++++++++------------------- 1 file changed, 8 insertions(+), 19 deletions(-) diff --git a/examples/stm32f1/src/bin/can.rs b/examples/stm32f1/src/bin/can.rs index abe60b35..625a3843 100644 --- a/examples/stm32f1/src/bin/can.rs +++ b/examples/stm32f1/src/bin/can.rs @@ -4,13 +4,12 @@ use defmt::*; use embassy_executor::Spawner; -use embassy_stm32::bind_interrupts; use embassy_stm32::can::bxcan::filter::Mask32; -use embassy_stm32::can::bxcan::{Fifo, Frame, StandardId, Id}; +use embassy_stm32::can::bxcan::{Fifo, Frame, Id, StandardId}; use embassy_stm32::can::{Can, Rx0InterruptHandler, Rx1InterruptHandler, SceInterruptHandler, TxInterruptHandler}; -use embassy_stm32::Config; use embassy_stm32::peripherals::CAN; +use embassy_stm32::{bind_interrupts, Config}; use {defmt_rtt as _, panic_probe as _}; bind_interrupts!(struct Irqs { @@ -23,10 +22,8 @@ bind_interrupts!(struct Irqs { // This example is configured to work with real CAN transceivers on B8/B9. // See other examples for loopback. - #[embassy_executor::main] async fn main(_spawner: Spawner) { - let p = embassy_stm32::init(Config::default()); // Set alternate pin mapping to B8/B9 @@ -34,7 +31,6 @@ async fn main(_spawner: Spawner) { let mut can = Can::new(p.CAN, p.PB8, p.PB9, Irqs); - can.as_mut() .modify_filters() .enable_bank(0, Fifo::Fifo0, Mask32::accept_all()); @@ -44,34 +40,27 @@ async fn main(_spawner: Spawner) { .set_loopback(false) .set_silent(false) .leave_disabled(); - can.set_bitrate(250_000); can.enable().await; - let mut i: u8 = 0; loop { let tx_frame = Frame::new_data(unwrap!(StandardId::new(i as _)), [i]); can.write(&tx_frame).await; match can.read().await { - Ok(env) => { - - match env.frame.id() { - Id::Extended(id) => { - defmt::println!("Extended Frame id={:x}", id.as_raw()); - }, - Id::Standard(id) => { - defmt::println!("Standard Frame id={:x}", id.as_raw()); - }, + Ok(env) => match env.frame.id() { + Id::Extended(id) => { + defmt::println!("Extended Frame id={:x}", id.as_raw()); + } + Id::Standard(id) => { + defmt::println!("Standard Frame id={:x}", id.as_raw()); } - }, Err(err) => { defmt::println!("Error {}", err); - } } i += 1;