-
Notifications
You must be signed in to change notification settings - Fork 360
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update drv_pwm.c #153
base: master
Are you sure you want to change the base?
Update drv_pwm.c #153
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -281,19 +281,42 @@ static void failsafeCheck(uint8_t channel, uint16_t pulse) | |
} | ||
} | ||
|
||
// Contains detection & fix for the "8 channels in 18ms Frsky problem" see: | ||
// http://diydrones.com/profiles/blogs/why-frsky-cppm-signal-is-so-disappointing | ||
// http://forums.openpilot.org/topic/16146-cc3d-with-frsky-8-channels-in-cppm-mode/ | ||
// Tested on: Frsky D8R-II and Frsky D4FR | ||
static void ppmCallback(uint8_t port, uint16_t capture) | ||
{ | ||
(void)port; | ||
uint16_t diff; | ||
static uint16_t now; | ||
uint16_t newval = capture; | ||
static uint16_t last = 0; | ||
static uint16_t frametime = 0; | ||
static uint8_t chan = 0; | ||
static uint8_t frsky_errcnt = 0; | ||
static bool frsky_18patch = false; | ||
uint16_t diff = newval - last; | ||
bool sync = diff > 2700; // rcgroups.com/forums/showpost.php?p=21996147&postcount=3960 "So, if you use 2.5ms or higher as being the reset for the PPM stream start, you will be fine. I use 2.7ms just to be safe." | ||
last = newval; | ||
|
||
if(frsky_18patch) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. spacing between if and ( |
||
sync |= chan == 8; // FrSky 18ms Fix, force sync after 8 channels | ||
} else { | ||
frametime += diff; | ||
} | ||
|
||
last = now; | ||
now = capture; | ||
diff = now - last; | ||
|
||
if (diff > 2700) { // Per http://www.rcgroups.com/forums/showpost.php?p=21996147&postcount=3960 "So, if you use 2.5ms or higher as being the reset for the PPM stream start, you will be fine. I use 2.7ms just to be safe." | ||
if (sync) { | ||
if(!frsky_18patch) { | ||
if(frametime < 18300 && chan == 8) { | ||
frsky_errcnt++; | ||
} else { | ||
frsky_errcnt = 0; | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. no need for braces for single line if () conditions There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I thought BF wants it that way because here: https://github.com/multiwii/baseflight/blob/master/src/mw.c#L108 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. left overs of original code.
|
||
if(frsky_errcnt == 30) { | ||
frsky_18patch = true; // Condition must be true 30 times in a row before we enable the FrSky fix | ||
} else { | ||
frametime = 0; | ||
} | ||
} | ||
chan = 0; | ||
} else { | ||
if (diff > PULSE_MIN && diff < PULSE_MAX && chan < MAX_INPUTS) { // 750 to 2250 ms is our 'valid' channel range | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is here from beginning, but if youre updating this part of code might as well make chan as int.