mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-17 05:15:25 +03:00
de-duplicate failsafe code. extract failsafe code to seperate files.
remove dependency on board.h and mw.h on a few files. Moved rx configuration paramaters into rxConfig in order to remove the dependency on config_t from the sbus rx code - sumd/spektrum to follow. Avoided use of YAW/PITCH/ROLL in some files since those constants are from an unrelated enum type. Replaced some magic numbers with constants to remove comments and improve code readability. Note, due to the tight coupling and global variable usage it was difficult to create a smaller commit.
This commit is contained in:
parent
d7eb416aa9
commit
0f02e12f40
26 changed files with 606 additions and 437 deletions
14
src/main.c
14
src/main.c
|
@ -1,10 +1,13 @@
|
|||
#include "board.h"
|
||||
#include "flight_common.h"
|
||||
#include "mw.h"
|
||||
|
||||
#include "rx.h"
|
||||
#include "rx_sbus.h"
|
||||
#include "rx_common.h"
|
||||
#include "telemetry_common.h"
|
||||
#include "boardalignment.h"
|
||||
#include "config.h"
|
||||
#include "config_storage.h"
|
||||
|
||||
#include "build_config.h"
|
||||
|
||||
|
@ -12,9 +15,6 @@ core_t core;
|
|||
|
||||
extern rcReadRawDataPtr rcReadRawFunc;
|
||||
|
||||
// receiver read function
|
||||
extern uint16_t pwmReadRawRC(uint8_t chan);
|
||||
|
||||
int main(void)
|
||||
{
|
||||
uint8_t i;
|
||||
|
@ -63,7 +63,7 @@ int main(void)
|
|||
pwm_params.idlePulse = mcfg.neutral3d;
|
||||
if (pwm_params.motorPwmRate > 500)
|
||||
pwm_params.idlePulse = 0; // brushed motors
|
||||
pwm_params.servoCenterPulse = mcfg.midrc;
|
||||
pwm_params.servoCenterPulse = mcfg.rxConfig.midrc;
|
||||
pwm_params.failsafeThreshold = cfg.failsafe_detect_threshold;
|
||||
switch (mcfg.power_adc_channel) {
|
||||
case 1:
|
||||
|
@ -86,13 +86,13 @@ int main(void)
|
|||
core.numRCChannels = MAX_INPUTS;
|
||||
|
||||
if (feature(FEATURE_SERIALRX)) {
|
||||
switch (mcfg.serialrx_type) {
|
||||
switch (mcfg.rxConfig.serialrx_type) {
|
||||
case SERIALRX_SPEKTRUM1024:
|
||||
case SERIALRX_SPEKTRUM2048:
|
||||
spektrumInit(&rcReadRawFunc);
|
||||
break;
|
||||
case SERIALRX_SBUS:
|
||||
sbusInit(&rcReadRawFunc);
|
||||
sbusInit(&rcReadRawFunc, &mcfg.rxConfig);
|
||||
break;
|
||||
case SERIALRX_SUMD:
|
||||
sumdInit(&rcReadRawFunc);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue