Cleaner first pulse

This commit is contained in:
Raphael Coeffic
2022-03-24 10:40:17 +01:00
committed by Raphael Coeffic
parent 86d1ca4364
commit f09c10b49d
3 changed files with 13 additions and 6 deletions
-5
View File
@@ -35,11 +35,6 @@
void _send_1(uint8_t v)
{
if (extmodulePulsesData.dsm2.index & 1)
v += 2;
else
v -= 2;
*extmodulePulsesData.dsm2.ptr++ = v - 1;
extmodulePulsesData.dsm2.index += 1;
}
@@ -81,7 +81,7 @@ static void config_ppm_output(uint16_t ppm_delay, bool polarity)
// AAR register defines duration of each pulse, it is
// updated after every pulse in Update interrupt handler.
stm32_pulse_config_output(&extmoduleTimer, !polarity, LL_TIM_OCMODE_PWM1,
stm32_pulse_config_output(&extmoduleTimer, !polarity, LL_TIM_OCMODE_FORCED_INACTIVE,
ppm_delay * 2);
}
@@ -155,6 +155,17 @@ static void set_oc_mode(const stm32_pulse_timer_t* tim, uint32_t ocmode)
LL_TIM_OC_SetMode(tim->TIMx, channel, ocmode);
}
static void force_start_level(const stm32_pulse_timer_t* tim)
{
uint32_t channel = tim->TIM_Channel;
if (channel == LL_TIM_CHANNEL_CH1N)
channel = LL_TIM_CHANNEL_CH1;
uint32_t mode = LL_TIM_OC_GetMode(tim->TIMx, channel);
LL_TIM_OC_SetMode(tim->TIMx, channel, LL_TIM_OCMODE_FORCED_ACTIVE);
LL_TIM_OC_SetMode(tim->TIMx, channel, mode);
}
void stm32_pulse_start_dma_req(const stm32_pulse_timer_t* tim,
const void* pulses, uint16_t length,
uint32_t ocmode, uint32_t cmp_val)
@@ -211,6 +222,7 @@ void stm32_pulse_start_dma_req(const stm32_pulse_timer_t* tim,
LL_TIM_GenerateEvent_UPDATE(tim->TIMx);
// start timer
force_start_level(tim);
LL_TIM_EnableCounter(tim->TIMx);
}