Special state = don't set timer, safer
This commit is contained in:
parent
0555625688
commit
c50201ee43
1 changed files with 9 additions and 9 deletions
|
|
@ -123,12 +123,9 @@ void pwm_set_freq(uint16_t freq)
|
||||||
timer_set_frequency(FRC1, freq);
|
timer_set_frequency(FRC1, freq);
|
||||||
pwmInfo._maxLoad = timer_get_load(FRC1);
|
pwmInfo._maxLoad = timer_get_load(FRC1);
|
||||||
|
|
||||||
if (pwmInfo.dutyCycle > 0 && pwmInfo.dutyCycle < UINT16_MAX)
|
if (pwmInfo.running)
|
||||||
{
|
{
|
||||||
if (pwmInfo.running)
|
pwm_start();
|
||||||
{
|
|
||||||
pwm_start();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -174,10 +171,13 @@ void pwm_start()
|
||||||
gpio_write(pwmInfo.pins[i].pin, true);
|
gpio_write(pwmInfo.pins[i].pin, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
timer_set_load(FRC1, pwmInfo._onLoad);
|
if (pwmInfo.dutyCycle > 0 && pwmInfo.dutyCycle < UINT16_MAX)
|
||||||
timer_set_reload(FRC1, false);
|
{
|
||||||
timer_set_interrupts(FRC1, true);
|
timer_set_load(FRC1, pwmInfo._onLoad);
|
||||||
timer_set_run(FRC1, true);
|
timer_set_reload(FRC1, false);
|
||||||
|
timer_set_interrupts(FRC1, true);
|
||||||
|
timer_set_run(FRC1, true);
|
||||||
|
}
|
||||||
|
|
||||||
pwmInfo.running = 1;
|
pwmInfo.running = 1;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue