fmt
This commit is contained in:
		| @@ -1,9 +1,8 @@ | |||||||
|  | use core::cell::{RefCell, RefMut}; | ||||||
| use core::future::poll_fn; | use core::future::poll_fn; | ||||||
| use core::marker::PhantomData; | use core::marker::PhantomData; | ||||||
| use core::ops::{Deref, DerefMut}; | use core::ops::{Deref, DerefMut}; | ||||||
| use core::task::Poll; | use core::task::Poll; | ||||||
| use core::cell::RefMut; |  | ||||||
| use core::cell::RefCell; |  | ||||||
|  |  | ||||||
| pub use bxcan; | pub use bxcan; | ||||||
| use bxcan::{Data, ExtendedId, Frame, Id, StandardId}; | use bxcan::{Data, ExtendedId, Frame, Id, StandardId}; | ||||||
| @@ -155,7 +154,11 @@ impl<'d, T: Instance> Can<'d, T> { | |||||||
|  |  | ||||||
|     pub fn set_bitrate(&mut self, bitrate: u32) { |     pub fn set_bitrate(&mut self, bitrate: u32) { | ||||||
|         let bit_timing = Self::calc_bxcan_timings(T::frequency(), bitrate).unwrap(); |         let bit_timing = Self::calc_bxcan_timings(T::frequency(), bitrate).unwrap(); | ||||||
|         self.can.borrow_mut().modify_config().set_bit_timing(bit_timing).leave_disabled(); |         self.can | ||||||
|  |             .borrow_mut() | ||||||
|  |             .modify_config() | ||||||
|  |             .set_bit_timing(bit_timing) | ||||||
|  |             .leave_disabled(); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     /// Queues the message to be sent but exerts backpressure |     /// Queues the message to be sent but exerts backpressure | ||||||
| @@ -432,19 +435,19 @@ impl<'d, T: Instance> Drop for Can<'d, T> { | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| // impl<'d, T: Instance> Deref for Can<'d, T> { | impl<'d, T: Instance> Deref for Can<'d, T> { | ||||||
| //     type Target = bxcan::Can<BxcanInstance<'d, T>>; |     type Target = RefCell<bxcan::Can<BxcanInstance<'d, T>>>; | ||||||
|  |  | ||||||
| //     fn deref(&self) -> &Self::Target { |     fn deref(&self) -> &Self::Target { | ||||||
| //         self.can.borrow() |         &self.can | ||||||
| //     } |     } | ||||||
| // } | } | ||||||
|  |  | ||||||
| // impl<'d, T: Instance> DerefMut for Can<'d, T> { | impl<'d, T: Instance> DerefMut for Can<'d, T> { | ||||||
| //     fn deref_mut(&mut self) -> &mut Self::Target { |     fn deref_mut(&mut self) -> &mut Self::Target { | ||||||
| //         self.can.borrow_mut() |         &mut self.can | ||||||
| //     } |     } | ||||||
| // } | } | ||||||
|  |  | ||||||
| pub(crate) mod sealed { | pub(crate) mod sealed { | ||||||
|     use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex; |     use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex; | ||||||
|   | |||||||
| @@ -2,15 +2,17 @@ | |||||||
| #![no_main] | #![no_main] | ||||||
| #![feature(type_alias_impl_trait)] | #![feature(type_alias_impl_trait)] | ||||||
|  |  | ||||||
| use core::borrow::BorrowMut; | use core::borrow::{Borrow, BorrowMut}; | ||||||
| use core::borrow::Borrow; |  | ||||||
| use cortex_m_rt::entry; | use cortex_m_rt::entry; | ||||||
| use defmt::*; | use defmt::*; | ||||||
| use embassy_executor::Spawner; | use embassy_executor::Spawner; | ||||||
| use embassy_stm32::bind_interrupts; | use embassy_stm32::bind_interrupts; | ||||||
| use embassy_stm32::can::bxcan::filter::Mask32; | use embassy_stm32::can::bxcan::filter::Mask32; | ||||||
| use embassy_stm32::can::bxcan::{Fifo, Frame, StandardId, Data}; | use embassy_stm32::can::bxcan::{Data, Fifo, Frame, StandardId}; | ||||||
| use embassy_stm32::can::{Can,CanTx,CanRx, Rx0InterruptHandler, Rx1InterruptHandler, SceInterruptHandler, TxInterruptHandler}; | use embassy_stm32::can::{ | ||||||
|  |     Can, CanRx, CanTx, Rx0InterruptHandler, Rx1InterruptHandler, SceInterruptHandler, TxInterruptHandler, | ||||||
|  | }; | ||||||
| use embassy_stm32::gpio::{Input, Pull}; | use embassy_stm32::gpio::{Input, Pull}; | ||||||
| use embassy_stm32::peripherals::CAN3; | use embassy_stm32::peripherals::CAN3; | ||||||
| use {defmt_rtt as _, panic_probe as _}; | use {defmt_rtt as _, panic_probe as _}; | ||||||
| @@ -44,8 +46,10 @@ async fn main(spawner: Spawner) { | |||||||
|     let rx_pin = Input::new(&mut p.PA15, Pull::Up); |     let rx_pin = Input::new(&mut p.PA15, Pull::Up); | ||||||
|     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.as_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.as_mut() |     CAN.as_mut() | ||||||
|         .modify_config() |         .modify_config() | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user