Skip to content

Commit cef5133

Browse files
committed
STM32 CAN: Fix issue with speed function calculation
1 parent 953b925 commit cef5133

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

targets/TARGET_STM/can_api.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -180,10 +180,10 @@ static unsigned int can_speed(unsigned int pclk, unsigned int cclk, unsigned cha
180180
}
181181

182182
if (hit) {
183-
btr = ((timing_pts[bits][1] << 20) & 0x00700000)
184-
| ((timing_pts[bits][0] << 16) & 0x000F0000)
185-
| ((psjw << 24) & 0x0000C000)
186-
| ((brp << 0) & 0x000003FF);
183+
btr = ((timing_pts[bits][1] << CAN_BTR_TS2_Pos) & CAN_BTR_TS2) |
184+
((timing_pts[bits][0] << CAN_BTR_TS1_Pos) & CAN_BTR_TS1) |
185+
((psjw << CAN_BTR_SJW_Pos) & CAN_BTR_SJW) |
186+
((brp << CAN_BTR_BRP_Pos) & CAN_BTR_BRP);
187187
} else {
188188
btr = 0xFFFFFFFF;
189189
}

0 commit comments

Comments
 (0)