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: Andriy Gelman <andriy.gelman@gmail.com>
This commit is contained in:
parent
9b3c0572cb
commit
c348a05d5a
1 changed files with 1 additions and 1 deletions
|
@ -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_seg1 = ts1 - res->prop_seg;
|
||||||
res->phase_seg2 = ts2;
|
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;
|
return sp_calc > sp ? sp_calc - sp : sp - sp_calc;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue