1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-03-16 08:29:15 +01:00

OP-1683 - Clenaup, trigger update in setfailsafe, Fix standard pwm operation

This commit is contained in:
Alessio Morale 2015-01-25 21:25:14 +01:00
parent 73dc04b436
commit 7955f63c98
2 changed files with 52 additions and 49 deletions

View File

@ -617,6 +617,8 @@ static void setFailsafe(const ActuatorSettingsData *actuatorSettings, const Mixe
for (int n = 0; n < ACTUATORCOMMAND_CHANNEL_NUMELEM; ++n) {
set_channel(n, Channel[n], actuatorSettings);
}
// Send the updated command
PIOS_Servo_Update();
// Update output object's parts that we changed
ActuatorCommandChannelSet(Channel);

View File

@ -95,22 +95,18 @@ int32_t PIOS_Servo_Init(const struct pios_servo_cfg *cfg)
case TIM_Channel_1:
TIM_OC1Init(chan->timer, &servo_cfg->tim_oc_init);
TIM_OC1PreloadConfig(chan->timer, TIM_OCPreload_Enable);
TIM_OC1PolarityConfig(chan->timer, TIM_OCPolarity_Low);
break;
case TIM_Channel_2:
TIM_OC2Init(chan->timer, &servo_cfg->tim_oc_init);
TIM_OC2PreloadConfig(chan->timer, TIM_OCPreload_Enable);
TIM_OC2PolarityConfig(chan->timer, TIM_OCPolarity_Low);
break;
case TIM_Channel_3:
TIM_OC3Init(chan->timer, &servo_cfg->tim_oc_init);
TIM_OC3PreloadConfig(chan->timer, TIM_OCPreload_Enable);
TIM_OC3PolarityConfig(chan->timer, TIM_OCPolarity_Low);
break;
case TIM_Channel_4:
TIM_OC4Init(chan->timer, &servo_cfg->tim_oc_init);
TIM_OC4PreloadConfig(chan->timer, TIM_OCPreload_Enable);
TIM_OC4PolarityConfig(chan->timer, TIM_OCPolarity_Low);
break;
}
}
@ -123,7 +119,9 @@ void PIOS_Servo_SetBankMode(uint8_t bank, uint8_t mode)
PIOS_Assert(bank < PIOS_SERVO_BANKS);
pios_servo_bank_mode[bank] = mode;
if (pios_servo_bank_timer[bank]) {
for (uint8_t i = 0; (i < servo_cfg->num_channels); i++) {
if (pios_servo_pin_bank[i] == bank) {
const struct pios_tim_channel *chan = &servo_cfg->channels[i];
switch (mode) {
case PIOS_SERVO_BANK_MODE_SINGLE_PULSE:
@ -147,16 +145,16 @@ void PIOS_Servo_SetBankMode(uint8_t bank, uint8_t mode)
/* Set up for output compare function */
switch (chan->timer_chan) {
case TIM_Channel_1:
TIM_OC1PolarityConfig(chan->timer, TIM_OCPolarity_Low);
TIM_OC1PolarityConfig(chan->timer, TIM_OCPolarity_High);
break;
case TIM_Channel_2:
TIM_OC2PolarityConfig(chan->timer, TIM_OCPolarity_Low);
TIM_OC2PolarityConfig(chan->timer, TIM_OCPolarity_High);
break;
case TIM_Channel_3:
TIM_OC3PolarityConfig(chan->timer, TIM_OCPolarity_Low);
TIM_OC3PolarityConfig(chan->timer, TIM_OCPolarity_High);
break;
case TIM_Channel_4:
TIM_OC4PolarityConfig(chan->timer, TIM_OCPolarity_Low);
TIM_OC4PolarityConfig(chan->timer, TIM_OCPolarity_High);
break;
}
break;
@ -164,6 +162,7 @@ void PIOS_Servo_SetBankMode(uint8_t bank, uint8_t mode)
PIOS_Assert(false);
}
}
}
// Setup the timer accordingly
switch (mode) {
case PIOS_SERVO_BANK_MODE_SINGLE_PULSE:
@ -178,6 +177,8 @@ void PIOS_Servo_SetBankMode(uint8_t bank, uint8_t mode)
PIOS_Assert(false);
}
}
}
void PIOS_Servo_Update()
{