From d2c40076db67d76ac4798d3b07e068ecf0089884 Mon Sep 17 00:00:00 2001 From: ProDrone Date: Wed, 12 Aug 2015 00:58:44 +0200 Subject: [PATCH] PPM and PWM now have their own ___ReadRawRC functions. Because a required change for PWM disturbed the PPM mode. --- src/main/drivers/pwm_rx.c | 5 +++++ src/main/drivers/pwm_rx.h | 1 + src/main/rx/pwm.c | 14 ++++++++++---- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/main/drivers/pwm_rx.c b/src/main/drivers/pwm_rx.c index fcd5f87f0e..33a04aac25 100644 --- a/src/main/drivers/pwm_rx.c +++ b/src/main/drivers/pwm_rx.c @@ -339,6 +339,11 @@ void ppmInConfig(const timerHardware_t *timerHardwarePtr) timerChConfigCallbacks(timerHardwarePtr, &self->edgeCb, &self->overflowCb); } +uint16_t ppmRead(uint8_t channel) +{ + return captures[channel]; +} + uint16_t pwmRead(uint8_t channel) { uint16_t capture = captures[channel]; diff --git a/src/main/drivers/pwm_rx.h b/src/main/drivers/pwm_rx.h index a81727f3c2..23ede57b01 100644 --- a/src/main/drivers/pwm_rx.h +++ b/src/main/drivers/pwm_rx.h @@ -30,6 +30,7 @@ void ppmAvoidPWMTimerClash(const timerHardware_t *timerHardwarePtr, TIM_TypeDef void pwmInConfig(const timerHardware_t *timerHardwarePtr, uint8_t channel); uint16_t pwmRead(uint8_t channel); +uint16_t ppmRead(uint8_t channel); bool isPPMDataBeingReceived(void); void resetPPMDataReceivedState(void); diff --git a/src/main/rx/pwm.c b/src/main/rx/pwm.c index 17ba6efaf8..894eb27a42 100644 --- a/src/main/rx/pwm.c +++ b/src/main/rx/pwm.c @@ -34,23 +34,29 @@ #include "rx/rx.h" #include "rx/pwm.h" -static uint16_t pwmReadRawRC(rxRuntimeConfig_t *rxRuntimeConfigPtr, uint8_t chan) +static uint16_t pwmReadRawRC(rxRuntimeConfig_t *rxRuntimeConfigPtr, uint8_t channel) { UNUSED(rxRuntimeConfigPtr); - return pwmRead(chan); + return pwmRead(channel); +} + +static uint16_t ppmReadRawRC(rxRuntimeConfig_t *rxRuntimeConfigPtr, uint8_t channel) +{ + UNUSED(rxRuntimeConfigPtr); + return ppmRead(channel); } void rxPwmInit(rxRuntimeConfig_t *rxRuntimeConfigPtr, rcReadRawDataPtr *callback) { UNUSED(rxRuntimeConfigPtr); // configure PWM/CPPM read function and max number of channels. serial rx below will override both of these, if enabled - *callback = pwmReadRawRC; - if (feature(FEATURE_RX_PARALLEL_PWM)) { rxRuntimeConfigPtr->channelCount = MAX_SUPPORTED_RC_PARALLEL_PWM_CHANNEL_COUNT; + *callback = pwmReadRawRC; } if (feature(FEATURE_RX_PPM)) { rxRuntimeConfigPtr->channelCount = MAX_SUPPORTED_RC_PPM_CHANNEL_COUNT; + *callback = ppmReadRawRC; } }