Commit c418c9ae authored by Andriy Gelman's avatar Andriy Gelman Committed by Anas Nashif
Browse files

drivers: can: Fix sample point calculation



CAN_SYNC_SEG and ts1 are in common units. Both need to be scaled by 1000
to calculate the sample point.

Signed-off-by: default avatarAndriy Gelman <andriy.gelman@gmail.com>
parent 61682bd6
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -175,7 +175,7 @@ static int update_sampling_pnt(uint32_t ts, uint32_t sp, struct can_timing *res,
	res->phase_seg1 = ts1 - res->prop_seg;
	res->phase_seg2 = ts2;

	sp_calc = (CAN_SYNC_SEG + ts1 * 1000) / ts;
	sp_calc = (CAN_SYNC_SEG + ts1) * 1000 / ts;

	return sp_calc > sp ? sp_calc - sp : sp - sp_calc;
}