Merge pull request #4077 from RichardWGNR/issue-4075
[embassy-stm32] Capability to modify CAN frame data without copying.
This commit is contained in:
commit
29ef61cd57
@ -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 {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user