add as_mut & set loopback true in example

This commit is contained in:
Philipp Scheff 2023-06-22 17:47:58 +02:00
parent f47a148f51
commit 76a334bd7c

View File

@ -45,14 +45,16 @@ async fn main(spawner: Spawner) {
core::mem::forget(rx_pin); core::mem::forget(rx_pin);
let CAN: &'static mut Can<'static,CAN3> = static_cell::make_static!(Can::new(p.CAN3, p.PA8, p.PA15, Irqs)); let CAN: &'static mut Can<'static,CAN3> = static_cell::make_static!(Can::new(p.CAN3, p.PA8, p.PA15, Irqs));
CAN.can.borrow_mut().modify_filters().enable_bank(0, Fifo::Fifo0, Mask32::accept_all()); CAN.as_mut().modify_filters().enable_bank(0, Fifo::Fifo0, Mask32::accept_all());
CAN.can.borrow_mut() CAN.as_mut()
.modify_config() .modify_config()
.set_bit_timing(0x001c0001) // http://www.bittiming.can-wiki.info/ .set_bit_timing(0x001c0001) // http://www.bittiming.can-wiki.info/
.set_loopback(true)
.enable(); .enable();
let (tx, mut rx) = CAN.split(); let (tx, mut rx) = CAN.split();
let TX: &'static mut CanTx<'static, 'static, CAN3> = static_cell::make_static!(tx); let TX: &'static mut CanTx<'static, 'static, CAN3> = static_cell::make_static!(tx);
spawner.spawn(send_can_message(TX)).unwrap(); spawner.spawn(send_can_message(TX)).unwrap();