Skip to content

Commit

Permalink
implement configuring transceiver delay compensation
Browse files Browse the repository at this point in the history
  • Loading branch information
liamkinne committed Jan 24, 2025
1 parent 2169741 commit 78df8a1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,10 @@ pub struct DataBitTiming {
pub sync_jump_width: NonZeroU8,
}
impl DataBitTiming {
// #[inline]
// fn tdc(&self) -> u8 {
// let tsd = self.transceiver_delay_compensation as u8;
// //TODO: stm32g4 does not export the TDC field
// todo!()
// }
#[inline]
pub(crate) fn tdc(&self) -> bool {
self.transceiver_delay_compensation
}
#[inline]
pub(crate) fn dbrp(&self) -> u8 {
u8::from(self.prescaler) & 0x1F
Expand Down
6 changes: 6 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -735,6 +735,10 @@ where
self.control.config.dbtr = btr;

let can = self.registers();
if btr.tdc() {
let tcdo = btr.dtseg1() * btr.dbrp();
can.tdcr.write(|w| unsafe { w.tdco().bits(tcdo) });
}
can.dbtp.write(|w| unsafe {
w.dbrp()
.bits(btr.dbrp() - 1)
Expand All @@ -744,6 +748,8 @@ where
.bits(btr.dtseg2() - 1)
.dsjw()
.bits(btr.dsjw() - 1)
.tdc()
.bit(btr.tdc())
});
}

Expand Down

0 comments on commit 78df8a1

Please sign in to comment.