Skip to content

Commit 7bfa914

Browse files
committed
implement configuring transceiver delay compensation
1 parent 454e804 commit 7bfa914

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

src/config.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,10 @@ pub struct DataBitTiming {
7878
pub sync_jump_width: NonZeroU8,
7979
}
8080
impl DataBitTiming {
81-
// #[inline]
82-
// fn tdc(&self) -> u8 {
83-
// let tsd = self.transceiver_delay_compensation as u8;
84-
// //TODO: stm32g4 does not export the TDC field
85-
// todo!()
86-
// }
81+
#[inline]
82+
pub(crate) fn tdc(&self) -> bool {
83+
self.transceiver_delay_compensation
84+
}
8785
#[inline]
8886
pub(crate) fn dbrp(&self) -> u8 {
8987
u8::from(self.prescaler) & 0x1F

src/lib.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -755,6 +755,10 @@ where
755755
self.control.config.dbtr = btr;
756756

757757
let can = self.registers();
758+
if btr.tdc() {
759+
let tcdo = btr.dtseg1() * btr.dbrp();
760+
can.tdcr.write(|w| unsafe { w.tdco().bits(tcdo) });
761+
}
758762
can.dbtp.write(|w| unsafe {
759763
w.dbrp()
760764
.bits(btr.dbrp() - 1)
@@ -764,6 +768,8 @@ where
764768
.bits(btr.dtseg2() - 1)
765769
.dsjw()
766770
.bits(btr.dsjw() - 1)
771+
.tdc()
772+
.bit(btr.tdc())
767773
});
768774
}
769775

0 commit comments

Comments
 (0)