diff --git a/embassy-stm32/src/can/frame.rs b/embassy-stm32/src/can/frame.rs index d2d1f7aa6..f621b8bd5 100644 --- a/embassy-stm32/src/can/frame.rs +++ b/embassy-stm32/src/can/frame.rs @@ -129,6 +129,11 @@ impl ClassicData { &self.bytes } + /// Raw mutable read access to data. + pub fn raw_mut(&mut self) -> &mut [u8] { + &mut self.bytes + } + /// Checks if the length can be encoded in FDCAN DLC field. pub const fn is_valid_len(len: usize) -> bool { match len { @@ -209,6 +214,11 @@ impl Frame { &self.data.raw() } + /// Get mutable reference to data + pub fn data_mut(&mut self) -> &mut [u8] { + self.data.raw_mut() + } + /// Get priority of frame pub fn priority(&self) -> u32 { self.header().priority() @@ -314,6 +324,11 @@ impl FdData { &self.bytes } + /// Raw mutable read access to data. + pub fn raw_mut(&mut self) -> &mut [u8] { + &mut self.bytes + } + /// Checks if the length can be encoded in FDCAN DLC field. pub const fn is_valid_len(len: usize) -> bool { match len { @@ -392,6 +407,11 @@ impl FdFrame { pub fn data(&self) -> &[u8] { &self.data.raw() } + + /// Get mutable reference to data + pub fn data_mut(&mut self) -> &mut [u8] { + self.data.raw_mut() + } } impl embedded_can::Frame for FdFrame {