Update formatting.

This commit is contained in:
Corey Schuhen 2023-12-11 21:25:05 +10:00
parent 13af76af88
commit b34c8e3eb1

View File

@ -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());
@ -45,33 +41,26 @@ async fn main(_spawner: Spawner) {
.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() {
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;