mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-24 16:55:36 +03:00
First attempt at getting CC3D PPM to work when oneshot is enabled.
I don't think that this will work, as we are manipulating the timer value to trick it into overflowing. Better would be to force an overflow a different way, that would preserve the current timer value. This would then give the proper value to the CC3D PPM routine, provided it was then divided by 8.
This commit is contained in:
parent
da35b3844c
commit
c0ed21a818
1 changed files with 11 additions and 0 deletions
|
@ -24,6 +24,8 @@
|
|||
#include "build_config.h"
|
||||
|
||||
#include "common/utils.h"
|
||||
#include "config/config.h"
|
||||
|
||||
#include "system.h"
|
||||
|
||||
#include "nvic.h"
|
||||
|
@ -80,6 +82,7 @@ static uint16_t captures[PWM_PORTS_OR_PPM_CAPTURE_COUNT];
|
|||
|
||||
static uint8_t ppmFrameCount = 0;
|
||||
static uint8_t lastPPMFrameCount = 0;
|
||||
static uint8_t ppmCountDivisor = 1;
|
||||
|
||||
typedef struct ppmDevice {
|
||||
uint8_t pulseIndex;
|
||||
|
@ -157,6 +160,9 @@ static void ppmEdgeCallback(timerCCHandlerRec_t* cbRec, captureCompare_t capture
|
|||
/* Convert to 32-bit timer result */
|
||||
ppmDev.currentTime += ppmDev.largeCounter;
|
||||
|
||||
// Divide by 8 if Oneshot125 is active and this is a CC3D board
|
||||
ppmDev.currentTime = ppmDev.currentTime / ppmCountDivisor;
|
||||
|
||||
/* Capture computation */
|
||||
ppmDev.deltaTime = ppmDev.currentTime - ppmDev.previousTime;
|
||||
|
||||
|
@ -325,6 +331,11 @@ void ppmInConfig(const timerHardware_t *timerHardwarePtr)
|
|||
|
||||
timerConfigure(timerHardwarePtr, (uint16_t)PPM_TIMER_PERIOD, PWM_TIMER_MHZ);
|
||||
|
||||
if((timerHardwarePtr->tim == TIM4) && (feature(FEATURE_ONESHOT125))){
|
||||
ppmCountDivisor = 8;
|
||||
}
|
||||
|
||||
|
||||
timerChCCHandlerInit(&self->edgeCb, ppmEdgeCallback);
|
||||
timerChOvrHandlerInit(&self->overflowCb, ppmOverflowCallback);
|
||||
timerChConfigCallbacks(timerHardwarePtr, &self->edgeCb, &self->overflowCb);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue