mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-24 16:55:36 +03:00
separate all telemetry code and add option to use softserial for telemetry.
to use, set softserial_baudrate=9600, softserial_inverted=1 and telemetry_softserial=1 then enable feature TELEMETRY. by disq git-svn-id: https://afrodevices.googlecode.com/svn/trunk/baseflight@448 7c89a4a9-59b9-e629-4cfe-3a2d53b20e61
This commit is contained in:
parent
47a4d30358
commit
779dfe8a92
8 changed files with 47 additions and 14 deletions
|
@ -202,13 +202,29 @@ static void sendHeading(void)
|
|||
|
||||
static bool telemetryEnabled = false;
|
||||
|
||||
void initTelemetry(bool State)
|
||||
void initTelemetry(void)
|
||||
{
|
||||
// Sanity check for softserial vs. telemetry port
|
||||
if (!feature(FEATURE_SOFTSERIAL))
|
||||
mcfg.telemetry_softserial = TELEMETRY_UART;
|
||||
|
||||
if (mcfg.telemetry_softserial == TELEMETRY_SOFTSERIAL)
|
||||
core.telemport = &(softSerialPorts[0].port);
|
||||
else
|
||||
core.telemport = core.mainport;
|
||||
}
|
||||
|
||||
void updateTelemetryState(void)
|
||||
{
|
||||
bool State = mcfg.telemetry_softserial != TELEMETRY_UART ? true : f.ARMED;
|
||||
|
||||
if (State != telemetryEnabled) {
|
||||
if (State)
|
||||
serialInit(9600);
|
||||
else
|
||||
serialInit(mcfg.serial_baudrate);
|
||||
if (mcfg.telemetry_softserial == TELEMETRY_UART) {
|
||||
if (State)
|
||||
serialInit(9600);
|
||||
else
|
||||
serialInit(mcfg.serial_baudrate);
|
||||
}
|
||||
telemetryEnabled = State;
|
||||
}
|
||||
}
|
||||
|
@ -218,6 +234,12 @@ static uint8_t cycleNum = 0;
|
|||
|
||||
void sendTelemetry(void)
|
||||
{
|
||||
if (mcfg.telemetry_softserial == TELEMETRY_UART && !f.ARMED)
|
||||
return;
|
||||
|
||||
if (serialTotalBytesWaiting(core.telemport) != 0)
|
||||
return;
|
||||
|
||||
if (millis() - lastCycleTime >= CYCLETIME) {
|
||||
lastCycleTime = millis();
|
||||
cycleNum++;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue