Skip to content

Commit

Permalink
transferred change of polarity to more central place (module_timer_dr…
Browse files Browse the repository at this point in the history
…iver)module_timer_driver

fixed problem of two back to back (hence invalid) ppm pulse trains at after init
  • Loading branch information
mha1 committed Mar 31, 2023
1 parent 2c2a458 commit dbffc62
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
4 changes: 2 additions & 2 deletions radio/src/pulses/ppm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ static void* ppmInit(uint8_t module)
auto delay = GET_MODULE_PPM_DELAY(module) * 2;
etx_timer_config_t cfg = {
.type = ETX_PWM,
.polarity = !GET_MODULE_PPM_POLARITY(module),
.polarity = GET_MODULE_PPM_POLARITY(module),
.cmp_val = (uint16_t)delay,
};

Expand Down Expand Up @@ -141,7 +141,7 @@ static void ppmSendPulses(void* ctx, uint8_t* buffer, int16_t* channels, uint8_t
auto delay = GET_MODULE_PPM_DELAY(module) * 2;
etx_timer_config_t cfg = {
.type = ETX_PWM,
.polarity = !GET_MODULE_PPM_POLARITY(module),
.polarity = GET_MODULE_PPM_POLARITY(module),
.cmp_val = (uint16_t)delay,
};

Expand Down
7 changes: 5 additions & 2 deletions radio/src/targets/common/arm/stm32/module_timer_driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,13 @@ static void module_timer_send(void* ctx, const etx_timer_config_t* cfg,
const void* pulses, uint16_t length)
{
auto timer = (const stm32_pulse_timer_t*)ctx;
if (!stm32_pulse_if_not_running_disable(timer)) return;
if (!stm32_pulse_if_not_running_disable(timer)) {
LL_DMA_DeInit(timer->DMAx, timer->DMA_Stream);
return;
}

// Set polarity
stm32_pulse_set_polarity(timer, cfg->polarity);
stm32_pulse_set_polarity(timer, !cfg->polarity);

// Start DMA request and re-enable timer
uint32_t ocmode = (cfg->type == ETX_PWM) ? LL_TIM_OCMODE_PWM1 : LL_TIM_OCMODE_TOGGLE;
Expand Down

0 comments on commit dbffc62

Please sign in to comment.