Commit 14c200d0 authored by Andrei Emeltchenko's avatar Andrei Emeltchenko Committed by Maureen Helm
Browse files

drivers: pwm: Fix wrong dc calculation for pwm tests



Values used in tests/drivers/pwm/pwm_api overflows calculation inside
xec_compute_dc(). Make calculation to be done in u64_t and then
convert to int.

Signed-off-by: default avatarAndrei Emeltchenko <andrei.emeltchenko@intel.com>
parent ff733369
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -136,7 +136,8 @@ static u32_t xec_compute_dc(u32_t on, u32_t off)
{
	int dc = (on + 1) + (off + 1);

	dc = (((on + 1) * XEC_PWM_DC_PF) / dc);
	/* Make calculation in u64_t since XEC_PWM_DC_PF is large */
	dc = (((u64_t)(on + 1) * XEC_PWM_DC_PF) / dc);

	return (u32_t)dc;
}