From 89fbb02979c0abfac99b32e3676c140055f31c1e Mon Sep 17 00:00:00 2001 From: Philipp Scheff Date: Thu, 22 Jun 2023 17:49:33 +0200 Subject: [PATCH] add as_mut --- embassy-stm32/src/can/bxcan.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/embassy-stm32/src/can/bxcan.rs b/embassy-stm32/src/can/bxcan.rs index 7b664a11..4afbb568 100644 --- a/embassy-stm32/src/can/bxcan.rs +++ b/embassy-stm32/src/can/bxcan.rs @@ -2,7 +2,9 @@ use core::future::poll_fn; use core::marker::PhantomData; use core::ops::{Deref, DerefMut}; use core::task::Poll; +use core::cell::RefMut; use core::cell::RefCell; + pub use bxcan; use bxcan::{Data, ExtendedId, Frame, Id, StandardId}; use embassy_hal_common::{into_ref, PeripheralRef}; @@ -346,6 +348,10 @@ impl<'d, T: Instance> Can<'d, T> { pub fn split<'c>(&'c self) -> (CanTx<'c, 'd, T>, CanRx<'c, 'd, T>) { (CanTx { can: &self.can }, CanRx { can: &self.can }) } + + pub fn as_mut(&self) -> RefMut<'_, bxcan::Can>> { + self.can.borrow_mut() + } } pub struct CanTx<'c, 'd, T: Instance> {