mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-18 22:05:17 +03:00
reorganization of uart-based receiver drivers
FEATURE_SPEKTRUM has been removed and replaced with FEATURE_SERIALRX. cli option serialrx_type now configures what type of receiver it is 0 = spektrum1024, 1 = spektrum2048, 2 = sbus sbus will need hardware inverter to use. also cleaned up receiver drivers to assign readrawRC callback instead of assigning in code in main() none of this has been tested. git-svn-id: https://afrodevices.googlecode.com/svn/trunk/baseflight@418 7c89a4a9-59b9-e629-4cfe-3a2d53b20e61
This commit is contained in:
parent
04ab548d2e
commit
2272e1a5a6
10 changed files with 191 additions and 31 deletions
23
src/main.c
23
src/main.c
|
@ -5,9 +5,8 @@ core_t core;
|
|||
|
||||
extern rcReadRawDataPtr rcReadRawFunc;
|
||||
|
||||
// two receiver read functions
|
||||
// receiver read function
|
||||
extern uint16_t pwmReadRawRC(uint8_t chan);
|
||||
extern uint16_t spektrumReadRawRC(uint8_t chan);
|
||||
|
||||
#ifdef USE_LAME_PRINTF
|
||||
// gcc/GNU version
|
||||
|
@ -59,9 +58,9 @@ int main(void)
|
|||
pwm_params.airplane = true;
|
||||
else
|
||||
pwm_params.airplane = false;
|
||||
pwm_params.useUART = feature(FEATURE_GPS) || feature(FEATURE_SPEKTRUM); // spektrum support uses UART too
|
||||
pwm_params.useUART = feature(FEATURE_GPS) || feature(FEATURE_SERIALRX); // spektrum/sbus support uses UART too
|
||||
pwm_params.usePPM = feature(FEATURE_PPM);
|
||||
pwm_params.enableInput = !feature(FEATURE_SPEKTRUM); // disable inputs if using spektrum
|
||||
pwm_params.enableInput = !feature(FEATURE_SERIALRX); // disable inputs if using spektrum
|
||||
pwm_params.useServos = core.useServo;
|
||||
pwm_params.extraServos = cfg.gimbal_flags & GIMBAL_FORWARDAUX;
|
||||
pwm_params.motorPwmRate = mcfg.motor_pwm_rate;
|
||||
|
@ -81,12 +80,20 @@ int main(void)
|
|||
|
||||
pwmInit(&pwm_params);
|
||||
|
||||
// configure PWM/CPPM read function. spektrum below will override that
|
||||
// configure PWM/CPPM read function. spektrum or sbus below will override that
|
||||
rcReadRawFunc = pwmReadRawRC;
|
||||
|
||||
if (feature(FEATURE_SPEKTRUM)) {
|
||||
spektrumInit();
|
||||
rcReadRawFunc = spektrumReadRawRC;
|
||||
if (feature(FEATURE_SERIALRX)) {
|
||||
switch (mcfg.serialrx_type) {
|
||||
case SERIALRX_SPEKTRUM1024:
|
||||
case SERIALRX_SPEKTRUM2048:
|
||||
spektrumInit(&rcReadRawFunc);
|
||||
break;
|
||||
|
||||
case SERIALRX_SBUS:
|
||||
sbusInit(&rcReadRawFunc);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
// spektrum and GPS are mutually exclusive
|
||||
// Optional GPS - available in both PPM and PWM input mode, in PWM input, reduces number of available channels by 2.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue