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

Allow the user to specify their serial port scenarios.

This commit is contained in:
Dominic Clifton 2014-05-10 01:57:12 +01:00
parent 5043370b2f
commit 0fd127bf60
8 changed files with 258 additions and 50 deletions

View file

@ -92,10 +92,6 @@ int main(void)
drv_pwm_config_t pwm_params;
drv_adc_config_t adc_params;
bool sensorsOK = false;
#ifdef SOFTSERIAL_LOOPBACK
serialPort_t* loopbackPort1 = NULL;
serialPort_t* loopbackPort2 = NULL;
#endif
initPrintfSupport();
@ -154,6 +150,10 @@ int main(void)
featureClear(FEATURE_SOFTSERIAL);
}
#ifndef FY90Q
timerInit();
#endif
serialInit(&masterConfig.serialConfig);
// when using airplane/wing mixer, servo/motor outputs are remapped
@ -187,14 +187,11 @@ int main(void)
pwm_params.adcChannel = 0; // FIXME this is the same as PWM1
break;
}
failsafe = failsafeInit(&masterConfig.rxConfig);
buzzerInit(failsafe);
#ifndef FY90Q
timerInit();
#endif
pwmInit(&pwm_params);
failsafe = failsafeInit(&masterConfig.rxConfig);
buzzerInit(failsafe);
rxInit(&masterConfig.rxConfig, failsafe);
if (feature(FEATURE_GPS)) {
@ -230,9 +227,28 @@ int main(void)
f.SMALL_ANGLE = 1;
#ifdef SOFTSERIAL_LOOPBACK
// FIXME this is a hack, perhaps add a FUNCTION_LOOPBACK to support it properly
serialPort_t *loopbackPort = (serialPort_t*)&(softSerialPorts[0]);
if (!loopbackPort->vTable) {
openSoftSerial1(19200, false);
}
serialPrint(loopbackPort, "LOOPBACK\r\n");
#endif
// loopy
while (1) {
loop();
#ifdef SOFTSERIAL_LOOPBACK
if (loopbackPort) {
while (serialTotalBytesWaiting(loopbackPort)) {
uint8_t b = serialRead(loopbackPort);
serialWrite(loopbackPort, b);
};
}
#endif
}
}