Fix PWM maxLoad and make isr static

This commit is contained in:
gpascualg 2015-11-27 02:42:45 +01:00
parent 222d96fdb0
commit 7091f57bd9

View file

@ -36,7 +36,7 @@ typedef struct pwmInfoDefinition
static PWMInfo pwmInfo; static PWMInfo pwmInfo;
void frc1_interrupt_handler(void) static void frc1_interrupt_handler(void)
{ {
uint8_t i = 0; uint8_t i = 0;
bool out = true; bool out = true;
@ -108,6 +108,7 @@ void pwm_set_freq(uint16_t freq)
} }
timer_set_frequency(FRC1, freq); timer_set_frequency(FRC1, freq);
pwmInfo._maxLoad = timer_get_load(FRC1);
if (pwmInfo.running) if (pwmInfo.running)
{ {
@ -132,7 +133,6 @@ void pwm_restart()
void pwm_start() void pwm_start()
{ {
pwmInfo._maxLoad = timer_get_load(FRC1);
pwmInfo._onLoad = pwmInfo.dutyCicle * pwmInfo._maxLoad / UINT16_MAX; pwmInfo._onLoad = pwmInfo.dutyCicle * pwmInfo._maxLoad / UINT16_MAX;
pwmInfo._offLoad = pwmInfo._maxLoad - pwmInfo._onLoad; pwmInfo._offLoad = pwmInfo._maxLoad - pwmInfo._onLoad;
pwmInfo._step = PERIOD_ON; pwmInfo._step = PERIOD_ON;