1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-02-20 10:54:14 +01:00

LP-117 Allow USART Port options to be set in hwsettings, to allow suitable configuration based on fc board, presence of ext. inverters and wiring - defaults to Non-Inverted single wire connection.

This commit is contained in:
Eric Price 2019-07-06 20:10:06 +02:00
parent d6c0141e01
commit 8aef698b6b
3 changed files with 35 additions and 9 deletions

View File

@ -43,6 +43,7 @@
#include "flightbatterystate.h"
#include "gpspositionsensor.h"
#include "frskysporttelemetrysettings.h"
#include "hwsettings.h"
#include "taskinfo.h"
@ -88,7 +89,6 @@ struct frsky_sport_telemetry {
int32_t scheduled_item;
uint32_t last_poll_time;
uintptr_t com;
bool master;
bool ignore_echo;
uint8_t ignore_rx_chars;
struct frsky_settings frsky_settings;
@ -254,8 +254,6 @@ static void FrSKYSPortTelemetrySettingsUpdatedCb(__attribute__((unused)) UAVObjE
FrSKYSPortTelemetrySettingsData settings;
FrSKYSPortTelemetrySettingsGet(&settings);
frsky->master = (settings.PortMaster == FRSKYSPORTTELEMETRYSETTINGS_PORTMASTER_TRUE);
}
@ -293,15 +291,43 @@ static int32_t uavoFrSKYSPortBridgeInitialize(void)
frsky->item_last_triggered[i] = PIOS_DELAY_GetuS();
}
// Set Port options:
// BAUD rate
PIOS_COM_ChangeBaud(frsky->com, FRSKY_SPORT_BAUDRATE);
HwSettingsSPortModeOptions options;
HwSettingsSPortModeGet(&options);
bool halfduplex;
enum PIOS_USART_Inverted inverted;
switch (options) {
case HWSETTINGS_SPORTMODE_HALFDUPLEXNONINVERTED:
halfduplex = true;
inverted = PIOS_USART_Inverted_None;
break;
case HWSETTINGS_SPORTMODE_HALFDUPLEXINVERTED:
halfduplex = true;
inverted = PIOS_USART_Inverted_RxTx;
break;
case HWSETTINGS_SPORTMODE_FULLDUPLEXNONINVERTED:
halfduplex = false;
inverted = PIOS_USART_Inverted_None;
break;
case HWSETTINGS_SPORTMODE_FULLDUPLEXINVERTED:
halfduplex = false;
inverted = PIOS_USART_Inverted_RxTx;
break;
}
// Port Inversion (Not available on STM32F4, will have no effect)
PIOS_COM_Ioctl(frsky->com, PIOS_IOCTL_USART_SET_INVERTED, &inverted);
// HalfDplex mode (Not available on STM32F0, will have no effect)
PIOS_COM_Ioctl(frsky->com, PIOS_IOCTL_USART_SET_HALFDUPLEX, &halfduplex);
FrSKYSPortTelemetrySettingsConnectCallback(FrSKYSPortTelemetrySettingsUpdatedCb);
FrSKYSPortTelemetrySettingsUpdatedCb(0);
PIOS_COM_ChangeBaud(frsky->com, FRSKY_SPORT_BAUDRATE);
bool param = true;
PIOS_COM_Ioctl(frsky->com, PIOS_IOCTL_USART_SET_HALFDUPLEX, &param);
return 0;
}
}

View File

@ -3,7 +3,6 @@
<description>FrSKY S.Port Telemetry configuration.</description>
<field name="AccelData" units="" type="enum" elements="1" options="Accels,NEDAccels, NEDVelocity, AttitudeAngles" defaultvalue="Accels"/>
<field name="PortMaster" units="" type="enum" elements="1" options="False,True" defaultvalue="False"/>
<access gcs="readwrite" flight="readwrite"/>
<telemetrygcs acked="true" updatemode="onchange" period="0"/>

View File

@ -35,6 +35,7 @@
<field name="ADCRouting" units="" type="enum" elementnames="adc0,adc1,adc2,adc3,adc4,adc5,adc6,adc7" options="Disabled,BatteryVoltage,BatteryCurrent,AnalogAirspeed,NTCTemperature,LM35Temperature,Generic" defaultvalue="Disabled"/>
<field name="DSMxBind" units="" type="uint8" elements="1" defaultvalue="0"/>
<field name="SBusMode" units="" type="enum" elements="1" options="Normal,Non Inverted" defaultvalue="Normal"/>
<field name="SPortMode" units="" type="enum" elements="1" options="HalfDuplexNonInverted,HalfDuplexInverted,FullDuplexNonInverted,FullDuplexInverted" defaultvalue="HalfDuplexNonInverted"/>
<field name="WS2811LED_Out" units="" type="enum" elements="1" options="ServoOut1,ServoOut2,ServoOut3,ServoOut4,ServoOut5,ServoOut6,FlexiIOPin3,FlexiIOPin4,Disabled" defaultvalue="Disabled"
limits="%0905NE:ServoOut2:ServoOut3:ServoOut4:ServoOut5:ServoOut6:FlexiIOPin3:FlexiIOPin4;"
/>