fix stop pwm
This commit is contained in:
parent
221d3551e2
commit
4fdf2e2857
1 changed files with 7 additions and 10 deletions
|
|
@ -140,7 +140,7 @@ void pwm_set_duty(uint16_t duty)
|
||||||
pwmInfo.dutyCycle = duty;
|
pwmInfo.dutyCycle = duty;
|
||||||
if (duty == 0 || duty == UINT16_MAX)
|
if (duty == 0 || duty == UINT16_MAX)
|
||||||
{
|
{
|
||||||
pwmInfo.output = (duty == UINT16_MAX);
|
pwmInfo.output = (duty == UINT16_MAX);
|
||||||
}
|
}
|
||||||
debug("Duty set at %u",pwmInfo.dutyCycle);
|
debug("Duty set at %u",pwmInfo.dutyCycle);
|
||||||
pwm_restart();
|
pwm_restart();
|
||||||
|
|
@ -176,10 +176,10 @@ void pwm_start()
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (uint8_t i = 0; i < pwmInfo.usedPins; ++i)
|
for (uint8_t i = 0; i < pwmInfo.usedPins; ++i)
|
||||||
{
|
{
|
||||||
gpio_write(pwmInfo.pins[i].pin, pwmInfo.reverse ? !pwmInfo.output : pwmInfo.output );
|
gpio_write(pwmInfo.pins[i].pin, pwmInfo.reverse ? !pwmInfo.output : pwmInfo.output );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
debug("PWM started");
|
debug("PWM started");
|
||||||
pwmInfo.running = 1;
|
pwmInfo.running = 1;
|
||||||
|
|
@ -189,12 +189,9 @@ void pwm_stop()
|
||||||
{
|
{
|
||||||
timer_set_interrupts(FRC1, false);
|
timer_set_interrupts(FRC1, false);
|
||||||
timer_set_run(FRC1, false);
|
timer_set_run(FRC1, false);
|
||||||
if (pwmInfo.dutyCycle == 0 || pwmInfo.dutyCycle == UINT16_MAX)
|
for (uint8_t i = 0; i < pwmInfo.usedPins; ++i)
|
||||||
{
|
{
|
||||||
for (uint8_t i = 0; i < pwmInfo.usedPins; ++i)
|
|
||||||
{
|
|
||||||
gpio_write(pwmInfo.pins[i].pin, pwmInfo.reverse ? true : false);
|
gpio_write(pwmInfo.pins[i].pin, pwmInfo.reverse ? true : false);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
debug("PWM stopped");
|
debug("PWM stopped");
|
||||||
pwmInfo.running = 0;
|
pwmInfo.running = 0;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue