1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-23 00:05:33 +03:00

Fix PPM support when using 8 channels on STM32F10x.

This was broken when 12 channel support was added in combination with
the STM32F3 support.
This commit is contained in:
Dominic Clifton 2014-05-26 13:28:36 +01:00
parent 8f6558156f
commit 5ccb0ecf36
3 changed files with 9 additions and 7 deletions

View file

@ -12,7 +12,6 @@
#include "pwm_rx.h" #include "pwm_rx.h"
#define PPM_CAPTURE_COUNT 12 #define PPM_CAPTURE_COUNT 12
#define PWM_INPUT_PORT_COUNT 8 #define PWM_INPUT_PORT_COUNT 8
@ -45,9 +44,12 @@ static pwmInputPort_t pwmInputPorts[PWM_INPUT_PORT_COUNT];
static uint16_t captures[PWM_PORTS_OR_PPM_CAPTURE_COUNT]; static uint16_t captures[PWM_PORTS_OR_PPM_CAPTURE_COUNT];
static uint8_t ppmFrameCount = 0; #define PPM_TIMER_PERIOD 0xFFFF
#define PWM_TIMER_PERIOD 0xFFFF
static uint8_t ppmFrameCount = 0;
static uint8_t lastPPMFrameCount = 0; static uint8_t lastPPMFrameCount = 0;
bool isPPMDataBeingReceived(void) bool isPPMDataBeingReceived(void)
{ {
return (ppmFrameCount != lastPPMFrameCount); return (ppmFrameCount != lastPPMFrameCount);
@ -62,7 +64,7 @@ void resetPPMDataReceivedState(void)
static void ppmCallback(uint8_t port, captureCompare_t capture) static void ppmCallback(uint8_t port, captureCompare_t capture)
{ {
int32_t diff; uint16_t diff; // See PPM_TIMER_PERIOD
static captureCompare_t now; static captureCompare_t now;
static captureCompare_t last = 0; static captureCompare_t last = 0;
@ -147,7 +149,7 @@ void pwmInConfig(uint8_t timerIndex, uint8_t channel)
pwmGPIOConfig(timerHardwarePtr->gpio, timerHardwarePtr->pin, timerHardwarePtr->gpioInputMode); pwmGPIOConfig(timerHardwarePtr->gpio, timerHardwarePtr->pin, timerHardwarePtr->gpioInputMode);
pwmICConfig(timerHardwarePtr->tim, timerHardwarePtr->channel, TIM_ICPolarity_Rising); pwmICConfig(timerHardwarePtr->tim, timerHardwarePtr->channel, TIM_ICPolarity_Rising);
timerConfigure(timerHardwarePtr, 0xFFFF, PWM_TIMER_MHZ); timerConfigure(timerHardwarePtr, PWM_TIMER_PERIOD, PWM_TIMER_MHZ);
configureTimerCaptureCompareInterrupt(timerHardwarePtr, channel, pwmCallback); configureTimerCaptureCompareInterrupt(timerHardwarePtr, channel, pwmCallback);
} }
@ -166,7 +168,7 @@ void ppmInConfig(uint8_t timerIndex)
pwmGPIOConfig(timerHardwarePtr->gpio, timerHardwarePtr->pin, timerHardwarePtr->gpioInputMode); pwmGPIOConfig(timerHardwarePtr->gpio, timerHardwarePtr->pin, timerHardwarePtr->gpioInputMode);
pwmICConfig(timerHardwarePtr->tim, timerHardwarePtr->channel, TIM_ICPolarity_Rising); pwmICConfig(timerHardwarePtr->tim, timerHardwarePtr->channel, TIM_ICPolarity_Rising);
timerConfigure(timerHardwarePtr, 0xFFFF, PWM_TIMER_MHZ); timerConfigure(timerHardwarePtr, PPM_TIMER_PERIOD, PWM_TIMER_MHZ);
configureTimerCaptureCompareInterrupt(timerHardwarePtr, UNUSED_PPM_TIMER_REFERENCE, ppmCallback); configureTimerCaptureCompareInterrupt(timerHardwarePtr, UNUSED_PPM_TIMER_REFERENCE, ppmCallback);
} }

View file

@ -10,7 +10,7 @@
typedef uint32_t captureCompare_t; typedef uint32_t captureCompare_t;
#endif #endif
#ifdef STM32F10X_MD #ifdef STM32F10X_MD
typedef uint32_t captureCompare_t; typedef uint16_t captureCompare_t;
#endif #endif
typedef void timerCCCallbackPtr(uint8_t port, captureCompare_t capture); typedef void timerCCCallbackPtr(uint8_t port, captureCompare_t capture);

View file

@ -310,7 +310,7 @@ void updateRSSI(void)
} }
} }
#if 1 #if 0
debug[3] = rawPwmRssi; debug[3] = rawPwmRssi;
#endif #endif