Skip to content

Commit

Permalink
Fix self-reception flag
Browse files Browse the repository at this point in the history
  • Loading branch information
bugadani committed Oct 7, 2024
1 parent d104906 commit c6a59b9
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions esp-hal/src/twai/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,7 @@ impl EspTwaiFrame {
data,
dlc,
is_remote: false,
self_reception: true,
self_reception: false,
}
}
}
Expand Down Expand Up @@ -1504,6 +1504,7 @@ pub trait Instance: crate::private::Sealed {

let is_standard_format = data_0 & 0b1 << 7 == 0;
let is_data_frame = data_0 & 0b1 << 6 == 0;
let self_reception = data_0 & 0b1 << 4 != 0;
let dlc = data_0 & 0b1111;

if dlc > 8 {
Expand Down Expand Up @@ -1541,11 +1542,12 @@ pub trait Instance: crate::private::Sealed {
(id, register_block.data_5().as_ptr())
};

let frame = if is_data_frame {
let mut frame = if is_data_frame {
unsafe { EspTwaiFrame::new_from_data_registers(id, data_ptr, dlc) }
} else {
EspTwaiFrame::new_remote(id, dlc).unwrap()
};
frame.self_reception = self_reception;

// Release the packet we read from the FIFO, allowing the peripheral to prepare
// the next packet.
Expand Down

0 comments on commit c6a59b9

Please sign in to comment.