Commit 5ece02d5 authored by Keith Short's avatar Keith Short Committed by Anas Nashif
Browse files

npcx: fix NPCX PWM driver with PWM_POLARITY_INVERTED



Update NPCX PWM driver so PWM can be turned off as the first call when
PWM_POLARITY_INVERTED is used.

Signed-off-by: default avatarKeith Short <keithshort@google.com>
parent d6316aae
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -99,16 +99,16 @@ static int pwm_npcx_pin_set(const struct device *dev, uint32_t pwm,
	/* Disable PWM before configuring */
	inst->PWMCTL &= ~BIT(NPCX_PWMCTL_PWR);

	/* If pulse_cycles is 0, return directly since PWM is already off */
	if (pulse_cycles == 0)
		return 0;

	/* Select PWM inverted polarity (ie. active-low pulse). */
	if (flags & PWM_POLARITY_INVERTED)
		inst->PWMCTL |= BIT(NPCX_PWMCTL_INVP);
	else
		inst->PWMCTL &= ~BIT(NPCX_PWMCTL_INVP);

	/* If pulse_cycles is 0, return directly since PWM is already off */
	if (pulse_cycles == 0)
		return 0;

	/*
	 * Calculate PWM prescaler that let period_cycles map to
	 * maximum pwm period cycles and won't exceed it.